KickJava   Java API By Example, From Geeks To Geeks.

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


1
2 /*
3  * JacORB - a free Java ORB
4  *
5  * Copyright (C) 1997-2004 Gerald Brose.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) 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  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the Free
19  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */

21
22 package org.jacorb.idl;
23
24 /**
25  * @author Gerald Brose
26  * @version $Id: ConstrTypeSpec.java,v 1.21 2004/05/06 12:39:58 nicolas Exp $
27  */

28
29 import java.io.PrintWriter JavaDoc;
30 import java.util.*;
31
32 public class ConstrTypeSpec
33     extends TypeSpec
34 {
35     public TypeDeclaration c_type_spec;
36
37     public ConstrTypeSpec( int num )
38     {
39         super( num );
40     }
41
42     public ConstrTypeSpec( TypeDeclaration c )
43     {
44         super( new_num() );
45         c_type_spec = c;
46     }
47
48     public void set_name( String JavaDoc n )
49     {
50         c_type_spec.set_name( n );
51     }
52
53     public Object JavaDoc clone()
54     {
55         ConstrTypeSpec cts = new ConstrTypeSpec( new_num() );
56         cts.c_type_spec = (TypeDeclaration)c_type_spec.clone();
57         return cts;
58     }
59
60     public TypeDeclaration declaration()
61     {
62         return c_type_spec;
63     }
64
65     public void setEnclosingSymbol( IdlSymbol s )
66     {
67         if( enclosing_symbol != null && enclosing_symbol != s )
68             throw new RuntimeException JavaDoc( "Compiler Error: trying to reassign container for " + name );
69         enclosing_symbol = s;
70         c_type_spec.setEnclosingSymbol( s );
71     }
72
73     public String JavaDoc toString()
74     {
75         String JavaDoc n = typeName();
76         if( !n.startsWith( "org.omg" ) )
77         {
78             return omgPrefix() + n;
79         }
80         else
81             return n;
82     }
83
84     public String JavaDoc typeName()
85     {
86         return c_type_spec.typeName();
87     }
88
89     public String JavaDoc full_name()
90     {
91         return c_type_spec.full_name();
92     }
93
94     /**
95      * @return "org.omg." if the symbol has been declare inside a
96      * scope with a pragma prefix of "omg.org"
97      */

98
99     public String JavaDoc omgPrefix()
100     {
101         return c_type_spec.omg_package_prefix;
102     }
103
104     public TypeSpec typeSpec()
105     {
106         return this;
107     }
108
109     public boolean basic()
110     {
111         return c_type_spec.basic();
112     }
113
114     public void parse()
115     {
116         c_type_spec.parse();
117     }
118
119     public void setPackage( String JavaDoc s )
120     {
121         s = parser.pack_replace( s );
122         c_type_spec.setPackage( s );
123     }
124
125
126     public String JavaDoc getTypeCodeExpression( Set knownTypeSpecs )
127     {
128         return c_type_spec.getTypeCodeExpression( knownTypeSpecs );
129     }
130
131     /**
132      * @return a string for an expression of type TypeCode that describes this type
133      */

134     public String JavaDoc getTypeCodeExpression()
135     {
136         return c_type_spec.getTypeCodeExpression();
137     }
138
139
140     public void print( PrintWriter JavaDoc ps )
141     {
142         c_type_spec.print( ps );
143     }
144
145     public String JavaDoc holderName()
146     {
147         return c_type_spec.holderName();
148     }
149
150     public String JavaDoc printReadExpression( String JavaDoc streamname )
151     {
152         return c_type_spec.printReadExpression( streamname );
153     }
154
155     public String JavaDoc printWriteStatement( String JavaDoc var_name, String JavaDoc streamname )
156     {
157         return c_type_spec.printWriteStatement( var_name, streamname );
158     }
159
160     public String JavaDoc printInsertExpression()
161     {
162         throw new RuntimeException JavaDoc( "Should not be called" );
163     }
164
165     public String JavaDoc printExtractExpression()
166     {
167         throw new RuntimeException JavaDoc( "Should not be called" );
168     }
169
170     public String JavaDoc id()
171     {
172         return c_type_spec.declaration().id();
173     }
174
175     /**
176      */

177
178     public void accept( IDLTreeVisitor visitor )
179     {
180         c_type_spec.declaration().accept( visitor );
181     }
182
183
184 }
185
Popular Tags