KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > modfact > corba > xmiio > mofobject > MOFObjectList


1 /**
2  * copyright 2002 2003 Laboratoire d'Informatique Paris 6 (LIP6)
3  *
4  * This file is part of ModFact.
5  *
6  * ModFact is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * at your option) any later version.
10  *
11  * ModFact is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with ModFact; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */

20 package org.objectweb.modfact.corba.xmiio.mofobject;
21
22 import java.util.List JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Iterator JavaDoc;
25
26 /**
27  * This class represents a list of objects and a list of xmi.idref corresponding to another objects.
28  * For example, it will be use for the return type of XXXTemplate methods to get the parsed objects
29  * and the xmi.idref of the referenced objects.
30  */

31 public class MOFObjectList {
32
33     /** List of objects. */
34     private List JavaDoc objectList;
35
36     /** List of XMI Id Ref. */
37     private List JavaDoc xmiIdRefList;
38
39     /**
40      * Default Constructor of a MOFObjectList.
41      */

42     public MOFObjectList() {
43         objectList = new ArrayList JavaDoc();
44         xmiIdRefList = new ArrayList JavaDoc();
45     }
46
47     /**
48      * Add an object to the corresponding list.
49      * @param obj The object to add.
50      */

51     public void addObject(Object JavaDoc obj) {
52         objectList.add(obj);
53     }
54
55     /**
56      * Get an interator from the list of objects.
57      * @return The iterator.
58      */

59     public Iterator JavaDoc getObjects() {
60         return objectList.iterator();
61     }
62
63     /**
64      * Add an XMI Id Ref to the corresponding list.
65      * @param xmiid The XMI Id to add.
66      */

67     public void addXmiIdRef(String JavaDoc xmiid) {
68         xmiIdRefList.add(xmiid);
69     }
70
71     /**
72      * Get an interator from the list of XMI Id Ref.
73      * @return The iterator.
74      */

75     public Iterator JavaDoc getXmiIdRef() {
76         return xmiIdRefList.iterator();
77     }
78
79     /**
80      * Add a MOFObjectList to this list.
81      * @param list The MOFObjectList to concatenate.
82      */

83     public void addMOFObjectList(MOFObjectList list) {
84         objectList.addAll(list.objectList);
85         xmiIdRefList.addAll(list.xmiIdRefList);
86     }
87
88     /**
89      * Get the first object of the list. This object is a BuiltObject, a XMIIdRef or a NullObject.
90      * @return The first object.
91      */

92     public MOFObject getFirstObject() {
93         if (objectList.size() > 0)
94             return new BuiltObject(objectList.get(0));
95         if (xmiIdRefList.size() > 0)
96             return new XMIIdRef((String JavaDoc) xmiIdRefList.get(0));
97         return new NullObject();
98     }
99
100 }
101
Popular Tags