KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > EnumDef_impl


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.
23 Contributor(s): Mathieu Vadet, Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.ir3;
28
29 // Package dependencies
30
import org.omg.CORBA.*;
31
32 /**
33  * Implementation of the CORBA::EnumDef interface.
34  *
35  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
36  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
37  *
38  * @version 0.4
39  */

40
41 public class EnumDef_impl
42        extends Contained_impl
43        implements EnumDefOperations
44 {
45     // ==================================================================
46
//
47
// Constructor.
48
//
49
// ==================================================================
50

51     /**
52      * TODO
53      */

54     public
55     EnumDef_impl(IFR ifr,
56                  Container_impl container)
57     {
58         // call the Contained_impl contructor.
59
super(ifr, container);
60
61         // set the tie servant object.
62
setServant(new EnumDefPOATie(this));
63
64         // init internal state.
65
members_ = new String JavaDoc[0];
66     }
67
68     // ==================================================================
69
//
70
// Internal state.
71
//
72
// ==================================================================
73

74     /**
75      * The members of the enum.
76      */

77     protected String JavaDoc[] members_;
78
79     // ==================================================================
80
//
81
// Internal methods for the inherited IRObject_impl class.
82
//
83
// ==================================================================
84

85     /**
86      * Warning : this operation must be implemented by subclasses.
87      * It allows us to avoid some casts while creating ::CORBA::TypeCode
88      */

89     protected TypeCode
90     recursiveType(java.util.List JavaDoc idSeq)
91     {
92         return type();
93     }
94
95     // ==================================================================
96
//
97
// Public methods.
98
//
99
// ==================================================================
100

101     /**
102      * Obtain its CORBA::EnumDef object reference.
103      */

104     public EnumDef
105     asEnumDef()
106     {
107         return EnumDefHelper.narrow(asObject());
108     }
109
110     // ==================================================================
111
//
112
// Internal methods for managing dependencies.
113
//
114
// ==================================================================
115

116     /**
117      * Cuts dependencies to other objects.
118      */

119     protected void
120     cutDependencies()
121     {
122         members_ = null;
123
124         // Calls the Container_impl::cutDependencies operation.
125
super.cutDependencies();
126     }
127
128     // ==================================================================
129
//
130
// For CORBA::IRObject interface.
131
//
132
// ==================================================================
133

134     /**
135      * IDL:omg.org/CORBA/IRObject/def_kind:1.0
136      */

137     public DefinitionKind
138     def_kind()
139     {
140         return DefinitionKind.dk_Enum;
141     }
142
143     // ==================================================================
144
//
145
// For CORBA::IDLType interface.
146
//
147
// ==================================================================
148

149     /**
150      * IDL:omg.org/CORBA/IDLType/type:1.0
151      */

152     public TypeCode
153     type()
154     {
155         // delegate to the TypeCodeFactory.
156
return getIFR().getTCF().create_enum_tc(id(), name(), members());
157     }
158
159     // ==================================================================
160
//
161
// For CORBA::EnumDef interface.
162
//
163
// ==================================================================
164

165     /**
166      * IDL:omg.org/CORBA/EnumDef/members:1.0
167      */

168     public String JavaDoc[]
169     members()
170     {
171         return members_;
172     }
173
174     /**
175      * IDL:omg.org/CORBA/EnumDef/members:1.0
176      */

177     public void
178     members(String JavaDoc[] names)
179     {
180         // check member names.
181
for(int i=0; i<names.length; i++)
182     {
183             String JavaDoc name = names[i];
184
185             for(int j=i+1; j<names.length; j++)
186                 if(name.equalsIgnoreCase(names[j]))
187                     throw exceptionDuplicateDeclarator(name, j);
188
189             container_.checkName(name, false, false);
190
191             if (name.equalsIgnoreCase(name()))
192                throw exceptionNameAlreadyUsedByImmediateScope(name);
193         }
194
195         members_ = names;
196     }
197 }
198
Popular Tags