KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > IDL3 > Repository


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@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): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.IDL3;
28
29 /**
30  * This class manages the Repository scope.
31  *
32  * @author <a=href="Philippe.Merle@lifl.fr">Philippe Merle</a>
33  * <a=href="Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
34  *
35  * @version 0.3
36  */

37
38 public class Repository
39        extends ScopeImpl
40        implements PrimitiveTypeFactory
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

48     /**
49      ** Reference to the PrimitiveDef for the null type.
50      **/

51     private TypeRefImpl null_ = null;
52
53     /**
54      ** Reference to the PrimitiveDef for the void type.
55      **/

56     private TypeRefImpl void_ = null;
57
58     /**
59      ** Reference to the PrimitiveDef for the short type.
60      **/

61     private TypeRefImpl short_ = null;
62
63     /**
64      ** Reference to the PrimitiveDef for the long type.
65      **/

66     private TypeRefImpl long_ = null;
67
68     /**
69      ** Reference to the PrimitiveDef for the unsigned short type.
70      **/

71     private TypeRefImpl unsigned_short_ = null;
72
73     /**
74      ** Reference to the PrimitiveDef for the unsigned long type.
75      **/

76     private TypeRefImpl unsigned_long_ = null;
77
78     /**
79      ** Reference to the PrimitiveDef for the float type.
80      **/

81     private TypeRefImpl float_ = null;
82
83     /**
84      ** Reference to the PrimitiveDef for the double type.
85      **/

86     private TypeRefImpl double_ = null;
87
88     /**
89      ** Reference to the PrimitiveDef for the boolean type.
90      **/

91     private TypeRefImpl boolean_ = null;
92
93     /**
94      ** Reference to the PrimitiveDef for the char type.
95      **/

96     private TypeRefImpl char_ = null;
97
98     /**
99      ** Reference to the PrimitiveDef for the octet type.
100      **/

101     private TypeRefImpl octet_ = null;
102
103     /**
104      ** Reference to the PrimitiveDef for the any type.
105      **/

106     private TypeRefImpl any_ = null;
107
108     /**
109      ** Reference to the PrimitiveDef for the TypeCode type.
110      **/

111     private TypeRefImpl TypeCode_ = null;
112
113     /**
114      ** Reference to the PrimitiveDef for the Principal type.
115      **/

116     private TypeRefImpl Principal_ = null;
117
118     /**
119      ** Reference to the PrimitiveDef for the string type.
120      **/

121     private TypeRefImpl string_ = null;
122
123     /**
124      ** Reference to the PrimitiveDef for the Object type.
125      **/

126     private TypeRefImpl object_ = null;
127
128     /**
129      ** Reference to the PrimitiveDef for the long long type.
130      **/

131     private TypeRefImpl long_long_ = null;
132
133     /**
134      ** Reference to the PrimitiveDef for the unsigned long long type.
135      **/

136     private TypeRefImpl unsigned_long_long_ = null;
137
138     /**
139      ** Reference to the PrimitiveDef for the long double type.
140      **/

141     private TypeRefImpl long_double_ = null;
142
143     /**
144      ** Reference to the PrimitiveDef for the wchar type.
145      **/

146     private TypeRefImpl wchar_ = null;
147
148     /**
149      ** Reference to the PrimitiveDef for the wstring type.
150      **/

151     private TypeRefImpl wstring_ = null;
152
153     /**
154      ** Reference to the PrimitiveDef for the value base type.
155      **/

156     private TypeRefImpl value_base_ = null;
157
158     /**
159      **
160      **/

161     private org.objectweb.ccm.util.Table declarations_;
162
163     /**
164      **
165      **/

166     private org.objectweb.ccm.util.Table mapped_declarations_;
167
168     /**
169      ** Reference to the CORBA 3.0 Repository.
170      **/

171     private org.omg.CORBA.Repository JavaDoc repository_;
172
173     /**
174      **
175      **/

176     private org.objectweb.openccm.ir3.api.ComponentRepository openccm_repository_;
177
178     // ==================================================================
179
//
180
// Constructor.
181
//
182
// ==================================================================
183

184     /**
185      ** The constructor with the parent scope.
186      **
187      ** @param repository The CORBA Repository that should be used.
188      **/

189     public
190     Repository(org.omg.CORBA.Repository JavaDoc repository)
191     {
192         // Call the ScopeImpl constructor.
193
super(null, null);
194
195         // Init internal state.
196
the_declaration_kind_ = DeclarationKind._dk_repository;
197         repository_ = repository;
198         openccm_repository_ = org.objectweb.openccm.ir3.api.ComponentRepositoryHelper.narrow(repository);
199         declarations_ = new org.objectweb.ccm.util.Table();
200         mapped_declarations_ = new org.objectweb.ccm.util.Table();
201         the_repository_ = this;
202     }
203
204     // ==================================================================
205
//
206
// Internal methods.
207
//
208
// ==================================================================
209

210     /**
211      **
212      **/

213     protected void
214     addDeclInRep(String JavaDoc rep_id, Declaration decl)
215     {
216         declarations_.put(rep_id, decl);
217     }
218
219     /**
220      **
221      **/

222     protected void
223     removeDeclFromRep(String JavaDoc rep_id)
224     {
225         declarations_.remove(rep_id);
226     }
227
228     /**
229      **
230      **/

231     protected void
232     addMappedDeclInRep(String JavaDoc rep_id, Declaration decl)
233     {
234         mapped_declarations_.put(rep_id, decl);
235     }
236
237     /**
238      **
239      **/

240     protected void
241     removeMappedDeclFromRep(String JavaDoc rep_id)
242     {
243         mapped_declarations_.remove(rep_id);
244     }
245
246     /**
247      ** Obtain a newly created Declaration of a IR3 Contained.
248      ** Note: only the following Contained can be loaded :
249      ** dk_Module, dk_Interface, dk_LocalInterface, dk_AbstractInterface,
250      ** dk_Value, dk_Struct, dk_Union, dk_Exception, dk_Component, dk_Home,
251      ** dk_Event.
252      **
253      ** @param contained The Contained to use.
254      ** @param scope The Scope in which the Contained will be loaded.
255      ** @return The associated Declaration or null if it not exists or if
256      ** the DefinitionKind is not valid.
257      **/

258     protected Declaration
259     loadContained(Scope scope, org.omg.CORBA.Contained JavaDoc contained)
260     {
261         ScopeImpl si = (ScopeImpl)scope;
262         int kind = contained.def_kind().value();
263
264         if ((kind!=org.omg.CORBA.DefinitionKind._dk_Module) &&
265             (kind!=org.omg.CORBA.DefinitionKind._dk_Interface) &&
266             (kind!=org.omg.CORBA.DefinitionKind._dk_LocalInterface) &&
267             (kind!=org.omg.CORBA.DefinitionKind._dk_AbstractInterface) &&
268             (kind!=org.omg.CORBA.DefinitionKind._dk_Value) &&
269             (kind!=org.omg.CORBA.DefinitionKind._dk_Struct) &&
270             (kind!=org.omg.CORBA.DefinitionKind._dk_Union) &&
271             (kind!=org.omg.CORBA.DefinitionKind._dk_Exception) &&
272             (kind!=org.omg.CORBA.DefinitionKind._dk_Component) &&
273             (kind!=org.omg.CORBA.DefinitionKind._dk_Home) &&
274             (kind!=org.omg.CORBA.DefinitionKind._dk_Event))
275             return null;
276
277         return si.loadContained(contained);
278     }
279
280     /**
281      **
282      **/

283     protected TypeRef
284     getAsTypeRef(org.omg.CORBA.IDLType JavaDoc type,
285                  boolean is_mapped)
286     {
287         org.omg.CORBA.TypeCode JavaDoc tc = type.type();
288         try
289         {
290             switch(tc.kind().value())
291             {
292             case org.omg.CORBA.TCKind._tk_null:
293                 return type_null();
294             case org.omg.CORBA.TCKind._tk_void:
295                 return type_void();
296             case org.omg.CORBA.TCKind._tk_short:
297                 return type_short();
298             case org.omg.CORBA.TCKind._tk_long:
299                 return type_long();
300             case org.omg.CORBA.TCKind._tk_ushort:
301                 return type_unsigned_short();
302             case org.omg.CORBA.TCKind._tk_ulong:
303                 return type_unsigned_long();
304             case org.omg.CORBA.TCKind._tk_float:
305                 return type_float();
306             case org.omg.CORBA.TCKind._tk_double:
307                 return type_double();
308             case org.omg.CORBA.TCKind._tk_boolean:
309                 return type_boolean();
310             case org.omg.CORBA.TCKind._tk_char:
311                 return type_char();
312             case org.omg.CORBA.TCKind._tk_octet:
313                 return type_octet();
314             case org.omg.CORBA.TCKind._tk_any:
315                 return type_any();
316             case org.omg.CORBA.TCKind._tk_TypeCode:
317                 return type_TypeCode();
318             case org.omg.CORBA.TCKind._tk_Principal:
319                 return type_Principal();
320             case org.omg.CORBA.TCKind._tk_longlong:
321                 return type_long_long();
322             case org.omg.CORBA.TCKind._tk_ulonglong:
323                 return type_unsigned_long_long();
324             case org.omg.CORBA.TCKind._tk_longdouble:
325                 return type_long_double();
326             case org.omg.CORBA.TCKind._tk_wchar:
327                 return type_wchar();
328
329             case org.omg.CORBA.TCKind._tk_string:
330                 TypeRefImpl tr = new TypeRefImpl(type, TypeKind._tk_string);
331                 tr.setLength(tc.length());
332                 return tr;
333             case org.omg.CORBA.TCKind._tk_sequence:
334                 tr = new TypeRefImpl(type, TypeKind._tk_sequence);
335                 tr.setLength(tc.length());
336                 org.omg.CORBA.SequenceDef JavaDoc seq = org.omg.CORBA.SequenceDefHelper.narrow(type);
337                 tr.setContentType(getAsTypeRef(seq.element_type_def()));
338                 return tr;
339             case org.omg.CORBA.TCKind._tk_array:
340                 tr = new TypeRefImpl(type, TypeKind._tk_array);
341                 tr.setLength(tc.length());
342                 org.omg.CORBA.ArrayDef JavaDoc arr = org.omg.CORBA.ArrayDefHelper.narrow(type);
343                 tr.setContentType(getAsTypeRef(arr.element_type_def()));
344                 return tr;
345             case org.omg.CORBA.TCKind._tk_wstring:
346                 tr = new TypeRefImpl(type, TypeKind._tk_wstring);
347                 tr.setLength(tc.length());
348                 return tr;
349             case org.omg.CORBA.TCKind._tk_fixed:
350                 tr = new TypeRefImpl(type, TypeKind._tk_fixed);
351                 tr.setDigits(tc.fixed_digits());
352                 tr.setScale(tc.fixed_scale());
353                 return tr;
354
355             case org.omg.CORBA.TCKind._tk_objref:
356               if (tc.id().equals("IDL:omg.org/CORBA/Object:1.0"))
357                 return type_Object();
358
359             case org.omg.CORBA.TCKind._tk_struct:
360             case org.omg.CORBA.TCKind._tk_union:
361             case org.omg.CORBA.TCKind._tk_enum:
362             case org.omg.CORBA.TCKind._tk_alias:
363             case org.omg.CORBA.TCKind._tk_value:
364             case org.omg.CORBA.TCKind._tk_value_box:
365             case org.omg.CORBA.TCKind._tk_native:
366             case org.omg.CORBA.TCKind._tk_abstract_interface:
367 /*
368  * not defined !
369             case org.omg.CORBA.TCKind._tk_local_interface:
370             case org.omg.CORBA.TCKind_.tk_event:
371             case org.omg.CORBA.TCKind._tk_home:
372             case org.omg.CORBA.TCKind._tk_component:
373  */

374                 if (is_mapped)
375                     return (TypeRef)lookupMappedId(tc.id());
376                 else
377                     return (TypeRef)lookupId(tc.id());
378
379             //
380
// PB : an exception is not an IDLType
381
// so it can't have an associated TypeRef
382
//
383
case org.omg.CORBA.TCKind._tk_except:
384             default:
385                 return type_null();
386             }
387         }
388         catch(org.omg.CORBA.TypeCodePackage.BadKind JavaDoc ex)
389         {
390             throw new Error JavaDoc("Should not have happened !");
391         }
392     }
393
394     // ==================================================================
395
//
396
// Public methods.
397
//
398
// ==================================================================
399

400     /**
401      **
402      **/

403     public void
404     useIDL3Repository()
405     {
406         // if we're not using the OpenCCM repository, mappings are not available.
407
if (openccm_repository_!=null)
408             openccm_repository_.as_IDL3_repository();
409     }
410
411     /**
412      **
413      **/

414     public void
415     useIDL2Repository()
416     {
417         // if we're not using the OpenCCM repository, mappings are not available.
418
if (openccm_repository_!=null)
419             openccm_repository_.as_IDL2_repository();
420     }
421
422     // ==================================================================
423
//
424
// Public methods for IRObject loading (for import statement).
425
//
426
// ==================================================================
427

428     /**
429      ** Loads a IR3 Contained in a IDL3 Scope.
430      **
431      ** @param scope The Scope in which the Contained will be loaded.
432      ** @param name The name of the Contained.
433      **
434      ** @return The newly created Declaration associated with the Contained.
435      **/

436     public Declaration
437     load(Scope scope, String JavaDoc name)
438     {
439         org.omg.CORBA.Contained JavaDoc decl = repository_.lookup(name);
440         if (decl==null)
441             return null;
442
443         return loadContained(scope, decl);
444     }
445
446     /**
447      ** Loads a IR3 Contained in a IDL3 Scope.
448      **
449      ** @param scope The Scope in which the Contained will be loaded.
450      ** @param id The RepositoryId of the Contained.
451      **
452      ** @return The newly created Declaration associated with the Contained.
453      **/

454     public Declaration
455     loadId(Scope scope, String JavaDoc id)
456     {
457         org.omg.CORBA.Contained JavaDoc decl = repository_.lookup_id(id);
458         if (decl==null)
459             return null;
460
461         return loadContained(scope, decl);
462     }
463
464     /**
465      **
466      **/

467     public Declaration
468     loadMapping(Scope scope, String JavaDoc rep_id)
469     {
470         // if we're not using the OpenCCM repository, mappings are not available.
471
if (openccm_repository_==null)
472             return null;
473
474         // use the OpenCCM repository as an IDL2 repository to extract the mapping !!!
475
openccm_repository_.as_IDL2_repository();
476
477         // check if it was not already loaded.
478
Declaration result = (Declaration)mapped_declarations_.get(rep_id);
479         if (result!=null)
480             return result;
481
482         org.omg.CORBA.Contained JavaDoc decl = openccm_repository_.lookup_mapped_id(rep_id);
483         if (decl==null)
484             return null;
485
486         // load the contained.
487
ScopeImpl si = (ScopeImpl)scope;
488         result = si.loadContainedAsMapping(decl);
489
490         // get back to an IDL3 repository.
491
openccm_repository_.as_IDL3_repository();
492
493         return result;
494     }
495
496     // ==================================================================
497
//
498
// Public methods for IR3 infos extraction.
499
//
500
// ==================================================================
501

502     /**
503      ** To obtain the Declaration object with it's absolute name.
504      **
505      ** @param abs_name The absolute name of the searched Declaration object.
506      **
507      ** @return The Declaration object or null if the absolute
508      ** name was not found.
509      **/

510     public Declaration
511     lookup(String JavaDoc scoped_name)
512     {
513         if (scoped_name.startsWith("::"))
514             return super.lookup(scoped_name.substring(2));
515         else
516             return super.lookup(scoped_name);
517     }
518
519     /**
520      **
521      **/

522     public Declaration
523     lookupMappedId(String JavaDoc rep_id)
524     {
525         Object JavaDoc obj = mapped_declarations_.get(rep_id);
526         if (obj!=null)
527             return (Declaration)obj;
528
529         // if not found then load it from the IR3
530
org.omg.CORBA.Contained JavaDoc decl = openccm_repository_.lookup_mapped_id(rep_id);
531
532         // if not found, it's a "normal" id
533
if (decl==null)
534             return lookupId(rep_id);
535
536         // else load it as a mapped id
537
org.omg.CORBA.Contained JavaDoc decl2 = null;
538         String JavaDoc abs_name = decl.absolute_name();
539         String JavaDoc name = "";
540         if (abs_name.startsWith("::"))
541             abs_name = abs_name.substring(2, abs_name.length());
542
543         int idx = 0;
544         ScopeImpl scope = null;
545         obj = this;
546         while (true)
547         {
548             scope = (ScopeImpl)obj;
549             idx = abs_name.indexOf(':');
550             if (idx==-1)
551                 return scope.loadContainedAsMapping(decl);
552             name = abs_name.substring(0, idx);
553             abs_name = abs_name.substring(idx+2, abs_name.length());
554             obj = scope.findInScope(name);
555             if (obj==null)
556             {
557                 decl2 = scope.getContainer().lookup(name);
558                 obj = scope.loadContainedAsMapping(decl2);
559             }
560         }
561     }
562
563     /**
564      **
565      **/

566     public Declaration
567     lookupId(String JavaDoc rep_id)
568     {
569         Object JavaDoc obj = declarations_.get(rep_id);
570
571         if (obj!=null)
572             return (Declaration)obj;
573
574         // if not found then load it from the IR3
575
org.omg.CORBA.Contained JavaDoc decl = repository_.lookup_id(rep_id);
576         org.omg.CORBA.Contained JavaDoc decl2 = null;
577         String JavaDoc abs_name = decl.absolute_name();
578         String JavaDoc name = "";
579         if (abs_name.startsWith("::"))
580             abs_name = abs_name.substring(2, abs_name.length());
581
582         int idx = 0;
583         ScopeImpl scope = null;
584         obj = this;
585         while (true)
586         {
587             scope = (ScopeImpl)obj;
588             idx = abs_name.indexOf(':');
589             if (idx==-1)
590                 return scope.loadContained(decl);
591             name = abs_name.substring(0, idx);
592             abs_name = abs_name.substring(idx+2, abs_name.length());
593             obj = scope.findInScope(name);
594             if (obj==null)
595             {
596                 decl2 = scope.getContainer().lookup(name);
597                 obj = scope.loadContained(decl2);
598             }
599         }
600     }
601
602     // ==================================================================
603
//
604
// Methods for the PrimitiveTypeFactory interface.
605
//
606
// ==================================================================
607

608     /**
609      **
610      **/

611     public TypeRef
612     getAsMappedTypeRef(org.omg.CORBA.IDLType JavaDoc type)
613     {
614         return getAsTypeRef(type, true);
615     }
616
617     /**
618      **
619      **/

620     public TypeRef
621     getAsTypeRef(org.omg.CORBA.IDLType JavaDoc type)
622     {
623         return getAsTypeRef(type, false);
624     }
625
626     /**
627      ** Obtain the null type.
628      **
629      ** @return The new created TypeRef.
630      **/

631     public TypeRef
632     type_null()
633     {
634        if (null_ == null)
635        {
636            null_ = new TypeRefImpl(
637               repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_null),
638               TypeKind._tk_null);
639        }
640        return null_;
641     }
642
643     /**
644      ** Obtain the void type.
645      **
646      ** @return The new created TypeRef.
647      **/

648     public TypeRef
649     type_void()
650     {
651        if (void_ == null)
652        {
653        void_ = new TypeRefImpl(
654                repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_void),
655                TypeKind._tk_void);
656        }
657        return void_;
658     }
659
660     /**
661      ** Obtain the short type.
662      **
663      ** @return The new created TypeRef.
664      **/

665     public TypeRef
666     type_short()
667     {
668        if (short_ == null)
669        {
670        short_ = new TypeRefImpl(
671               repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_short),
672               TypeKind._tk_short);
673        }
674        return short_;
675     }
676
677     /**
678      ** Obtain the long type.
679      **
680      ** @return The new created TypeRef.
681      **/

682     public TypeRef
683     type_long()
684     {
685        if (long_ == null)
686        {
687        long_ = new TypeRefImpl(
688                repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_long),
689                TypeKind._tk_long);
690        }
691        return long_;
692     }
693
694     /**
695      ** Obtain the unsigned short type.
696      **
697      ** @return The new created TypeRef.
698      **/

699     public TypeRef
700     type_unsigned_short()
701     {
702        if (unsigned_short_ == null)
703        {
704        unsigned_short_ = new TypeRefImpl(
705              repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_ushort),
706              TypeKind._tk_ushort);
707        }
708        return unsigned_short_;
709     }
710
711     /**
712      ** Obtain the unsigned long type.
713      **
714      ** @return The new created TypeRef.
715      **/

716     public TypeRef
717     type_unsigned_long()
718     {
719        if (unsigned_long_ == null)
720        {
721        unsigned_long_ = new TypeRefImpl(
722              repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_ulong),
723              TypeKind._tk_ulong);
724        }
725        return unsigned_long_;
726     }
727
728     /**
729      ** Obtain the float type.
730      **
731      ** @return The new created TypeRef.
732      **/

733     public TypeRef
734     type_float()
735     {
736        if (float_ == null)
737        {
738        float_ = new TypeRefImpl(
739              repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_float),
740              TypeKind._tk_float);
741        }
742        return float_;
743     }
744
745     /**
746      ** Obtain the double type.
747      **
748      ** @return The new created TypeRef.
749      **/

750     public TypeRef
751     type_double()
752     {
753        if (double_ == null)
754        {
755        double_ = new TypeRefImpl(
756              repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_double),
757              TypeKind._tk_double);
758        }
759        return double_;
760     }
761
762     /**
763      ** Obtain the boolean type.
764      **
765      ** @return The new created TypeRef.
766      **/

767     public TypeRef
768     type_boolean()
769     {
770        if (boolean_ == null)
771        {
772        boolean_ = new TypeRefImpl(
773            repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_boolean),
774            TypeKind._tk_boolean);
775        }
776        return boolean_;
777     }
778
779     /**
780      ** Obtain the char type.
781      **
782      ** @return The new created TypeRef.
783      **/

784     public TypeRef
785     type_char()
786     {
787        if (char_ == null)
788        {
789        char_ = new TypeRefImpl(
790              repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_char),
791              TypeKind._tk_char);
792        }
793        return char_;
794     }
795
796     /**
797      ** Obtain the octet type.
798      **
799      ** @return The new created TypeRef.
800      **/

801     public TypeRef
802     type_octet()
803     {
804        if (octet_ == null)
805        {
806        octet_ = new TypeRefImpl(
807              repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_octet),
808              TypeKind._tk_octet);
809        }
810        return octet_;
811     }
812
813     /**
814      ** Obtain the any type.
815      **
816      ** @return The new created TypeRef.
817      **/

818     public TypeRef
819     type_any()
820     {
821        if (any_ == null)
822        {
823        any_ = new TypeRefImpl(
824            repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_any),
825            TypeKind._tk_any);
826        }
827        return any_;
828     }
829
830     /**
831      ** Obtain the TypeCode type.
832      **
833      ** @return The new created TypeRef.
834      **/

835     public TypeRef
836     type_TypeCode()
837     {
838        if (TypeCode_ == null)
839        {
840        TypeCode_ =new TypeRefImpl(
841            repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_TypeCode),
842            TypeKind._tk_TypeCode);
843        }
844        return TypeCode_;
845     }
846
847     /**
848      ** Obtain the Principal type.
849      **
850      ** @return The new created TypeRef.
851      **/

852     public TypeRef
853     type_Principal()
854     {
855        if (Principal_ == null)
856        {
857        Principal_ =new TypeRefImpl(
858        repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_Principal),
859        TypeKind._tk_Principal);
860        }
861        return Principal_;
862     }
863
864     /**
865      ** Obtain the string type.
866      **
867      ** @return The new created TypeRef.
868      **/

869     public TypeRef
870     type_string()
871     {
872        if (string_ == null)
873        {
874        string_ = new TypeRefImpl(
875              repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_string),
876              TypeKind._tk_string);
877        }
878        return string_;
879     }
880
881     /**
882      ** Obtain the Object type.
883      **
884      ** @return The new created TypeRef.
885      **/

886     public TypeRef
887     type_Object()
888     {
889        if (object_ == null)
890        {
891        object_ = new TypeRefImpl(
892              repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_objref),
893              TypeKind._tk_objref);
894        }
895        return object_;
896     }
897
898     /**
899      ** Obtain the long long type.
900      **
901      ** @return The new created TypeRef.
902      **/

903     public TypeRef
904     type_long_long()
905     {
906        if (long_long_ == null)
907        {
908        long_long_ = new TypeRefImpl(
909                repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_longlong),
910                TypeKind._tk_longlong);
911        }
912        return long_long_;
913     }
914
915     /**
916      ** Obtain the unsigned long long type.
917      **
918      ** @return The new created TypeRef.
919      **/

920     public TypeRef
921     type_unsigned_long_long()
922     {
923        if (unsigned_long_long_ == null)
924        {
925        unsigned_long_long_ = new TypeRefImpl(
926              repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_ulonglong),
927              TypeKind._tk_ulonglong);
928        }
929        return unsigned_long_long_;
930     }
931
932     /**
933      ** Obtain the long double type.
934      **
935      ** @return The new created TypeRef.
936      **/

937     public TypeRef
938     type_long_double()
939     {
940        if (long_double_ == null)
941        {
942        long_double_ = new TypeRefImpl(
943              repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_longdouble),
944              TypeKind._tk_longdouble);
945        }
946        return long_double_;
947     }
948
949     /**
950      ** Obtain the wchar type.
951      **
952      ** @return The new created TypeRef.
953      **/

954     public TypeRef
955     type_wchar()
956     {
957        if (wchar_ == null)
958        {
959        wchar_ = new TypeRefImpl(
960              repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_wchar),
961              TypeKind._tk_wchar);
962        }
963        return wchar_;
964     }
965
966     /**
967      ** Obtain the wstring type.
968      **
969      ** @return The new created TypeRef.
970      **/

971     public TypeRef
972     type_wstring()
973     {
974        if (wstring_ == null)
975        {
976        wstring_ = new TypeRefImpl(
977             repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_wstring),
978             TypeKind._tk_wstring);
979        }
980        return wstring_;
981     }
982
983     /**
984      ** Obtain the value base type.
985      **
986      ** @return The new created TypeRef.
987      **/

988     public TypeRef
989     type_value_base()
990     {
991        if (value_base_ == null)
992        {
993        value_base_ = new TypeRefImpl(
994              repository_.get_primitive(org.omg.CORBA.PrimitiveKind.pk_value_base),
995              //
996
// PB : no TypeCode is associated with value base
997
//
998
TypeKind._tk_null);
999        }
1000       return value_base_;
1001    }
1002
1003    /**
1004     ** Create an anonymous string<bound> type.
1005     **
1006     ** @param bound The length of the string.
1007     **
1008     ** @return The new created TypeRef.
1009     **/

1010    public TypeRef
1011    createString(int bound)
1012    {
1013        // Create a StringDef into the IFR.
1014
org.omg.CORBA.StringDef JavaDoc stringDef = repository_.create_string(bound);
1015        TypeRefImpl tr = new TypeRefImpl(stringDef, TypeKind._tk_string);
1016        tr.setLength(bound);
1017        return tr;
1018    }
1019
1020    /**
1021     ** Create an anonymous wstring<bound> type.
1022     **
1023     ** @param bound The length of the wstring.
1024     **
1025     ** @return The new created TypeRef.
1026     **/

1027    public TypeRef
1028    createWstring(int bound)
1029    {
1030        // Create a WstringDef into the IFR.
1031
org.omg.CORBA.WstringDef JavaDoc wstringDef = repository_.create_wstring(bound);
1032        TypeRefImpl tr = new TypeRefImpl(wstringDef, TypeKind._tk_wstring);
1033        tr.setLength(bound);
1034        return tr;
1035    }
1036
1037    /**
1038     ** Create an anonymous sequence<bound,element_type> type.
1039     **
1040     ** @param bound The length of the sequence.
1041     ** @param element_type The TypeRef of the elements.
1042     **
1043     ** @return The new created TypeRef.
1044     **/

1045    public TypeRef
1046    createSequence(int bound,
1047                   TypeRef element_type)
1048    {
1049        if(element_type == null)
1050            return null;
1051
1052        // Create a SequenceDef into the IFR.
1053
org.omg.CORBA.SequenceDef JavaDoc sequenceDef =
1054            repository_.create_sequence(bound, element_type.getIDLType());
1055        TypeRefImpl tr = new TypeRefImpl(sequenceDef, TypeKind._tk_sequence);
1056        tr.setLength(bound);
1057        tr.setContentType(element_type);
1058        return tr;
1059    }
1060
1061    /**
1062     ** Create an anonymous array type, i.e. element_type[length].
1063     **
1064     ** @param length The length of the array.
1065     ** @param element_type The TypeRef of the elements.
1066     **
1067     ** @return The new created TypeRef.
1068     **/

1069    public TypeRef
1070    createArray(int length,
1071                TypeRef element_type)
1072    {
1073        if(element_type == null)
1074            return null;
1075
1076        // Create an ArrayDef into the IFR.
1077
org.omg.CORBA.ArrayDef JavaDoc arrayDef =
1078             repository_.create_array(length, element_type.getIDLType());
1079        TypeRefImpl tr = new TypeRefImpl(arrayDef, TypeKind._tk_array);
1080        tr.setLength(length);
1081        tr.setContentType(element_type);
1082        return tr;
1083    }
1084
1085    /**
1086     ** Create a fixed type, i.e. fixed<digits,scale>.
1087     **
1088     ** @param digits The number of decimal digits.
1089     ** @param scale The position of the decimal point.
1090     **
1091     ** @return The new created TypeRef.
1092     **/

1093    public TypeRef
1094    createFixed(short digits,
1095                short scale)
1096    {
1097        // Create a FixedDef into the IFR.
1098
org.omg.CORBA.FixedDef JavaDoc fixedDef =
1099            repository_.create_fixed (digits,scale);
1100        TypeRefImpl tr = new TypeRefImpl(fixedDef, TypeKind._tk_fixed);
1101        tr.setDigits(digits);
1102        tr.setScale(scale);
1103        return tr;
1104    }
1105
1106    // ==================================================================
1107
//
1108
// Methods for the inherited DeclarationImpl class.
1109
//
1110
// ==================================================================
1111

1112    /**
1113     ** Obtain its CORBA 3.0 Contained reference.
1114     **
1115     ** @return null because a Repository does not support the
1116     ** Contained interface.
1117     **/

1118    protected org.omg.CORBA.Contained JavaDoc
1119    getContained()
1120    {
1121       return null;
1122    }
1123
1124    // ==================================================================
1125
//
1126
// Methods for the inherited ScopeImpl class.
1127
//
1128
// ==================================================================
1129

1130    /**
1131     ** Obtain its CORBA 3.0 Container reference.
1132     **
1133     ** @return The Repository.
1134     **/

1135    protected org.omg.CORBA.Container JavaDoc
1136    getContainer()
1137    {
1138       return repository_;
1139    }
1140
1141    /**
1142     ** Obtain its CORBA 3.0 Container reference.
1143     **
1144     ** @return The Container object associated with the module declaration.
1145     **/

1146    protected org.omg.CORBA.ComponentIR.Container
1147    getComponentContainer()
1148    {
1149        return openccm_repository_;
1150    }
1151}
1152
Popular Tags