KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > IDL3 > ParameterListImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@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): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.IDL3;
28
29 /**
30  * This class manages IDL parameter lists.
31  *
32  * @author <a=href="Philippe.Merle@lifl.fr">Philippe Merle</a>
33  * <a=href="Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
34  *
35  * @version 0.3
36  */

37
38 public class ParameterListImpl
39        implements ParameterList
40 {
41     // ==================================================================
42
//
43
// Internal state.
44
//
45
// ==================================================================
46

47     /**
48      ** List of members names.
49      **/

50     protected org.objectweb.ccm.util.Vector param_names_;
51
52     /**
53      ** List of members TypeRef.
54      **/

55     protected org.objectweb.ccm.util.Vector param_types_;
56
57     /**
58      **
59      **/

60     protected org.objectweb.ccm.util.Vector param_modes_;
61
62     // ==================================================================
63
//
64
// Constructor.
65
//
66
// ==================================================================
67

68     /**
69      ** The default constructor.
70      **/

71     public ParameterListImpl()
72     {
73         // Init internal state.
74
param_names_ = new org.objectweb.ccm.util.Vector();
75         param_types_ = new org.objectweb.ccm.util.Vector();
76         param_modes_ = new org.objectweb.ccm.util.Vector();
77     }
78
79     // ==================================================================
80
//
81
// Internal methods.
82
//
83
// ==================================================================
84

85     /**
86      ** Obtain its ParameterDescription[].
87      **
88      ** @return An array containing the parameters description.
89      **/

90     protected org.omg.CORBA.ParameterDescription JavaDoc[]
91     getParameterDescs()
92     {
93         org.omg.CORBA.ParameterDescription JavaDoc[] result =
94             new org.omg.CORBA.ParameterDescription JavaDoc[param_names_.size()];
95
96         for(int i=0; i<result.length; i++)
97         {
98             result[i] = new org.omg.CORBA.ParameterDescription JavaDoc(
99                 (String JavaDoc)param_names_.get(i),
100                 org.objectweb.openccm.corba.TypeCodeUtils.getTC_void(),
101                 ((TypeRef)param_types_.get(i)).getIDLType(),
102                 org.omg.CORBA.ParameterMode.from_int(((Integer JavaDoc)param_modes_.get(i)).intValue()));
103
104         }
105         return result;
106     }
107
108     /**
109      **
110      **/

111     protected void
112     destroy()
113     {
114         for (int i=0;i<param_types_.size();i++)
115         {
116             ((TypeRef)param_types_.get(i)).removeRef();
117         }
118     }
119
120     // ==================================================================
121
//
122
// Methods for the ParameterList interface.
123
//
124
// ==================================================================
125

126     /**
127      **
128      **/

129     public void
130     addParam(String JavaDoc name,
131              TypeRef type,
132              int mode)
133     {
134         if (type!=null)
135         {
136             param_names_.add(name);
137             type.addRef();
138             param_types_.add(type);
139             param_modes_.add(new Integer JavaDoc(mode));
140         }
141     }
142
143     /**
144      **
145      **/

146     public String JavaDoc[]
147     getParamNames()
148     {
149         String JavaDoc[] result = new String JavaDoc[param_names_.size()];
150         for (int i=0;i<result.length;i++)
151         {
152             result[i] = (String JavaDoc)param_names_.get(i);
153         }
154         return result;
155     }
156
157     /**
158      **
159      **/

160     public int[]
161     getParamModes()
162     {
163         int[] result = new int[param_modes_.size()];
164         for (int i=0;i<result.length;i++)
165         {
166             result[i] = ((Integer JavaDoc)param_modes_.get(i)).intValue();
167         }
168         return result;
169     }
170
171     /**
172      **
173      **/

174     public TypeRef[]
175     getParamTypes()
176     {
177         TypeRef[] result = new TypeRef[param_types_.size()];
178         for (int i=0;i<result.length;i++)
179         {
180             result[i] = (TypeRef)param_types_.get(i);
181         }
182         return result;
183     }
184 }
185
Popular Tags