KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > parser > lib > DeclaratorList


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.parser.lib;
28
29 // Package dependencies
30
import org.objectweb.openccm.ast.api.TypeRef;
31
32 /**
33  * This class manages list of declarators.
34  *
35  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
36  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
37  *
38  * @version 0.3
39  */

40
41 public class DeclaratorList
42 {
43     // ==================================================================
44
//
45
// Internal state.
46
//
47
// ==================================================================
48

49     /**
50      ** List of declarator names.
51      **/

52     private java.util.List JavaDoc names_;
53
54     /**
55      ** List of declarator types.
56      **/

57     private java.util.List JavaDoc types_;
58
59     // ==================================================================
60
//
61
// Constructor.
62
//
63
// ==================================================================
64

65     /**
66      ** The default constructor.
67      **/

68     public DeclaratorList()
69     {
70         // Init internal state.
71
names_ = new java.util.ArrayList JavaDoc();
72         types_ = new java.util.ArrayList JavaDoc();
73     }
74
75     // ==================================================================
76
//
77
// Public methods.
78
//
79
// ==================================================================
80

81     /**
82      ** Add a declarator.
83      **
84      ** @param name The name of the declarator.
85      ** @param type The TypeRef of the declarator.
86      **/

87     public void
88     addDeclarator(String JavaDoc name,
89                   TypeRef type)
90     {
91         names_.add(name);
92         types_.add(type);
93     }
94
95     /**
96      ** Obtain the number of declarators.
97      **
98      ** @return The number of declarators.
99      **/

100     public int
101     size()
102     {
103         return names_.size();
104     }
105
106     /**
107      ** Obtain the name of the index declarator.
108      **
109      ** @param index The index of the searched declarator.
110      **
111      ** @return The name of the declarator at the specified index.
112      **/

113     public String JavaDoc
114     nameAt(int index)
115     {
116         return (String JavaDoc) names_.get(index);
117     }
118
119     /**
120      ** Obtain the type of the index declarator.
121      **
122      ** @param index The index of the searched declarator.
123      **
124      ** @return The TypeRef of the declarator at the specified index.
125      **/

126     public TypeRef
127     typeAt(int index)
128     {
129         return (TypeRef) types_.get(index);
130     }
131 }
132
Popular Tags