KickJava   Java API By Example, From Geeks To Geeks.

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


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

26
27 package org.objectweb.openccm.ast.lib;
28
29 /** To access AST DeclarationKind. */
30 import org.objectweb.openccm.ast.api.DeclarationKind;
31
32 /** To access AST StringList. */
33 import org.objectweb.openccm.ast.api.StringList;
34
35 /** To report ASTError exceptions. */
36 import org.objectweb.openccm.ast.api.ASTError;
37
38 /**
39  * DeclarationWithMemberListImpl is a wrapper class for
40  * PSDL declarations with a list of member names.
41  *
42  *
43  * Inherits from:
44  *
45  * - DeclarationImpl as they are IDL declarations,
46  *
47  * - DeclarationWithMemberList: OMG IDL for PSDL declarations
48  * with a list of member names.
49  *
50  *
51  * Provides:
52  *
53  * - The list of member names,
54  * i.e. the getMemberList operation.
55  *
56  *
57  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
58  * <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
59  *
60  * @version 0.1
61  */

62
63 public class DeclarationWithMemberListImpl
64      extends DeclarationImpl
65   implements org.objectweb.openccm.ast.api.DeclarationWithMemberList
66 {
67     // ==================================================================
68
//
69
// Internal state.
70
//
71
// ==================================================================
72

73     /** The list of member names. */
74     protected StringListImpl members_;
75
76     // ==================================================================
77
//
78
// Constructor.
79
//
80
// ==================================================================
81

82     /**
83      * The constructor with the parent scope.
84      *
85      * @param rep The repository of the declaration.
86      * @param parent The parent scope of the declaration.
87      */

88     protected
89     DeclarationWithMemberListImpl(Repository rep,
90                                   ScopeImpl parent)
91     {
92         // Call the DeclarationImpl constructor.
93
super(rep, parent);
94
95         // Init internal state.
96
members_ = new StringListImpl();
97     }
98
99     // ==================================================================
100
//
101
// Internal methods.
102
//
103
// ==================================================================
104

105     // ==================================================================
106
//
107
// Methods for the inherited DeclarationImpl class.
108
//
109
// ==================================================================
110

111     /**
112      * Obtain its CORBA 3.0 Contained reference.
113      *
114      * @return The Contained object associated with the any declaration.
115      */

116     protected org.omg.CORBA.Contained JavaDoc
117     getContained()
118     {
119        return null;
120     }
121
122     // ==================================================================
123
//
124
// Public methods.
125
//
126
// ==================================================================
127

128     // ==================================================================
129
//
130
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
131
//
132
// ==================================================================
133

134     /**
135      * Obtain its DeclarationKind.
136      *
137      * This method is implemented into DeclarationImpl subclasses.
138      *
139      * @return The DeclarationKind of the object.
140      */

141     public long
142     getDeclKind()
143     {
144       return DeclarationKind.dk_null;
145     }
146
147     /**
148      * Create the declaration.
149      */

150     public void
151     create()
152     {
153         // Call the DeclarationImpl "create" method.
154
super.create();
155
156         // Check if a member is not specify more that once
157
int index = members_.checkSameItem();
158         if( index != -1 )
159         {
160             throw new ASTError( (String JavaDoc)members_.get(index) + " must be specified once and once only.");
161         }
162     }
163
164     /**
165      * Check if state members of the list are valid.
166      */

167     protected void
168     check(StorageTypeBaseImpl st)
169     {
170         int size = members_.getSize();
171         for(int i=0; i<size; i++)
172         {
173              String JavaDoc state = (String JavaDoc)members_.get(i);
174              if( st.isValidState(state) == false)
175              {
176                  throw new ASTError(getName() + " => " + state + " is not a valid state member." );
177              }
178         }
179     }
180
181     // ==================================================================
182
//
183
// Methods for OMG IDL org.objectweb.openccm.ast.api.DeclarationWithMemberList
184
//
185
// ==================================================================
186

187     /**
188      * Obtain the list of member names.
189      *
190      * @return The list of member names.
191      */

192     public StringList
193     getMemberList()
194     {
195         return members_;
196     }
197 }
198
Popular Tags