KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdo > sco > detached > DetachSCOArrayListFactory


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdo.sco.detached;
13
14 import com.versant.core.jdo.VersantPersistenceManager;
15 import com.versant.core.jdo.VersantStateManager;
16 import com.versant.core.common.VersantFieldMetaData;
17 import com.versant.core.common.Utils;
18 import com.versant.core.jdo.sco.CollectionData;
19 import com.versant.core.jdo.sco.VersantSCOCollectionFactory;
20 import com.versant.core.jdo.sco.VersantSimpleSCO;
21 import com.versant.core.metadata.FieldMetaData;
22 import com.versant.core.common.BindingSupportImpl;
23
24 import javax.jdo.spi.PersistenceCapable;
25 import java.io.Serializable JavaDoc;
26 import java.util.Collection JavaDoc;
27
28 public class DetachSCOArrayListFactory implements VersantSCOCollectionFactory,
29         Serializable JavaDoc {
30
31     /**
32      * Create a new DetachSCOArrayList instance.
33      * <p/>
34      * If collectionData contains any OIDs they are first resolved into PC
35      * instances.
36      */

37     public VersantSimpleSCO createSCOCollection(PersistenceCapable owner,
38                                                  VersantPersistenceManager pm, VersantStateManager stateManager,
39                                                  VersantFieldMetaData fmd, CollectionData collectionData) {
40         int n = collectionData.valueCount;
41         Object JavaDoc[] originalData = new Object JavaDoc[n];
42         originalData = Utils.getObjectsById(collectionData.values,
43                 collectionData.valueCount, pm, (FieldMetaData) fmd,
44                 fmd.isElementTypePC());
45         return new DetachSCOArrayList(owner, stateManager, fmd, originalData);
46     }
47
48     /**
49      * Create a new DetachSCOArrayList instance and fill it with the data in collection.
50      */

51     public VersantSimpleSCO createSCOCollection(PersistenceCapable owner,
52                                                  VersantPersistenceManager pm, VersantStateManager stateManager,
53                                                  VersantFieldMetaData fmd, Collection JavaDoc collection) {
54         return new DetachSCOArrayList(owner, stateManager, fmd, collection.toArray());
55     }
56     
57       
58 }
59
Popular Tags