01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.jdo.sco;
12:
13: import com.versant.core.jdo.VersantPersistenceManager;
14: import com.versant.core.jdo.VersantStateManager;
15: import com.versant.core.common.VersantFieldMetaData;
16: import com.versant.core.common.Utils;
17: import com.versant.core.metadata.FieldMetaData;
18: import com.versant.core.common.BindingSupportImpl;
19:
20: import javax.jdo.spi.PersistenceCapable;
21: import java.io.Serializable;
22: import java.util.Collection;
23:
24: /**
25: *
26: */
27: public class SCOHashSetFactory implements VersantSCOCollectionFactory,
28: Serializable {
29:
30: /**
31: * Create a new SCOHashSet instance that implements the
32: * VersantSCOCollection interface.
33: * <p/>
34: * If collectionData contains any OIDs they are first resolved into PC
35: * instances.
36: */
37: public VersantSimpleSCO createSCOCollection(
38: PersistenceCapable owner, VersantPersistenceManager pm,
39: VersantStateManager stateManager, VersantFieldMetaData fmd,
40: CollectionData collectionData) {
41: int n = collectionData.valueCount;
42: Object[] originalData = new Object[n];
43: originalData = Utils.getObjectsById(collectionData.values,
44: collectionData.valueCount, pm, (FieldMetaData) fmd, fmd
45: .isElementTypePC());
46: return new SCOHashSet(owner, stateManager, fmd, originalData);
47: }
48:
49: /**
50: * Create a new SCOHashSet instance that implements the VersantSCOCollection
51: * interface and fill it with the data in collection.
52: */
53: public VersantSimpleSCO createSCOCollection(
54: PersistenceCapable owner, VersantPersistenceManager pm,
55: VersantStateManager stateManager, VersantFieldMetaData fmd,
56: Collection collection) {
57: return new SCOHashSet(owner, stateManager, fmd, collection
58: .toArray());
59: }
60:
61: }
|