KickJava   Java API By Example, From Geeks To Geeks.

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


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

20
21 package org.jacorb.idl;
22
23 import java.io.PrintWriter JavaDoc;
24 import java.util.*;
25
26 /**
27  * @author Gerald Brose
28  * @version $Id: AttrDecl.java,v 1.17 2004/05/06 12:39:58 nicolas Exp $
29  */

30
31 public class AttrDecl
32     extends Declaration
33 {
34     public boolean readOnly;
35     public TypeSpec param_type_spec;
36     public SymbolList declarators;
37
38     private Vector operations = new Vector();
39
40     public AttrDecl( int num )
41     {
42         super( num );
43     }
44
45     public void setPackage( String JavaDoc s )
46     {
47         s = parser.pack_replace( s );
48         if( pack_name.length() > 0 )
49             pack_name = s + "." + pack_name;
50         else
51             pack_name = s;
52         declarators.setPackage( s );
53         param_type_spec.setPackage( s );
54     }
55
56     public void parse()
57     {
58         IdlSymbol myInterface = enclosing_symbol;
59
60         if( param_type_spec.typeSpec() instanceof ScopedName )
61         {
62             TypeSpec ts =
63                     ( (ScopedName)param_type_spec.typeSpec() ).resolvedTypeSpec();
64             if( ts != null )
65                 param_type_spec = ts;
66
67             myInterface.addImportedName( ts.typeName() );
68         }
69
70         // declarator names can be left unparsed to tolerate buggy
71
// IDL generated by rmic
72
if (parser.strict_attributes)
73         {
74             declarators.parse();
75         }
76
77         for (Enumeration e = declarators.v.elements(); e.hasMoreElements();)
78         {
79             operations.addElement(
80                     new Method( param_type_spec,
81                             null,
82                             ( (SimpleDeclarator)e.nextElement() ).name(),
83                             is_pseudo)
84             );
85         }
86
87         if (!readOnly)
88         {
89             for( Enumeration e = declarators.v.elements(); e.hasMoreElements(); )
90             {
91                 SimpleDeclarator d =
92                         (SimpleDeclarator)e.nextElement();
93                 operations.addElement(
94                         new Method( null,
95                                 param_type_spec,
96                                 d.name(),
97                                 is_pseudo )
98                 );
99             }
100         }
101     }
102
103     public void print( PrintWriter JavaDoc ps )
104     {
105     }
106
107     public Enumeration getOperations()
108     {
109         return operations.elements();
110     }
111
112     /**
113      * collect Interface Repository information in the argument hashtable
114      */

115
116     public void getIRInfo( Hashtable irInfoTable )
117     {
118         for( Enumeration e = declarators.v.elements(); e.hasMoreElements(); )
119         {
120             String JavaDoc fullName = param_type_spec.full_name();
121             irInfoTable.put( ( (SimpleDeclarator)e.nextElement() ).name(),
122                     "attribute" + ( readOnly?"":"-w" ) + ";" +
123                     ( fullName != null ? fullName : param_type_spec.typeName() ) );
124         }
125     }
126
127
128 }
129
130
131
132
133
134
135
136
Popular Tags