KickJava   Java API By Example, From Geeks To Geeks.

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


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 report ASTError exceptions. */
30 import org.objectweb.openccm.ast.api.ASTError;
31
32 /** To access all the AST API. */
33 import org.objectweb.openccm.ast.api.*;
34
35 /**
36  * ScopeImpl is a wrapper class for all IDL definition scopes.
37  *
38  * Inherits from:
39  * - Declaration as IDL scopes are also IDL declarations.
40  *
41  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
42  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
43  *
44  * @version 0.3
45  */

46
47 abstract public class ScopeImpl
48                 extends DeclarationImpl
49                 implements org.objectweb.openccm.ast.api.Scope
50 {
51     // ==================================================================
52
//
53
// Internal state.
54
//
55
// ==================================================================
56

57     /**
58      * To store Declaration names.
59      * It's used to keep the order of the declarations.
60      */

61     protected java.util.List JavaDoc contained_decls_;
62
63     /** To know if the contained objects have been loaded. */
64     protected boolean content_loaded_;
65
66     // ==================================================================
67
//
68
// Constructor.
69
//
70
// ==================================================================
71

72     /**
73      * The constructor with the parent scope.
74      *
75      * @param rep The repository of the declaration.
76      * @param parent The parent scope of the declaration.
77      */

78     protected
79     ScopeImpl(Repository rep,
80               ScopeImpl parent)
81     {
82         // Call the DeclarationImpl constructor.
83
super(rep, parent);
84
85         // Init internal state.
86
contained_decls_ = new java.util.ArrayList JavaDoc();
87         content_loaded_ = false;
88     }
89
90     // ==================================================================
91
//
92
// Internal methods.
93
//
94
// ==================================================================
95

96     /**
97      * Add a contained declaration.
98      *
99      * @param decl The declaration.
100      */

101     protected void
102     addDecl(Declaration decl)
103     {
104         // Test if the declaration is present
105
Declaration current = null;
106         String JavaDoc name = decl.getName();
107         for (int i=0;i<contained_decls_.size();i++)
108         {
109             current = (Declaration)contained_decls_.get(i);
110             if (current.getName().equalsIgnoreCase(name))
111                 return; // We don't have to add this declaration
112
}
113         // Adding the declaration
114
contained_decls_.add(decl);
115     }
116
117     /**
118      * To know if a declaration is a contained declaration.
119      *
120      * @param decl The declaration.
121      *
122      * @return True if the declaration is contained, false otherwise.
123      */

124     protected boolean
125     containsDecl(Declaration decl)
126     {
127         return ( decl.getAbsoluteName().startsWith(getAbsoluteName()+"::") );
128     }
129
130     /**
131      * Remove a contained declaration.
132      */

133     protected void
134     removeDecl(String JavaDoc name)
135     {
136         Declaration decl = null;
137         for (int i=0;i<contained_decls_.size();i++)
138         {
139             decl = (Declaration)contained_decls_.get(i);
140             if (decl.getName().equalsIgnoreCase(name))
141                 contained_decls_.remove(i);
142         }
143     }
144
145     /**
146      * Create a declaration.
147      */

148     protected Declaration
149     createDeclaration(int kind,
150                       java.lang.String JavaDoc name)
151     {
152         Declaration decl = null;
153         switch (kind)
154         {
155             // IDL2 objects
156
case org.omg.CORBA.DefinitionKind._dk_Interface :
157                 decl = startInterface(name);
158                 break;
159             case org.omg.CORBA.DefinitionKind._dk_LocalInterface :
160                 decl = startLocalInterface(name);
161                 break;
162             case org.omg.CORBA.DefinitionKind._dk_AbstractInterface :
163                 decl = startAbstractInterface(name);
164                 break;
165             case org.omg.CORBA.DefinitionKind._dk_Module :
166                 decl = startModule(name);
167                 break;
168             case org.omg.CORBA.DefinitionKind._dk_Struct :
169                 decl = startStruct(name);
170                 break;
171             case org.omg.CORBA.DefinitionKind._dk_Value :
172                 decl = startValue(name);
173                 break;
174             case org.omg.CORBA.DefinitionKind._dk_Union :
175                 decl = startUnion(name);
176                 break;
177             case org.omg.CORBA.DefinitionKind._dk_Exception :
178                 decl = startException(name);
179                 break;
180             case org.omg.CORBA.DefinitionKind._dk_Constant :
181                 decl = startConstant(name);
182                 break;
183             case org.omg.CORBA.DefinitionKind._dk_Enum :
184                 decl = startEnum(name);
185                 break;
186             case org.omg.CORBA.DefinitionKind._dk_Alias :
187                 decl = startAlias(name);
188                 break;
189             case org.omg.CORBA.DefinitionKind._dk_Attribute :
190                 decl = startAttribute(name);
191                 break;
192             case org.omg.CORBA.DefinitionKind._dk_Operation :
193                 decl = startOperation(name);
194                 break;
195             case org.omg.CORBA.DefinitionKind._dk_ValueBox :
196                 decl = startValueBox(name);
197                 break;
198             case org.omg.CORBA.DefinitionKind._dk_Native :
199                 decl = startNative(name);
200                 break;
201             case org.omg.CORBA.DefinitionKind._dk_ValueMember :
202                 decl = startValueMember(name);
203                 break;
204
205             // IDL3 objects
206
case org.omg.CORBA.DefinitionKind._dk_Component :
207                 decl = startComponent(name);
208                 break;
209             case org.omg.CORBA.DefinitionKind._dk_Home :
210                 decl = startHome(name);
211                 break;
212             case org.omg.CORBA.DefinitionKind._dk_Factory :
213                 decl = startFactory(name);
214                 break;
215             case org.omg.CORBA.DefinitionKind._dk_Finder :
216                 decl = startFinder(name);
217                 break;
218             case org.omg.CORBA.DefinitionKind._dk_Emits :
219                 decl = startEmits(name);
220                 break;
221             case org.omg.CORBA.DefinitionKind._dk_Publishes :
222                 decl = startPublishes(name);
223                 break;
224             case org.omg.CORBA.DefinitionKind._dk_Consumes :
225                 decl = startConsumes(name);
226                 break;
227             case org.omg.CORBA.DefinitionKind._dk_Provides :
228                 decl = startProvides(name);
229                 break;
230             case org.omg.CORBA.DefinitionKind._dk_Uses :
231                 decl = startUses(name);
232                 break;
233             case org.omg.CORBA.DefinitionKind._dk_Event :
234                 decl = startEvent(name);
235                 break;
236             default :
237                 // should not happen
238
throw new ASTError("");
239         }
240
241         return decl;
242     }
243
244     /**
245      * To load an Contained object.
246      *
247      * @param contained The Contained object.
248      *
249      * @return The newly created Declaration object.
250      */

251     protected Declaration
252     loadContained(org.omg.CORBA.Contained JavaDoc contained)
253     {
254         DeclarationImpl decl = (DeclarationImpl)
255             createDeclaration(contained.def_kind().value(), contained.name());
256         decl.load(contained);
257         decl.setImported();
258         return decl;
259     }
260
261     /**
262      * To load an Contained object.
263      *
264      * @param contained The Contained object.
265      *
266      * @return The newly created Declaration object.
267      */

268     protected Declaration
269     loadContainedAsMapping(org.omg.CORBA.Contained JavaDoc contained)
270     {
271         DeclarationImpl decl = (DeclarationImpl)
272             createDeclaration(contained.def_kind().value(), contained.name());
273         decl.loadAsMapping(contained);
274         return decl;
275     }
276
277     /**
278      * Start a struct declaration.
279      *
280      * @param name The associated name.
281      *
282      * @return The new created StructDecl.
283      */

284     protected StructDecl
285     startStruct(String JavaDoc name)
286     {
287         StructDecl decl = new StructDeclImpl(getRepository(), this);
288         decl.setName(name);
289         return decl;
290     }
291
292     /**
293      * Start an union declaration.
294      *
295      * @param name The associated name.
296      *
297      * @return The new created UnionDecl.
298      */

299     protected UnionDecl
300     startUnion(String JavaDoc name)
301     {
302         UnionDecl decl = new UnionDeclImpl(getRepository(), this);
303         decl.setName(name);
304         return decl;
305     }
306
307     /**
308      * Start an interface declaration.
309      *
310      * @param name The associated name.
311      *
312      * @return The new created InterfaceDecl.
313      */

314     protected InterfaceDecl
315     startInterface(String JavaDoc name)
316     {
317         InterfaceDecl decl = new InterfaceDeclImpl(getRepository(), this);
318         decl.setName(name);
319         return decl;
320     }
321
322     /**
323      * Start an local interface declaration.
324      *
325      * @param name The associated name.
326      *
327      * @return The new created LocalInterfaceDecl.
328      */

329     protected LocalInterfaceDecl
330     startLocalInterface(String JavaDoc name)
331     {
332         LocalInterfaceDecl decl = new LocalInterfaceDeclImpl(
333                                           getRepository(), this);
334         decl.setName(name);
335         return decl;
336     }
337
338     /**
339      * Start an abstract interface declaration.
340      *
341      * @param name The associated name.
342      *
343      * @return The new created AbstractInterfaceDecl.
344      */

345     protected AbstractInterfaceDecl
346     startAbstractInterface(String JavaDoc name)
347     {
348         AbstractInterfaceDecl decl = new AbstractInterfaceDeclImpl(
349                                              getRepository(), this);
350         decl.setName(name);
351         return decl;
352     }
353
354     /**
355      * Start an value declaration.
356      *
357      * @param name The associated name.
358      *
359      * @return The new created ValueDecl.
360      */

361     protected ValueDecl
362     startValue(String JavaDoc name)
363     {
364         ValueDecl decl = new ValueDeclImpl(getRepository(), this);
365         decl.setName(name);
366         return decl;
367     }
368
369     /**
370      * Start a module declaration.
371      *
372      * @param name The associated name.
373      *
374      * @return The new created ModuleDecl.
375      */

376     protected ModuleDecl
377     startModule(String JavaDoc name)
378     {
379         ModuleDecl module = new ModuleDeclImpl(getRepository(), this);
380         module.setName(name);
381         return module;
382     }
383
384     /**
385      * Start an component declaration.
386      *
387      * @param name The associated name.
388      *
389      * @return The new created ComponentDecl.
390      */

391     protected ComponentDecl
392     startComponent(String JavaDoc name)
393     {
394         ComponentDecl decl = new ComponentDeclImpl(getRepository(), this);
395         decl.setName(name);
396         return decl;
397     }
398
399     /**
400      * Start an event declaration.
401      *
402      * @param name The associated name.
403      *
404      * @return The new created EventDecl.
405      */

406     protected EventDecl
407     startEvent(String JavaDoc name)
408     {
409         EventDecl decl = new EventDeclImpl(getRepository(), this);
410         decl.setName(name);
411         return decl;
412     }
413
414     /**
415      * Find a declaration.
416      *
417      * @param name The name of the searched declaration.
418      *
419      * @return The declaration that was searched
420      * or null if it does not exist.
421      */

422     protected Declaration
423     findInScope(String JavaDoc name)
424     {
425         Declaration decl = null;
426         for (int i=0;i<contained_decls_.size();i++)
427         {
428             decl = (Declaration)contained_decls_.get(i);
429             if (decl.getName().equalsIgnoreCase(name))
430                 return decl;
431         }
432         return null;
433     }
434
435     /**
436      * Find a declaration in the IR3.
437      *
438      * @param name The name of the searched declaration.
439      *
440      * @return The declaration that was searched
441      * or null if it does not exist.
442      */

443     protected Declaration
444     findInIR3(String JavaDoc name)
445     {
446         org.omg.CORBA.Container JavaDoc container = getContainer();
447         if (container == null)
448             return null;
449
450         org.omg.CORBA.Contained JavaDoc contained = container.lookup(name);
451         if (contained == null)
452             return null;
453
454         return loadContained(contained);
455     }
456
457     /**
458      * Obtain its CORBA 3.0 Container reference.
459      *
460      * @return The Container object associated with the scope declaration.
461      */

462     protected org.omg.CORBA.Container JavaDoc
463     getContainer()
464     {
465         // TODO: Why this method?
466
return null;
467     }
468
469     /**
470      * To avoid casts.
471      */

472     protected org.omg.CORBA.ComponentIR.ComponentDef
473     getComponentDef()
474     {
475         // TODO: Why this method?
476
return null;
477     }
478
479     /**
480      * To avoid casts
481      */

482     protected org.omg.CORBA.ExtValueDef
483     getExtValueDef()
484     {
485         // TODO: Why this method?
486
return null;
487     }
488
489     /**
490      * To avoid casts
491      */

492     protected org.omg.CORBA.ComponentIR.HomeDef
493     getHomeDef()
494     {
495         // TODO: Why this method?
496
return null;
497     }
498
499     /**
500      * To avoid casts
501      *
502      * @return The Container object associated with the scope declaration.
503      */

504     protected org.omg.CORBA.ComponentIR.Container
505     getComponentContainer()
506     {
507         // TODO: Why this method?
508
return null;
509     }
510
511     /**
512      * Create an attribute definition.
513      *
514      * @param attribute The attribute declaration.
515      * @param type The IDLType of the attribute.
516      * @param mode The mode of the attribute ie normal or readonly
517      * @param get_exceptions An array containing the exceptions
518      * that accessor operations can raise.
519      * @param set_exceptions An array containing the exceptions
520      * that mutator operations can raise.
521      *
522      * @return The new created AttributeDef.
523      */

524     protected org.omg.CORBA.ExtAttributeDef
525     createExtAttribute(AttributeDecl attribute,
526                        org.omg.CORBA.IDLType JavaDoc type,
527                        org.omg.CORBA.AttributeMode JavaDoc mode,
528                        org.omg.CORBA.ExceptionDef JavaDoc[] get_exceptions,
529                        org.omg.CORBA.ExceptionDef JavaDoc[] set_exceptions)
530     {
531         // TODO: Why this method?
532
return null;
533     }
534
535     /**
536      * Create an operation.
537      *
538      * @param operation The operation declaration.
539      * @param type The IDLType of the object that the operations returns.
540      * @param mode The mode of the operation ie normal or oneway.
541      * @param params An array containing the parameters description.
542      * @param exceptions An array containing the exceptions
543      * that the operation can raise.
544      * @param contexts An array containing the possible context values.
545      *
546      * @return The new created OperationDef.
547      */

548     protected org.omg.CORBA.OperationDef JavaDoc
549     createOperation(OperationDecl operation,
550                     org.omg.CORBA.IDLType JavaDoc type,
551                     org.omg.CORBA.OperationMode JavaDoc mode,
552                     org.omg.CORBA.ParameterDescription JavaDoc[] params,
553                     org.omg.CORBA.ExceptionDef JavaDoc[] exceptions,
554                     String JavaDoc[] contexts)
555     {
556         // TODO: Why this method?
557
return null;
558     }
559
560     // ==================================================================
561
//
562
// Public methods.
563
//
564
// ==================================================================
565

566     // ==================================================================
567
//
568
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
569
//
570
// ==================================================================
571

572     /**
573      * Destroy all the contained declarations of the scope in the IR3.
574      */

575     public void
576     destroy()
577     {
578         Declaration decl = null;
579         for (int i=contained_decls_.size()-1;i>=0;i--)
580         {
581             decl = (Declaration)contained_decls_.get(i);
582             decl.destroy();
583         }
584
585         // destroy it as a declaration if there is no content.
586
if (contained_decls_.size()==0)
587             super.destroy();
588     }
589
590     // ==================================================================
591
//
592
// Methods for OMG IDL org.objectweb.openccm.ast.api.Scope
593
//
594
// ==================================================================
595

596     /**
597      * Start a new IDL FileScope scope.
598      *
599      * @param filename The name of the new FileScope.
600      *
601      * @return The new created FileScope.
602      */

603     public FileScope
604     startFileScope(String JavaDoc filename)
605     {
606         FileScope decl = new FileScopeImpl(getRepository(),
607                                            this,
608                                            contained_decls_);
609         decl.setFileName(filename);
610         return decl;
611     }
612
613     /**
614      * Start a new IDL constant declaration.
615      *
616      * @param name The name of the constant declaration.
617      *
618      * @return The new created ConstantDecl.
619      */

620     public ConstantDecl
621     startConstant(String JavaDoc name)
622     {
623         ConstantDecl decl = new ConstantDeclImpl(getRepository(), this);
624         decl.setName(name);
625         return decl;
626     }
627
628     /**
629      * Declare an IDL struct.
630      * If it doesn't exist then create it.
631      *
632      * @param name The name of the struct declaration.
633      *
634      * @return The previous or new created StructDecl.
635      */

636     public StructDecl
637     declareStruct(String JavaDoc name)
638     {
639         // Find a declaration with the same name.
640
Declaration decl = findInScope(name);
641
642         if ((decl != null) && (decl instanceof StructDecl))
643             return (StructDecl)decl;
644
645         // else create it.
646
return startStruct(name);
647     }
648
649     /**
650      * Declare an IDL union.
651      * If it doesn't exist then create it.
652      *
653      * @param name The name of the union declaration.
654      *
655      * @return The previous or new created UnionDecl.
656      */

657     public UnionDecl
658     declareUnion(String JavaDoc name)
659     {
660         // Find a declaration with the same name.
661
Declaration decl = findInScope(name);
662
663         if ((decl != null) && (decl instanceof UnionDecl))
664             return (UnionDecl)decl;
665
666         // else create it.
667
return startUnion(name);
668     }
669
670     /**
671      * Start a new IDL enum declaration.
672      *
673      * @param name The name of the enum declaration.
674      *
675      * @return The new created EnumDecl.
676      */

677     public EnumDecl
678     startEnum(String JavaDoc name)
679     {
680         EnumDecl decl = new EnumDeclImpl(getRepository(), this);
681         decl.setName(name);
682         return decl;
683     }
684
685     /**
686      * Start a new IDL alias declaration.
687      *
688      * @param name The name of the alias declaration.
689      *
690      * @return The new created AliasDecl.
691      */

692     public AliasDecl
693     startAlias(String JavaDoc name)
694     {
695         AliasDecl decl = new AliasDeclImpl(getRepository(), this);
696         decl.setName(name);
697         return decl;
698     }
699
700     /**
701      * Declare an IDL module.
702      * If it doesn't exist then create it.
703      *
704      * @param name The name of the module declaration.
705      *
706      * @return The previous or new created ModuleDecl.
707      */

708     public ModuleDecl
709     declareModule(String JavaDoc name)
710     {
711       // System.out.println("declareModule " + name + " in " + this);
712

713         // Find a declaration with the same name.
714
Declaration decl = findInScope(name);
715
716         // if it is a module then return it
717
// because this is a module reopening.
718
if(decl != null && decl instanceof ModuleDecl)
719         {
720             return (ModuleDecl)decl;
721         }
722
723         // else create it.
724
ModuleDeclImpl module = (ModuleDeclImpl)startModule(name);
725
726         // Search its ModuleDef into the IR3.
727
try
728         {
729             org.omg.CORBA.Contained JavaDoc contained = getContainer().lookup(name);
730             if (contained!=null)
731                 module.load(contained);
732         }
733         catch(org.omg.CORBA.SystemException JavaDoc exc)
734         {
735             // TODO: Do nothing if narrow fails?
736
}
737
738         return module;
739     }
740
741     /**
742      * Declare an IDL interface.
743      * If it doesn't exist then create it.
744      *
745      * @param name The name of the interface declaration.
746      *
747      * @return The previous or new created InterfaceDecl.
748      */

749     public InterfaceDecl
750     declareInterface(String JavaDoc name)
751     {
752         // Find a declaration with the same name.
753
Declaration decl = findInScope(name);
754
755         if (decl != null)
756         {
757             // if it is an interface then return it.
758
if (decl.getClass() == InterfaceDeclImpl.class)
759                 return (InterfaceDecl)decl;
760
761             // if it is an abstract interface then raise an error.
762
if (decl instanceof AbstractInterfaceDeclImpl)
763                 throw new ASTError("interface `" + name +
764                           "' does not match forward abstract declaration");
765
766             // if it is a local interface then raise an error.
767
if (decl instanceof LocalInterfaceDeclImpl)
768                 throw new ASTError("interface `" + name +
769                           "' does not match forward local declaration");
770         }
771
772         // else create it.
773
return startInterface(name);
774     }
775
776     /**
777      * Declare an IDL local interface.
778      * If it doesn't exist then create it.
779      *
780      * @param name The name of the local interface declaration.
781      *
782      * @return The previous or new created LocalInterfaceDecl.
783      */

784     public LocalInterfaceDecl
785     declareLocalInterface(String JavaDoc name)
786     {
787         // Find a declaration with the same name.
788
Declaration decl = findInScope(name);
789
790         if (decl != null)
791         {
792             // if it is a local interface then return it.
793
if (decl instanceof LocalInterfaceDeclImpl)
794                 return (LocalInterfaceDecl)decl;
795
796             // if it is an abstract interface then raise an error.
797
if (decl instanceof AbstractInterfaceDeclImpl)
798                 throw new ASTError("interface `" + name +
799                           "' does not match forward abstract declaration");
800
801             // if it is an interface then raise an error.
802
if (decl instanceof InterfaceDeclImpl)
803                 throw new ASTError("interface `" + name +
804                           "' does not match forward declaration");
805         }
806
807         // else create it.
808
return startLocalInterface(name);
809     }
810
811     /**
812      * Declare an IDL abstract interface.
813      * If it doesn't exist then create it.
814      *
815      * @param name The name of the abstract interface declaration.
816      *
817      * @return The previous or new created AbstractInterfaceDecl.
818      */

819     public AbstractInterfaceDecl
820     declareAbstractInterface(String JavaDoc name)
821     {
822         // Find a declaration with the same name.
823
Declaration decl = findInScope(name);
824
825         if (decl != null)
826         {
827             // if it is an abstract interface then return it.
828
if (decl instanceof AbstractInterfaceDeclImpl)
829                 return (AbstractInterfaceDecl)decl;
830
831             // if it is a local interface then raise an error.
832
if (decl instanceof LocalInterfaceDeclImpl)
833                 throw new ASTError("interface `" + name +
834                           "' does not match forward local declaration");
835
836             // if it is an interface then raise an error.
837
if (decl instanceof InterfaceDeclImpl)
838                 throw new ASTError("interface `" + name +
839                            "' does not match forward declaration");
840         }
841
842         // else create it.
843
return startAbstractInterface(name);
844     }
845
846    /**
847     * Declare an IDL value type.
848     * If it doesn't exist then create it.
849     *
850     * @param name The name of the value type declaration.
851     *
852     * @return The previous or new created ValueDecl.
853     */

854     public ValueDecl
855     declareValue(String JavaDoc name)
856     {
857         // Find a declaration with the same name.
858
Declaration decl = findInScope(name);
859
860         if ((decl != null) && (decl instanceof ValueDecl))
861             return (ValueDecl)decl;
862
863         // else create it.
864
return startValue(name);
865     }
866
867     /**
868      * Start a new IDL initializer declaration.
869      *
870      * @param name The name of the initializer declaration.
871      *
872      * @return The new created Initializer.
873      */

874     public Initializer
875     startInitializer(String JavaDoc name)
876     {
877         Initializer init = new InitializerImpl();
878         init.setName(name);
879         return init;
880     }
881
882     /**
883      * Start a new IDL value member declaration.
884      *
885      * @param name The name of the value member declaration.
886      *
887      * @return The new created ValueMemberDecl.
888      */

889     public ValueMemberDecl
890     startValueMember(String JavaDoc name)
891     {
892         ValueMemberDecl decl = new ValueMemberDeclImpl(getRepository(), this);
893         decl.setName(name);
894         return decl;
895     }
896
897     /**
898      * Start a new IDL value box declaration.
899      *
900      * @param name The name of the value box declaration.
901      *
902      * @return The new created ValueBoxDecl.
903      */

904     public ValueBoxDecl
905     startValueBox(String JavaDoc name)
906     {
907         ValueBoxDecl decl = new ValueBoxDeclImpl(getRepository(), this);
908         decl.setName(name);
909         return decl;
910     }
911
912     /**
913      * Start a new IDL exception declaration.
914      *
915      * @param name The name of the exception declaration.
916      *
917      * @return The new created ExceptionDecl.
918      */

919     public ExceptionDecl
920     startException(String JavaDoc name)
921     {
922         ExceptionDecl decl = new ExceptionDeclImpl(getRepository(), this);
923         decl.setName(name);
924         return decl;
925     }
926
927     /**
928      * Start a new IDL native declaration.
929      *
930      * @param name The name of the native declaration.
931      *
932      * @return The new created NativeDecl.
933      */

934     public NativeDecl
935     startNative(String JavaDoc name)
936     {
937         NativeDecl decl = new NativeDeclImpl(getRepository(), this);
938         decl.setName(name);
939         return decl;
940     }
941
942     /**
943      * Start a new IDL attribute declaration.
944      *
945      * @param name The name of the attribute declaration.
946      *
947      * @return The new created AttributeDecl.
948      */

949     public AttributeDecl
950     startAttribute(String JavaDoc name)
951     {
952         AttributeDecl decl = new AttributeDeclImpl(getRepository(), this);
953         decl.setName(name);
954         return decl;
955     }
956
957     /**
958      * Start a new IDL operation declaration.
959      *
960      * @param name The name of the operation declaration.
961      *
962      * @return The new created OperationDecl.
963      */

964     public OperationDecl
965     startOperation(String JavaDoc name)
966     {
967         OperationDecl decl = new OperationDeclImpl(getRepository(), this);
968         decl.setName(name);
969         return decl;
970     }
971
972     /**
973      * Declare an IDL event type.
974      * If it not exists then create it.
975      *
976      * @param name The name of the event type declaration.
977      *
978      * @return The previous or new created EventDecl.
979      */

980     public EventDecl
981     declareEvent(String JavaDoc name)
982     {
983         // Find a declaration with the same name.
984
Declaration decl = findInScope(name);
985 <