KickJava   Java API By Example, From Geeks To Geeks.

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


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 /** Used to access AST TypeKind. */
30 import org.objectweb.openccm.ast.api.TypeKind;
31
32 /** Used to access AST TypeRef. */
33 import org.objectweb.openccm.ast.api.TypeRef;
34
35 /** Used to access AST DeclarationKind. */
36 import org.objectweb.openccm.ast.api.DeclarationKind;
37
38 /** Used to access AST Declaration. */
39 import org.objectweb.openccm.ast.api.Declaration;
40
41 /** Used to access AST InterfaceDecl. */
42 import org.objectweb.openccm.ast.api.InterfaceDecl;
43
44 /** Used to access AST AttributeDecl. */
45 import org.objectweb.openccm.ast.api.AttributeDecl;
46
47 /** Used to access AST OperationDecl. */
48 import org.objectweb.openccm.ast.api.OperationDecl;
49
50 /** Used to access AST ValueDecl. */
51 import org.objectweb.openccm.ast.api.ValueDecl;
52
53 /** Used to access AST ValueList. */
54 import org.objectweb.openccm.ast.api.ValueList;
55
56 /** Used to access AST InterfaceList. */
57 import org.objectweb.openccm.ast.api.InterfaceList;
58
59 /** Used to access AST Initializer. */
60 import org.objectweb.openccm.ast.api.Initializer;
61
62 /** Used to access AST InitializerList. */
63 import org.objectweb.openccm.ast.api.InitializerList;
64
65 /** Used to access AST Parameter. */
66 import org.objectweb.openccm.ast.api.Parameter;
67
68 /** Used to access AST Exception. */
69 import org.objectweb.openccm.ast.api.ExceptionDecl;
70
71 /** To use CORBA::ValueDef. */
72 import org.omg.CORBA.ValueDef JavaDoc;
73
74 /** To use CORBA::ExtValueDef. */
75 import org.omg.CORBA.ExtValueDef;
76 import org.omg.CORBA.ExtValueDefHelper;
77
78 /** To use CORBA::InterfaceDef. */
79 import org.omg.CORBA.InterfaceDef JavaDoc;
80
81 /**
82  * ValueDeclImpl is a wrapper class for IDL value type declarations.
83  *
84  *
85  * Inherits from:
86  *
87  * - ForwardScopeImpl as valuetypes are also IDL forward scopes.
88  *
89  * - ValueDecl: OMG IDL for value type declarations.
90  *
91  * - IDLTypeWrapper as values are IDL types.
92  *
93  *
94  * Provides:
95  *
96  * - the boolean 'Custom' property
97  * i.e. the setCustom and isCustom operations.
98  *
99  * - the boolean 'Abstract' property
100  * i.e. the setAbstract and isAbstract operations.
101  *
102  * - the boolean 'Truncatable' property
103  * i.e. the setTruncatable and isTruncatable operations.
104  *
105  * - the inherited 'BaseValue' property
106  * i.e. the setBaseValue and getBaseValue operations.
107  *
108  * - the boolean 'PrimaryKey' property
109  * i.e. the isPrimaryKey operation.
110  *
111  * - the list of inherited abstract valuetypes
112  * i.e. the getAbstractValueList operation.
113  *
114  * - the list of supported interfaces
115  * i.e. the getSupportedInterfaceList operation.
116  *
117  * - the list of initializers
118  * i.e. the getInitializerList operation.
119  *
120  *
121  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
122  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
123  *
124  * @version 0.3
125  */

126
127 public class ValueDeclImpl
128      extends ForwardScopeIDLImpl
129   implements ValueDecl,
130              IDLTypeWrapper
131 {
132     // ==================================================================
133
//
134
// Internal state.
135
//
136
// ==================================================================
137

138     /** Reference to the CORBA 3.0 ValueDef. */
139     protected ExtValueDef ext_value_def_;
140
141     /** To store the 'Custom' property. */
142     protected boolean is_custom_;
143
144     /** To store the 'Abstract' property. */
145     protected boolean is_abstract_;
146
147     /** To store the 'Truncatable' property. */
148     protected boolean is_truncatable_;
149
150     /** The inherited base value. */
151     protected ValueDeclImpl base_value_;
152
153     /** The inherited abstract base values. */
154     protected ValueListImpl abstract_base_values_;
155
156     /** The supported interfaces. */
157     protected InterfaceListImpl supported_interfaces_;
158
159     /** The initializers. */
160     protected InitializerListImpl initializers_;
161  
162     // ==================================================================
163
//
164
// Constructor.
165
//
166
// ==================================================================
167

168     /**
169      * The constructor with the parent scope.
170      *
171      * @param rep The repository of the declaration.
172      * @param parent The parent scope of the value declaration.
173      */

174     public
175     ValueDeclImpl(Repository rep, ScopeImpl parent)
176     {
177         // Call the ForwardScopeIDLImpl constructor.
178
super(rep, parent);
179
180         // Init internal state.
181
ext_value_def_ = null;
182         is_custom_ = false;
183         is_abstract_ = false;
184         is_truncatable_ = false;
185         base_value_ = null;
186         abstract_base_values_ = new ValueListImpl();
187         supported_interfaces_ = new InterfaceListImpl();
188         initializers_ = new InitializerListImpl();
189     }
190
191     // ==================================================================
192
//
193
// Internal methods.
194
//
195
// ==================================================================
196

197     // ==================================================================
198
//
199
// Internal methods for DeclarationImpl.
200
//
201
// ==================================================================
202

203     /**
204      * Loads infos of the CORBA 3.0 ValueDef.
205      *
206      * @param contained The ValueDef to load.
207      */

208     protected void
209     load(org.omg.CORBA.Contained JavaDoc contained)
210     {
211         ext_value_def_ = ExtValueDefHelper.narrow(contained);
212         is_custom_ = ext_value_def_.is_custom();
213         is_abstract_ = ext_value_def_.is_abstract();
214         is_truncatable_ = ext_value_def_.is_truncatable();
215
216         ValueDef JavaDoc baseValue = ext_value_def_.base_value();
217         if (baseValue!=null)
218             setBaseValue((ValueDecl)getRepository().lookupId(baseValue.id()));
219
220         // load as scope now to prevent infinite loop in the case
221
// of recursive union.
222
super.load(contained);
223
224         ValueDef JavaDoc[] abstract_base_values = ext_value_def_.abstract_base_values();
225         for (int i=0; i<abstract_base_values.length; i++)
226             abstract_base_values_.add(
227                 (ValueDecl)getRepository().
228                 lookupId(abstract_base_values[i].id()));
229
230         InterfaceDef JavaDoc[] supported_interfaces =
231              ext_value_def_.supported_interfaces();
232         for (int i=0; i<supported_interfaces.length; i++)
233             supported_interfaces_.add(
234                 (InterfaceDecl)getRepository().
235                 lookupId(supported_interfaces[i].id()));
236
237         org.omg.CORBA.ExtInitializer[] initializers =
238             ext_value_def_.ext_initializers();
239         for (int i=0; i<initializers.length; i++)
240         {
241             Initializer initializer = startInitializer(initializers[i].name);
242             initializers_.add(initializer);
243             // Load initializer parameters
244
org.omg.CORBA.StructMember JavaDoc[] params = initializers[i].members;
245             for (int j=0; j<params.length; j++)
246             {
247                 initializer.getParameterList().
248                             addInParam(params[j].name,
249                                        getRepository().
250                                        getAsTypeRef(params[j].type_def));
251             }
252             // Load initializer exceptions
253
org.omg.CORBA.ExceptionDef JavaDoc[] exc = initializers[i].exceptions_def;
254             for (int j=0; j<exc.length; j++)
255             {
256                 initializer.getExceptionList().add(
257                         (ExceptionDecl)getRepository().lookupId(exc[j].id()) );
258             }
259         }
260     }
261
262     /**
263      * Loads infos of the CORBA 3.0 ValueDef.
264      *
265      * @param contained The ValueDef to load.
266      */

267     protected void
268     loadAsMapping(org.omg.CORBA.Contained JavaDoc contained)
269     {
270         ext_value_def_ = ExtValueDefHelper.narrow(contained);
271         is_custom_ = ext_value_def_.is_custom();
272         is_abstract_ = ext_value_def_.is_abstract();
273         is_truncatable_ = ext_value_def_.is_truncatable();
274
275         ValueDef JavaDoc baseValue = ext_value_def_.base_value();
276         if (baseValue!=null)
277             setBaseValue((ValueDecl)getRepository().
278             lookupMappedId(baseValue.id()));
279
280         // load as scope now to prevent infinite loop in the case
281
// of recursive union.
282
super.loadAsMapping(contained);
283
284
285         ValueDef JavaDoc[] abstract_base_values =
286             ext_value_def_.abstract_base_values();
287         for (int i=0; i<abstract_base_values.length; i++)
288             abstract_base_values_.add(
289                 (ValueDecl)getRepository().
290                 lookupMappedId(abstract_base_values[i].id()));
291
292         InterfaceDef JavaDoc[] supported_interfaces =
293             ext_value_def_.supported_interfaces();
294         for (int i=0; i<supported_interfaces.length; i++)
295             supported_interfaces_.add(
296                 (InterfaceDecl)getRepository().
297                 lookupMappedId(supported_interfaces[i].id()));
298
299         org.omg.CORBA.ExtInitializer[] initializers =
300             ext_value_def_.ext_initializers();
301         for (int i=0; i<initializers.length; i++)
302         {
303             Initializer initializer = startInitializer(initializers[i].name);
304             initializers_.add(initializer);
305             // Load initializer parameters
306
org.omg.CORBA.StructMember JavaDoc[] params = initializers[i].members;
307             for (int j=0; j<params.length; j++)
308             {
309                 initializer.getParameterList().
310                             addInParam(params[j].name,
311                                        getRepository().
312                                        getAsMappedTypeRef(params[j].type_def));
313             }
314             // Load initializer exceptions
315
org.omg.CORBA.ExceptionDef JavaDoc[] exc = initializers[i].exceptions_def;
316             for (int j=0; j<exc.length; j++)
317             {
318                 initializer.getExceptionList().add(
319                         (ExceptionDecl)getRepository().lookupId(exc[j].id()) );
320             }
321         }
322     }
323
324     /**
325      * Obtain its CORBA 3.0 Contained reference.
326      *
327      * @return The Contained object associated with the value declaration.
328      */

329     protected org.omg.CORBA.Contained JavaDoc
330     getContained()
331     {
332        return ext_value_def_;
333     }
334
335     // ==================================================================
336
//
337
// Internal methods for ScopeImpl.
338
//
339
// ==================================================================
340

341     /**
342      * Create an attribute definition.
343      *
344      * @param attribute The attribute declaration.
345      * @param type The IDLType of the attribute.
346      * @param mode The mode of the attribute.
347      * @param get_exceptions An array containing the exceptions that
348      * the accessor method can raise.
349      * @param put_exceptions An array containing the exceptions that
350      * the mutator method can raise.
351      *
352      * @return The new created AttributeDef.
353      */

354     protected org.omg.CORBA.ExtAttributeDef
355     createExtAttribute(AttributeDecl attribute,
356                        org.omg.CORBA.IDLType JavaDoc type,
357                        org.omg.CORBA.AttributeMode JavaDoc mode,
358                        org.omg.CORBA.ExceptionDef JavaDoc[] get_exceptions,
359                        org.omg.CORBA.ExceptionDef JavaDoc[] set_exceptions)
360     {
361         // Create an AttributeDef into the IFR!;
362
org.omg.CORBA.ExtAttributeDef ext_attribute_def =
363             getExtValueDef().create_ext_attribute(attribute.getId(),
364                                                   attribute.getName(),
365                                                   attribute.getVersion(),
366                                                   type, mode,
367                                                   get_exceptions,
368                                                   set_exceptions);
369         return ext_attribute_def;
370     }
371
372     /**
373      * Create an operation
374      *
375      * @param operation The operation declaration.
376      * @param type The IDLType of the object that the operations returns.
377      * @param mode The mode of the operation ie normal or oneway.
378      * @param params An array containing the parameters description.
379      * @param exceptions An array containing the exceptions that
380      * the operation can raise.
381      * @param contexts An array containing the possible context values.
382      *
383      * @return The new created OperationDef.
384      */

385     protected org.omg.CORBA.OperationDef JavaDoc
386     createOperation(OperationDecl operation,
387                     org.omg.CORBA.IDLType JavaDoc type,
388                     org.omg.CORBA.OperationMode JavaDoc mode,
389                     org.omg.CORBA.ParameterDescription JavaDoc[] params,
390                     org.omg.CORBA.ExceptionDef JavaDoc[] exceptions,
391                     String JavaDoc[] contexts)
392     {
393         // Create an OperationDef into the IFR.
394
org.omg.CORBA.OperationDef JavaDoc operation_def =
395             getExtValueDef().create_operation(operation.getId(),
396                                               operation.getName(),
397                                               operation.getVersion(),
398                                               type, mode,
399                                               params,
400                                               exceptions,
401                                               contexts);
402         return operation_def;
403     }
404
405     /**
406      * Obtain its CORBA 3.0 Container reference.
407      *
408      * @return The Container object associated with the value declaration.
409      */

410     protected org.omg.CORBA.Container JavaDoc
411     getContainer()
412     {
413         return ext_value_def_;
414     }
415
416     // ==================================================================
417
//
418
// Internal methods for ForwardScopeImpl.
419
//
420
// ==================================================================
421

422     // ==================================================================
423
//
424
// Internal methods for ForwardScopeIDLImpl.
425
//
426
// ==================================================================
427

428     /**
429      * Create the container object.
430      */

431     protected void
432     createContainer()
433     {
434         // Create a ValueDef into the IFR.
435
ext_value_def_ = the_parent_.getContainer().
436                          create_ext_value(getId(), getName(), getVersion(),
437                          is_custom_, is_abstract_,
438                          getBaseValueDef(),
439                          is_truncatable_,
440                          abstract_base_values_.getValueDefSeq(),
441                          supported_interfaces_.getInterfaceDefSeq(),
442                          new org.omg.CORBA.ExtInitializer[0]);
443     }
444
445     /**
446      * Complete the container object.
447      */

448     protected void
449     completeContainer()
450     {
451         ValueDef JavaDoc base_value = getBaseValueDef();
452         if(base_value != null)
453             getExtValueDef().base_value(base_value);
454
455         if(abstract_base_values_.getSize() != 0)
456             getExtValueDef().abstract_base_values(abstract_base_values_.getValueDefSeq());
457
458         if(supported_interfaces_.getSize() != 0)
459             getExtValueDef().supported_interfaces(supported_interfaces_.getInterfaceDefSeq());
460
461         if(initializers_.getSize() != 0)
462             getExtValueDef().ext_initializers(initializers_.getExtInitializerSeq());
463     }
464
465     // ==================================================================
466
//
467
// Public methods.
468
//
469
// ==================================================================
470

471     /**
472      * Obtain the base value.
473      *
474      * @return The ExtValueDef of the base value or null if it not exists.
475      **/

476     public ExtValueDef
477     getBaseValueDef()
478     {
479         return (base_value_ != null)
480          ? (base_value_.getExtValueDef()) : null;
481     }
482
483     /**
484      * Obtain its ValueDef reference.
485      *
486      * @return The ValueDef associated with the value declaration.
487      */

488     public ExtValueDef
489     getExtValueDef()
490     {
491         return ext_value_def_;
492     }
493
494     /**
495      * Obtain its ValueDef reference.
496      *
497      * @return The ValueDef associated with the value declaration.
498      */

499     public ValueDef JavaDoc
500     getValueDef()
501     {
502         return ext_value_def_;
503     }
504
505     // ==================================================================
506
//
507
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
508
//
509
// ==================================================================
510

511     /**
512      * Obtain the declaration external dependencies.
513      *
514      * Note: for scopes, contained objects are not considered
515      * as dependencies.
516      *
517      * @return The list of dependencies as an array of Declaration.
518      */

519     public Declaration[]
520     getDependencies()
521     {
522         if (dependencies_!=null)
523             return dependencies_;
524
525         dependencies_ = new Declaration[0];
526         java.util.List JavaDoc value_depend = new java.util.ArrayList JavaDoc();
527         Declaration[] depend = null;
528
529         // base value
530
if (getBaseValue()!=null)
531         {
532             value_depend.add(getBaseValue());
533             depend = getBaseValue().getDependencies();
534             for (int j=0; j<depend.length; j++)
535             {
536                 if (depend[j]!=this)
537                     value_depend.add(depend[j]);
538             }
539         }
540
541         // abstract base values
542
ValueDecl[] abs = abstract_base_values_.getValues();
543         for (int i=0; i<abs.length; i++)
544         {
545             value_depend.add(abs[i]);
546             depend = abs[i].getDependencies();
547             for (int j=0; j<depend.length; j++)
548             {
549                 if ((depend[j]!=this) &&
550                     (value_depend.indexOf(depend[j])==-1))
551                     value_depend.add(depend[j]);
552             }
553         }
554
555         // supported interfaces
556
InterfaceDecl[] supp = supported_interfaces_.getInterfaces();
557         for (int i=0; i<supp.length; i++)
558         {
559             value_depend.add(supp[i]);
560             depend = supp[i].getDependencies();
561             for (int j=0; j<depend.length; j++)
562             {
563                 if ((depend[j]!=this) &&
564                     (value_depend.indexOf(depend[j])==-1))
565                     value_depend.add(depend[j]);
566             }
567         }
568
569         // initializers
570
Initializer[] inits = initializers_.getInitializers();
571         for (int i=0; i<inits.length; i++)
572         {
573             Parameter[] parameters = inits[i].getParameterList().
574                                      getParameters();
575             for (int j=0; j<parameters.length; j++)
576             {
577                 TypeRef param_type = parameters[j].getType();
578                 depend = param_type.getDependencies();
579                 for (int k=0; k<depend.length; k++)
580                 {
581                     if ((!containsDecl(depend[k])) &&
582                         (depend[k]!=this) &&
583                         (value_depend.indexOf(depend[k])==-1))
584                         value_depend.add(depend[k]);
585                 }
586             }
587         }
588
589         // contents
590
Declaration[] decls = getContents(true, DeclarationKind.dk_all);
591         for (int i=0; i<decls.length; i++)
592         {
593             depend = decls[i].getDependencies();
594             for (int j=0; j<depend.length; j++)
595             {
596                 if ((!containsDecl(depend[j])) &&
597                     (depend[j]!=this) &&
598                     (value_depend.indexOf(depend[j])==-1))
599                     value_depend.add(depend[j]);
600             }
601         }
602
603         dependencies_ = (Declaration[])value_depend.toArray(new Declaration[0]);
604         return dependencies_;
605     }
606
607     // ==================================================================
608
//
609
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
610
//
611
// ==================================================================
612

613     /**
614      * Obtain its DeclarationKind.
615      *
616      * @return The DeclarationKind of the object.
617      */

618     public long
619     getDeclKind()
620     {
621         return DeclarationKind.dk_value;
622     }
623
624     // ==================================================================
625
//
626
// Methods for OMG IDL org.objectweb.openccm.ast.api.Scope
627
//
628
// ==================================================================
629

630     /**
631      * Find a declaration.
632      *
633      * Note that the declaration is also recursively searched in the
634      * parent scope.
635      *
636      * @param name The name of the searched declaration.
637      *
638      * @return The declaration that was searched
639      * or null if it does not exist.
640      */

641     public Declaration
642     find(String JavaDoc name)
643     {
644         // Finds in the current scope.
645
Declaration decl = super.find(name);
646
647         // If found then returns it.
648
if(decl != null) return decl;
649
650         // If not found then finds in base value.
651
if(base_value_ != null)
652         {
653             decl = base_value_.find(name);
654
655             // If found then returns it.
656
if(decl != null) return decl;
657         }
658
659         // If not found then finds in abstract values.
660
decl = abstract_base_values_.find(name);
661
662         // If found then returns it.
663
if(decl != null) return decl;
664
665         // If not found then finds in supported interfaces.
666
decl = supported_interfaces_.find(name);
667
668         // Else not found.
669
return null;
670     }
671
672     /**
673      * To obtain all the contained Declaration objects.
674      *
675      * @param exclude_inherited If false return also objects contained in inherited scopes.
676      * @param limited_types A logical combination of DeclarationKind.
677      *
678      * @return An array of Declaration objects.
679      */

680     public Declaration[]
681     getContents(boolean exclude_inherited,
682                 long limited_types)
683     {
684         if (exclude_inherited)
685             return super.getContents(exclude_inherited, limited_types);
686
687         Declaration[] res = super.getContents(exclude_inherited, limited_types);
688
689         InterfaceDecl[] itfs = supported_interfaces_.getInterfaces();
690         for (int i=0; i<itfs.length; i++)
691         {
692             Declaration[] tmp1 = itfs[i].getContents(exclude_inherited, limited_types);
693             Declaration[] tmp2 = res;
694             res = new Declaration[tmp1.length+tmp2.length];
695             System.arraycopy(tmp2, 0, res, 0, tmp2.length);
696             System.arraycopy(tmp1, 0, res, tmp2.length, tmp1.length);
697         }
698         ValueDecl[] vals = abstract_base_values_.getValues();
699         for (int i=0; i<vals.length; i++)
700         {
701             Declaration[] tmp1 = vals[i].getContents(exclude_inherited, limited_types);
702             Declaration[] tmp2 = res;
703             res = new Declaration[tmp1.length+tmp2.length];
704             System.arraycopy(tmp2, 0, res, 0, tmp2.length);
705             System.arraycopy(tmp1, 0, res, tmp2.length, tmp1.length);
706         }
707         if (base_value_==null)
708             return res;
709
710         Declaration[] tmp1 = base_value_.getContents(exclude_inherited, limited_types);
711         Declaration[] tmp2 = res;
712         res = new Declaration[tmp1.length+tmp2.length];
713         System.arraycopy(tmp2, 0, res, 0, tmp2.length);
714         System.arraycopy(tmp1, 0, res, tmp2.length, tmp1.length);
715         return res;
716     }
717
718     // ==================================================================
719
//
720
// Methods for OMG IDL org.objectweb.openccm.ast.api.ForwardScope
721
//
722
// ==================================================================
723

724     // ==================================================================
725
//
726
// Methods for OMG IDL org.objectweb.openccm.ast.api.TypeRef
727
//
728
// ==================================================================
729

730     /**
731      * Obtain its associated TypeKind.
732      *
733      * @return The associated TypeKind.
734      */

735     public TypeKind
736     getTypeKind()
737     {
738         return TypeKind.tk_value;
739     }
740
741     // ==================================================================
742
//
743
// Methods for OMG IDL org.objectweb.openccm.ast.api.ValueDecl
744
//
745
// ==================================================================
746

747     /**
748      * Set as a custom valuetype.
749      *
750      * @param b True if it is a custom valuetype, else false.
751      */

752     public void
753     setCustom(boolean b)
754     {
755         is_custom_ = b;
756     }
757
758     /**
759      * Is it a custom valuetype?
760      *
761      * @return True if it is a custom valuetype, else false.
762      */

763     public boolean
764     isCustom()
765     {
766         return is_custom_;
767     }
768
769     /**
770      * Set as an abstract valuetype.
771      *
772      * @param b True if it is an abstract valuetype, else false.
773      */

774     public void
775     setAbstract(boolean b)
776     {
777         is_abstract_ = b;
778     }
779
780     /**
781      * Is it abstract?
782      *
783      * @return True if it is an abstract valuetype, else false.
784      */

785     public boolean
786     isAbstract()
787     {
788         return is_abstract_;
789     }
790
791     /**
792      * Set as a truncatable valuetype.
793      *
794      * @param b True if it is a truncatable valuetype, else false.
795      */

796     public void
797     setTruncatable(boolean b)
798     {
799         is_truncatable_ = b;
800     }
801
802     /**
803      * Is it truncatable?
804      *
805      * @return True if it is a truncatable valuetype, else false.
806      */

807     public boolean
808     isTruncatable()
809     {
810         return is_truncatable_;
811     }
812
813     /**
814      * Set the base value.
815      *
816      * @param value The base value.
817      */

818     public void
819     setBaseValue(ValueDecl value)
820     {
821         if(value != null)
822         {
823             base_value_ = (ValueDeclImpl)value;
824         }
825     }
826
827     /**
828      * Obtain the base value.
829      *
830      * @return The base value.
831      */

832     public ValueDecl
833     getBaseValue()
834     {
835         return base_value_;
836     }
837
838     /**
839      * Is it a primary key valuetype?
840      *
841      * @return True if it is a primary key, else false.
842      */

843     public boolean
844     isPrimaryKey()
845     {
846         boolean is_pk = false;
847         ValueDecl[] abs = abstract_base_values_.getValues();
848         for (int i=0;i<abs.length;i++)
849         {
850             if (abs[i].getAbsoluteName().equals("::Components::PrimaryKeyBase"))
851                 return true;
852
853             is_pk = abs[i].isPrimaryKey();
854             if (is_pk)
855                 return true;
856         }
857
858         if (getBaseValue()!=null)
859             is_pk = getBaseValue().isPrimaryKey();
860
861         return is_pk;
862     }
863
864     /**
865      * Obtain the list of inherited abstract values.
866      *
867      * @param itf The list of inherited abstract values.
868      */

869     public ValueList
870     getAbstractValueList()
871     {
872         return abstract_base_values_;
873     }
874
875
876     /**
877      * Obtain the list of supported interfaces.
878      *
879      * @param itf The list of supported interfaces.
880      */

881     public InterfaceList
882     getSupportedInterfaceList()
883     {
884         return supported_interfaces_;
885     }
886
887     /**
888      * Obtain the list of initializers.
889      *
890      * @param itf The list of initializers.
891      */

892     public InitializerList
893     getInitializerList()
894     {
895         return initializers_;
896     }
897
898     // ==================================================================
899
//
900
// Methods for interface IDLTypeWrapper
901
//
902
// ==================================================================
903

904     /**
905      * Obtain its IDLType reference.
906      *
907      * @return The IDLType associated with the value declaration.
908      */

909     public org.omg.CORBA.IDLType JavaDoc
910     getIDLType()
911     {
912         return ext_value_def_;
913     }
914 }
915
Popular Tags