KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > idl > ValueInheritanceSpec


1 package org.jacorb.idl;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2004 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import java.io.PrintWriter JavaDoc;
24 import java.util.*;
25
26 /**
27  * @author Gerald Brose
28  * @version $Id: ValueInheritanceSpec.java,v 1.14 2004/05/06 12:39:59 nicolas Exp $
29  */

30
31 class ValueInheritanceSpec
32     extends SymbolList
33 {
34     /** the value types (both abstract and stateful) inherited by this
35      value type */

36     //Vector v;
37

38     /** the IDL interfaces inherited ("supported") by this value type */
39     Vector supports;
40
41     /** if the value type this spec belongs to is truncatable to the
42      single stateful ancestor value type */

43     Truncatable truncatable = null;
44
45     public ValueInheritanceSpec( int num )
46     {
47         super( num );
48         //v = new Vector();
49
supports = new Vector();
50     }
51
52     public String JavaDoc getTruncatableId()
53     {
54         if( truncatable == null )
55         {
56             return null;
57         }
58         else
59         {
60             return truncatable.getId();
61         }
62     }
63
64     public boolean isEmpty()
65     {
66         return ( v.size() == 0 && truncatable == null );
67     }
68
69     public Enumeration getValueTypes()
70     {
71         return v.elements();
72     }
73
74     public Enumeration getSupportedInterfaces()
75     {
76         return supports.elements();
77     }
78
79     public void setPackage( String JavaDoc s )
80     {
81         s = parser.pack_replace( s );
82         if( pack_name.length() > 0 )
83             pack_name = s + "." + pack_name;
84         else
85             pack_name = s;
86
87         if( truncatable != null )
88             truncatable.scopedName.setPackage( s );
89
90         for( Enumeration e = v.elements(); e.hasMoreElements(); )
91             ( (IdlSymbol)e.nextElement() ).setPackage( s );
92
93         for( Enumeration e = supports.elements(); e.hasMoreElements(); )
94             ( (IdlSymbol)e.nextElement() ).setPackage( s );
95     }
96
97     public void parse()
98     {
99         if( truncatable != null )
100         {
101             ScopedName s = truncatable.scopedName;
102             Value v = (Value)((ConstrTypeSpec)s.resolvedTypeSpec()).c_type_spec;
103             if( v instanceof ValueAbsDecl )
104             {
105                 parser.error( "truncatable base value " +
106                               s.toString() + " must not be abstract", token );
107             }
108         }
109         Enumeration e = v.elements();
110         for( ; e.hasMoreElements(); )
111         {
112             ( (IdlSymbol)e.nextElement() ).parse();
113         }
114
115     }
116
117     public void print( PrintWriter JavaDoc ps )
118     {
119         ps.print( toString() );
120     }
121
122     public String JavaDoc toString()
123     {
124         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
125
126         if( truncatable != null )
127             sb.append( truncatable.toString() + " " );
128
129         Enumeration e = v.elements();
130
131         if( e.hasMoreElements() )
132             sb.append( (IdlSymbol)e.nextElement() + " " );
133
134         for( ; e.hasMoreElements(); )
135         {
136             sb.append( "," + (IdlSymbol)e.nextElement() + " " );
137         }
138
139         Enumeration s = supports.elements();
140         if( s.hasMoreElements() )
141         {
142             sb.append( "supports " );
143             ( (IdlSymbol)s.nextElement() ).toString();
144         }
145
146         for( ; s.hasMoreElements(); )
147         {
148             sb.append( "," );
149             ( (IdlSymbol)s.nextElement() ).toString();
150         }
151
152         return sb.toString();
153     }
154 }
155
156
157
158
Popular Tags