KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ast > lib > StructMemberListImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle, Mathieu Vadet.
23 Contributor(s): Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.ast.lib;
28
29 /** To use AST StructMember. */
30 import org.objectweb.openccm.ast.api.StructMember;
31
32 /**
33  * StructMemberListImpl is a wrapper class for IDL struct member lists.
34  *
35  *
36  * Inherits from:
37  *
38  * - ListBaseImpl: The base class for all lists.
39  *
40  * - StructMemberList: OMG IDL for struct member lists.
41  *
42  *
43  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
44  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
45  *
46  * @version 0.3
47  */

48
49 public class StructMemberListImpl
50        extends ListBaseImpl
51        implements org.objectweb.openccm.ast.api.StructMemberList
52 {
53     // ==================================================================
54
//
55
// Internal state.
56
//
57
// ==================================================================
58

59     // ==================================================================
60
//
61
// Constructor.
62
//
63
// ==================================================================
64

65     /**
66      * The default constructor.
67      */

68     public
69     StructMemberListImpl()
70     {
71         // Call the ListBaseImpl constructor.
72
super();
73     }
74
75     // ==================================================================
76
//
77
// Internal methods.
78
//
79
// ==================================================================
80

81     // ==================================================================
82
//
83
// Public methods.
84
//
85
// ==================================================================
86

87     /**
88      * Obtain its associated CORBA::StructMemberSeq.
89      *
90      * @return Its associated CORBA::StructMemberSeq.
91      */

92     public org.omg.CORBA.StructMember JavaDoc[]
93     getStructMemberSeq()
94     {
95         // Create an array with the same length as the list.
96
org.omg.CORBA.StructMember JavaDoc[] result =
97             new org.omg.CORBA.StructMember JavaDoc[getSize()];
98
99         // Iterate on all elements of the list.
100
java.util.Iterator JavaDoc it = iterator();
101         for(int i=0; it.hasNext(); i++)
102         {
103             // Obtain the current element.
104
StructMemberImpl sm = (StructMemberImpl)it.next();
105
106             // Obtain its associated CORBA::StructMember.
107
result[i] = sm.getStructMember();
108         }
109
110         // Return the array.
111
return result;
112     }
113
114     /**
115      * Return the index name.
116      *
117      * @param index The index of the member that should be returned.
118      *
119      * @return The name of the member at the specified index.
120      */

121     public String JavaDoc
122     nameAt(int index)
123     {
124         return ((StructMemberImpl)super.get(index)).getName();
125     }
126
127     // ==================================================================
128
//
129
// Methods for OMG IDL org.objectweb.openccm.ast.api.StructMemberList
130
//
131
// ==================================================================
132

133     /**
134      * Add a member.
135      *
136      * @param name The name of the member.
137      * @param type The TypeRef of the member.
138      */

139     public void
140     addMember(String JavaDoc name,
141               org.objectweb.openccm.ast.api.TypeRef type)
142     {
143         if(type != null)
144         {
145             super.addObject( new StructMemberImpl(name, type) );
146         }
147     }
148
149     /**
150      * Obtain all the struct members.
151      *
152      * @return All the struct members.
153      */

154     public StructMember[]
155     getStructMembers()
156     {
157        return (StructMember[])super.toArray(new StructMember[0]);
158     }
159 }
160
Popular Tags