|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +package org.apache.mnemonic.collections; |
| 19 | + |
| 20 | +import org.apache.mnemonic.DurableType; |
| 21 | +import org.apache.mnemonic.EntityFactoryProxy; |
| 22 | +import org.apache.mnemonic.OutOfHybridMemory; |
| 23 | +import org.apache.mnemonic.RestorableAllocator; |
| 24 | +import org.apache.mnemonic.RestoreDurableEntityError; |
| 25 | + |
| 26 | +public class DurableArrayFactory { |
| 27 | + public static <A extends RestorableAllocator<A>, E> DurableArray<E> |
| 28 | + create(A allocator) throws OutOfHybridMemory { |
| 29 | + return create(allocator, 0, false); |
| 30 | + } |
| 31 | + |
| 32 | + public static <A extends RestorableAllocator<A>, E> DurableArray<E> |
| 33 | + create(A allocator, int size) throws OutOfHybridMemory { |
| 34 | + return create(allocator, size, false); |
| 35 | + } |
| 36 | + |
| 37 | + public static <A extends RestorableAllocator<A>, E> DurableArray<E> |
| 38 | + create(A allocator, int size, boolean autoreclaim) throws OutOfHybridMemory { |
| 39 | + return create(allocator, null, null, size, autoreclaim); |
| 40 | + } |
| 41 | + |
| 42 | + public static <A extends RestorableAllocator<A>, E> DurableArray<E> |
| 43 | + create(A allocator, EntityFactoryProxy[] factoryproxys, DurableType[] gfields, |
| 44 | + int size, boolean autoreclaim) throws OutOfHybridMemory { |
| 45 | + DurableArrayImpl<A, E> entity = new DurableArrayImpl<A, E>(size); |
| 46 | + entity.setupGenericInfo(factoryproxys, gfields); |
| 47 | + entity.createDurableEntity(allocator, factoryproxys, gfields, autoreclaim); |
| 48 | + return entity; |
| 49 | + } |
| 50 | + |
| 51 | + public static <A extends RestorableAllocator<A>, E> DurableArray<E> |
| 52 | + restore(A allocator, long phandler) throws RestoreDurableEntityError { |
| 53 | + return restore(allocator, phandler, false); |
| 54 | + } |
| 55 | + |
| 56 | + public static <A extends RestorableAllocator<A>, E> DurableArray<E> |
| 57 | + restore(A allocator, long phandler, boolean autoreclaim) throws RestoreDurableEntityError { |
| 58 | + return restore(allocator, null, null, phandler, autoreclaim); |
| 59 | + } |
| 60 | + |
| 61 | + public static <A extends RestorableAllocator<A>, E> DurableArray<E> |
| 62 | + restore(A allocator, EntityFactoryProxy[] factoryproxys, DurableType[] gfields, |
| 63 | + long phandler, boolean autoreclaim) throws RestoreDurableEntityError { |
| 64 | + DurableArrayImpl<A, E> entity = new DurableArrayImpl<A, E>(); |
| 65 | + entity.setupGenericInfo(factoryproxys, gfields); |
| 66 | + entity.restoreDurableEntity(allocator, factoryproxys, gfields, phandler, autoreclaim); |
| 67 | + return entity; |
| 68 | + } |
| 69 | +} |
0 commit comments