KickJava   Java API By Example, From Geeks To Geeks.

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


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::StructMemberSeq 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 StructMembers
42      extends Members
43 {
44     // ==================================================================
45
//
46
// Internal state.
47
//
48
// ==================================================================
49

50     // ==================================================================
51
//
52
// Constructor.
53
//
54
// ==================================================================
55

56     /** TODO */
57     public
58     StructMembers(Contained_impl contained,
59                   Container_impl container)
60     {
61         super(contained, container);
62     }
63
64     // ==================================================================
65
//
66
// Public methods.
67
//
68
// ==================================================================
69

70     /**
71      * Obtain as CORBA::StructMemberSeq
72      */

73     public StructMember[]
74     getStructMemberSeq(java.util.List JavaDoc idSeq)
75     {
76         StructMember[] result = new StructMember[names_.length];
77
78         for(int i=0; i<result.length; i++)
79     {
80             result[i] = new StructMember();
81             result[i].name = names_[i];
82             // recompute the typecode of each member.
83
result[i].type = types_[i].recursiveType(idSeq);
84             result[i].type_def = types_[i].asIDLType();
85     }
86
87         return result;
88     }
89
90     /**
91      * Obtain as CORBA::StructMemberSeq
92      */

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

115     public void
116     setStructMemberSeq(StructMember[] val)
117     {
118         // duplicates members names.
119
String JavaDoc[] names = new String JavaDoc[val.length];
120         for (int i=0; i<val.length; i++)
121             names[i] = val[i].name;
122
123         checkNames(names);
124
125         IRObject_impl[] types = new IRObject_impl[val.length];
126         for (int i=0; i<val.length; i++)
127             types[i] = contained_.castToLocal(val[i].type_def);
128
129         IDLType_ref[] refs = new IDLType_ref[val.length];
130         for (int i=0; i<val.length; i++)
131             refs[i] = new IDLType_ref( container_, types[i] );
132
133         super.setNamesTypes(names, refs);
134     }
135 }
136
Popular Tags