KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdo > sco > SCOListFactory


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;
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.metadata.FieldMetaData;
19 import com.versant.core.common.BindingSupportImpl;
20
21 import javax.jdo.spi.PersistenceCapable;
22 import java.io.Serializable JavaDoc;
23 import java.util.Collection JavaDoc;
24
25 /**
26  *
27  */

28 public class SCOListFactory implements VersantSCOCollectionFactory,
29         Serializable JavaDoc {
30
31     /**
32      * Create a new SCOList instance that implements the
33      * VersantSCOCollection interface.
34      * <p/>
35      * If collectionData contains any OIDs they are first resolved into PC
36      * instances.
37      */

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

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