KickJava   Java API By Example, From Geeks To Geeks.

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


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 Declaration. */
33 import org.objectweb.openccm.ast.api.Declaration;
34
35 /** To use AST PsdlTypeRef */
36 import org.objectweb.openccm.ast.api.PsdlTypeRef;
37
38 /** To use AST StorageHomeDecl */
39 import org.objectweb.openccm.ast.api.StorageHomeDecl;
40
41 /** To use AST StorageTypeStateMemberDecl */
42 import org.objectweb.openccm.ast.api.StorageTypeStateMemberDecl;
43
44 /** To report ASTError exceptions. */
45 import org.objectweb.openccm.ast.api.ASTError;
46
47 /**
48  * StorageTypeStoreDirectiveDeclImpl is a wrapper class for
49  * PSDL storagetype state member declarations.
50  *
51  *
52  * Inherits from:
53  *
54  * - DeclarationImpl as they are IDL declarations,
55  *
56  * - StorageTypeStateMemberDecl: OMG IDL for PSDL storagetype store
57  * directive declarations.
58  *
59  *
60  * Provides:
61  *
62  * - The 'Readonly' property,
63  * i.e. the setReadonly and isReadonly operations.
64  *
65  *
66  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
67  * <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
68  *
69  * @version 0.1
70  */

71
72 public class StorageTypeStoreDirectiveDeclImpl
73      extends DeclarationImpl
74   implements org.objectweb.openccm.ast.api.StorageTypeStoreDirectiveDecl
75 {
76     // ==================================================================
77
//
78
// Internal state.
79
//
80
// ==================================================================
81

82     /** The name of the state member concerned. */
83     private String JavaDoc state_member_;
84
85     /** The state member's type. */
86     private PsdlTypeRef type_;
87
88     /** The storage home where the state member must be stored. */
89     private StorageHomeDeclImpl storage_home_;
90
91     // ==================================================================
92
//
93
// Constructor.
94
//
95
// ==================================================================
96

97     /**
98      * The constructor with the parent scope.
99      *
100      * @param rep The repository of the declaration.
101      * @param parent The parent scope of the value member declaration.
102      **/

103     protected
104     StorageTypeStoreDirectiveDeclImpl(Repository rep,
105                                       ScopeImpl parent)
106     {
107         // Call the DeclarationWithTypeRefImpl constructor.
108
super(rep, parent);
109
110         // Init internal state.
111
state_member_ = null;
112         type_ = null;
113         storage_home_ = null;;
114     }
115
116     // ==================================================================
117
//
118
// Internal methods.
119
//
120
// ==================================================================
121

122     // ==================================================================
123
//
124
// Internal methods for DeclarationImpl.
125
//
126
// ==================================================================
127

128     /**
129      * Obtain its CORBA 3.0 Contained reference.
130      *
131      * @return The Contained object associated with the value
132      * member declaration.
133      */

134     protected org.omg.CORBA.Contained JavaDoc
135     getContained()
136     {
137         // TODO
138
return null;
139     }
140
141     /**
142       * Obtain its category (IDL, PSDL, CIDL).
143       *
144       * @return The category of the declaration.
145       */

146     public org.objectweb.openccm.ast.api.DeclarationCategory
147     getCategory()
148     {
149         return org.objectweb.openccm.ast.api.DeclarationCategory.dc_psdl;
150     }
151
152     // ==================================================================
153
//
154
// Internal methods for DeclarationWithTypeRefImpl.
155
//
156
// ==================================================================
157

158     // ==================================================================
159
//
160
// Public methods.
161
//
162
// ==================================================================
163

164     // ==================================================================
165
//
166
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
167
//
168
// ==================================================================
169

170     /**
171      * Obtain the declaration external dependencies.
172      *
173      * Note: for scopes, contained objects are not considered
174      * as dependencies.
175      *
176      * @return The list of dependencies as an array of Declaration.
177      */

178     public Declaration[]
179     getDependencies()
180     {
181         // TODO
182
return null;
183     }
184
185     // ==================================================================
186
//
187
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
188
//
189
// ==================================================================
190

191     /**
192      * Obtain its DeclarationKind.
193      *
194      * @return The DeclarationKind of the object.
195      */

196     public long
197     getDeclKind()
198     {
199         return DeclarationKind.dk_storage_type_store_directive;
200     }
201
202     /**
203      * Create the declaration.
204      */

205     public void
206     create()
207     {
208         boolean found = false;
209
210         // Call the DeclarationImpl "create" method.
211
super.create();
212
213         org.objectweb.openccm.ast.api.StorageTypeDecl st = null;
214
215         /* First check :
216           <store_directive> ::= "stores" <simple_declarator> "as"
217                                <psdl_concrete_state_type> [<storagehome_scope>]
218            <simple_declarator> must be the name of a state member declared
219            in this storagetype or in one of the abstract storagetype it
220            implements.
221         */

222         org.objectweb.openccm.ast.api.AbstractStorageTypeDecl[] ast_decls = null;
223
224         st = (org.objectweb.openccm.ast.api.StorageTypeDecl)getParent();
225         // System.err.println("<= "+st.getName()+" =>");
226
// Get abstract storage types implemented
227
ast_decls = st.getAllImplementedAbstractStorageTypes().getAbstractStorageTypes();
228         int i = 0;
229         while ((!found) && (i<ast_decls.length))
230         {
231             // System.err.println("+--> "+ast_decls[i].getName());
232
Declaration[] decls = null;
233             // Get state members
234
decls = ast_decls[i].getContents(true, org.objectweb.openccm.ast.api.DeclarationKind.dk_storage_type_state_member);
235             int j=0;
236             while ((!found) && (j<decls.length))
237             {
238                 StorageTypeStateMemberDecl member = (StorageTypeStateMemberDecl)decls[j];
239                 org.objectweb.openccm.ast.api.StorageTypeBase type = member.getType().getStorageTypeBase();
240                 // System.err.println("+------>"+member.getName());
241
if( member.getName().equals(getStateMember()) )
242                     found = true;
243                 j++;
244             }
245             i++;
246         }
247         if (!found)
248             throw new ASTError( getStateMember() + " must be the name of a state member declared"
249                                 + " in this storagetype or in one of the abstract storagetype it implements.");
250
251         /* Second check :
252            if <psdl_concrete_state_type> denotes a storagetype S then the type
253            of the state member must be an abstract storagetype S' or a sequence/array
254            of an abstract storagetype S', S must implement directly or indirectly S'.
255            Idem for references.
256         */

257
258     }
259
260     // ==================================================================
261
//
262
// Methods for OMG IDL org.objectweb.openccm.ast.api.StorageTypeStoreDirectiveDecl
263
//
264
// ==================================================================
265

266     /**
267      * Set the state member.
268      *
269      * @param name The state member's name.
270      */

271     public void
272     setStateMember(String JavaDoc name)
273     {
274         state_member_ = name;
275     }
276
277     /**
278      * Get the state member
279      *
280      * @return The state member.
281      */

282     public String JavaDoc
283     getStateMember()
284     {
285         return state_member_;
286     }
287
288     /**
289      * Set the state member's type.
290      *
291      * @param st The state member's type.
292      */

293     public void
294     setType(PsdlTypeRef type)
295     {
296         type_ = type;
297     }
298
299     /**
300      * Get the state member's type
301      *
302      * @return The state member's type.
303      */

304     public PsdlTypeRef
305     getType()
306     {
307         return type_;
308     }
309
310     /**
311      * Set the storage home.
312      *
313      * @param sh The storage home where the state member must be stored.
314      */

315     public void
316     setStorageHome(StorageHomeDecl sh)
317     {
318         storage_home_ = (StorageHomeDeclImpl)sh;
319     }
320
321     /**
322      * Get the storage home.
323      *
324      * @return The storage home where the state member must be stored.
325      */

326     public StorageHomeDecl
327     getStorageHome()
328     {
329         return storage_home_;
330     }
331 }
332
Popular Tags