KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > Parameters


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.
23 Contributor(s): Mathieu Vadet, Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.ir3;
28
29 // Package dependencies
30
import org.omg.CORBA.*;
31
32 /**
33  * Implementation of the CORBA::ParameterDescription helper class.
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.4
39  */

40
41 public class Parameters
42      extends Members
43 {
44     // ==================================================================
45
//
46
// Internal state.
47
//
48
// ==================================================================
49

50     /** The parameter modes. */
51     protected ParameterMode[] modes_;
52
53     // ==================================================================
54
//
55
// Constructor.
56
//
57
// ==================================================================
58

59     /**
60      * TODO
61      */

62     public
63     Parameters(OperationDef_impl op)
64     {
65         super(op, null);
66         modes_ = new ParameterMode[0];
67     }
68
69     // ==================================================================
70
//
71
// Public methods.
72
//
73
// ==================================================================
74

75     /**
76      * Check parameter modess are only PARAM_IN.
77      */

78     public void
79     checkOnlyInModes()
80     {
81         for(int i=0; i<modes_.length; i++)
82             if(modes_[i] != ParameterMode.PARAM_IN)
83                throw contained_.exceptionNeedOnlyInParams();
84     }
85
86     /**
87      * Obtain as CORBA::ParameterDescriptionSeq
88      */

89     public ParameterDescription[]
90     getParameterDescriptionSeq()
91     {
92         ParameterDescription[] result =
93             new ParameterDescription[names_.length];
94
95         java.util.List JavaDoc idSeq = new java.util.ArrayList JavaDoc();
96         for(int i=0; i<result.length; i++)
97     {
98             idSeq.clear();
99             result[i] = new ParameterDescription();
100             result[i].name = names_[i];
101             // recompute the typecode of each member.
102
result[i].type = types_[i].recursiveType(idSeq);
103             result[i].type_def = types_[i].asIDLType();
104             result[i].mode = modes_[i];
105     }
106
107         return result;
108     }
109
110     /**
111      * Set as CORBA::ParameterDescriptionSeq
112      */

113     public void
114     setParameterDescriptionSeq(ParameterDescription[] val)
115     {
116         // duplicates members names.
117
String JavaDoc[] names = new String JavaDoc[val.length];
118         for (int i=0; i<val.length; i++)
119             names[i] = val[i].name;
120
121         checkNames(names);
122
123         // duplicates parameter modes.
124
ParameterMode[] modes = new ParameterMode[val.length];
125         for (int i=0; i<val.length; i++)
126             modes[i] = val[i].mode;
127
128         IRObject_impl[] types = new IRObject_impl[val.length];
129         for (int i=0; i<val.length; i++)
130             types[i] = contained_.castToLocal(val[i].type_def);
131
132         IDLType_ref[] refs = new IDLType_ref[val.length];
133         for (int i=0; i<val.length; i++)
134             refs[i] = new IDLType_ref( contained_, types[i] );
135
136         modes_ = modes;
137         super.setNamesTypes(names, refs);
138     }
139 }
140
Popular Tags