KickJava   Java API By Example, From Geeks To Geeks.

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


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 UnionMember. */
30 import org.objectweb.openccm.ast.api.UnionMember;
31
32 /**
33  * UnionMemberListImpl is a wrapper class for IDL union member lists.
34  *
35  *
36  * Inherits from:
37  *
38  * - ListBaseImpl: The base class for all lists.
39  *
40  * - UnionMemberList: OMG IDL for union 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 UnionMemberListImpl
50        extends ListBaseImpl
51        implements org.objectweb.openccm.ast.api.UnionMemberList
52 {
53     // ==================================================================
54
//
55
// Internal state.
56
//
57
// ==================================================================
58

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

65     /** The default constructor. */
66     public
67     UnionMemberListImpl()
68     {
69         // Call the ListBaseImpl constructor.
70
super();
71     }
72
73     // ==================================================================
74
//
75
// Internal methods.
76
//
77
// ==================================================================
78

79     // ==================================================================
80
//
81
// Public methods.
82
//
83
// ==================================================================
84

85     /**
86      * Obtain its associated CORBA::UnionMemberSeq.
87      *
88      *
89      * @param discriminator The discriminator TypeCode.
90      *
91      * @return Its associated CORBA::UnionMemberSeq.
92      **/

93     public org.omg.CORBA.UnionMember JavaDoc[]
94     getUnionMemberSeq(org.omg.CORBA.TypeCode JavaDoc discriminator)
95     {
96         // Create an array with the same length as the list.
97
org.omg.CORBA.UnionMember JavaDoc[] result =
98             new org.omg.CORBA.UnionMember JavaDoc[getSize()];
99
100         // Iterate on all elements of the list.
101
java.util.Iterator JavaDoc it = iterator();
102         for(int i=0; it.hasNext(); i++)
103         {
104             // Obtain the current element.
105
UnionMemberImpl um = (UnionMemberImpl)it.next();
106
107             // Obtain its associated CORBA::UnionMember.
108
result[i] = um.getUnionMember(discriminator);
109         }
110
111         // Return the array.
112
return result;
113     }
114
115     // ==================================================================
116
//
117
// Methods for OMG IDL org.objectweb.openccm.ast.api.UnionMemberList
118
//
119
// ==================================================================
120

121     // ==================================================================
122
//
123
// Methods for the StructMembers interface.
124
//
125
// ==================================================================
126

127     /**
128      * Add an union member.
129      *
130      * @param name The name of the union member.
131      * @param type The TypeRef of the union member.
132      * @param value The AnyValue of the union member.
133      */

134     public void
135     addMember(String JavaDoc name,
136               org.objectweb.openccm.ast.api.TypeRef type,
137               org.objectweb.openccm.ast.api.AnyValue value)
138     {
139         if ((type!=null) && (name!=null) && (value!=null))
140         {
141             super.addObject( new UnionMemberImpl(name, type,
142                                                 (AnyValueImpl)value) );
143         }
144     }
145
146     /**
147      * Obtain all the union members.
148      *
149      * @return All the union members.
150      */

151     public UnionMember[]
152     getUnionMembers()
153     {
154        return (UnionMember[])super.toArray(new UnionMember[0]);
155     }
156 }
157
Popular Tags