Dead
[official-gcc.git] / gomp-20050608-branch / libjava / classpath / gnu / CORBA / typecodes / ArrayTypeCode.java
blobbb798101a99f590c486344a1e8532aad29b414b0
1 /* ArrayTypeCode.java --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package gnu.CORBA.typecodes;
42 import org.omg.CORBA.TCKind;
43 import org.omg.CORBA.TypeCode;
44 import org.omg.CORBA.TypeCodePackage.BadKind;
46 /**
47 * A TypeCode for arrays.
48 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
50 public class ArrayTypeCode
51 extends PrimitiveTypeCode
53 /**
54 * Use serialVersionUID for interoperability.
56 private static final long serialVersionUID = 1;
59 /**
60 * The array components.
62 TypeCode of;
64 /**
65 * The length of the array, must be updated when setting
66 * a new value.
68 private int length;
70 /**
71 * Create a primitive array type code, defining the sequence
72 * {@link TCKind.tk_sequence)} with
73 * the given member type.
75 * @param array_of the sequence member type.
77 public ArrayTypeCode(TCKind array_of)
79 super(TCKind.tk_sequence);
80 of = new PrimitiveTypeCode(array_of);
83 /**
84 * Create a primitive array type code, defining the array, sequence
85 * or other type with the given member type.
87 * @param this_type the type of this type (normally either
88 * sequence of array).
89 * @param array_of the sequence member type.
91 public ArrayTypeCode(TCKind this_type, TypeCode array_of)
93 super(this_type);
94 of = array_of;
97 /**
98 * Return the array component type.
99 * @return the array component type
100 * @throws org.omg.CORBA.TypeCodePackage.BadKind
102 public TypeCode content_type()
103 throws org.omg.CORBA.TypeCodePackage.BadKind
105 return of;
109 * Return true if the other TypeCode defines the array, having elements
110 * of the same type. The sizes of arrays are not taken into
111 * consideration.
113 * @param other the other TypeCode
114 * @return true if <code>other</code> is an array with the same
115 * component type.
117 public boolean equal(TypeCode other)
121 return kind() == other.kind() &&
122 content_type() == other.content_type();
124 catch (BadKind ex)
126 // Should not be thrown.
127 return false;
132 * Returns the agreed Id in the form of
133 * <code>IDL:omg.org/CORBA/ {type name} Seq:1.0</code>.
135 * @return the Id of this TypeCode.
137 * @throws org.omg.CORBA.TypeCodePackage.BadKind if the content type
138 * is not one of the constants, defined in {@link TCKind}.
139 * This package class should not be used as TypeCode for the arrays,
140 * holding the user defined components.
142 public String id()
143 throws org.omg.CORBA.TypeCodePackage.BadKind
145 switch (content_type().kind().value())
147 case TCKind._tk_null :
148 return "IDL:omg.org/CORBA/NullSeq:1.0";
150 case TCKind._tk_void :
151 return "IDL:omg.org/CORBA/VoidSeq:1.0";
153 case TCKind._tk_short :
154 return "IDL:omg.org/CORBA/ShortSeq:1.0";
156 case TCKind._tk_long :
157 return "IDL:omg.org/CORBA/LongSeq:1.0";
159 case TCKind._tk_ushort :
160 return "IDL:omg.org/CORBA/UShortSeq:1.0";
162 case TCKind._tk_ulong :
163 return "IDL:omg.org/CORBA/ULongSeq:1.0";
165 case TCKind._tk_float :
166 return "IDL:omg.org/CORBA/FloatSeq:1.0";
168 case TCKind._tk_double :
169 return "IDL:omg.org/CORBA/DoubleSeq:1.0";
171 case TCKind._tk_boolean :
172 return "IDL:omg.org/CORBA/BooleanSeq:1.0";
174 case TCKind._tk_char :
175 return "IDL:omg.org/CORBA/CharSeq:1.0";
177 case TCKind._tk_octet :
178 return "IDL:omg.org/CORBA/OctetSeq:1.0";
180 case TCKind._tk_any :
181 return "IDL:omg.org/CORBA/AnySeq:1.0";
183 case TCKind._tk_TypeCode :
184 return "IDL:omg.org/CORBA/TypeCodeSeq:1.0";
186 case TCKind._tk_Principal :
187 return "IDL:omg.org/CORBA/PrincipalSeq:1.0";
189 case TCKind._tk_objref :
190 return "IDL:omg.org/CORBA/ObjrefSeq:1.0";
192 case TCKind._tk_struct :
193 return "IDL:omg.org/CORBA/StructSeq:1.0";
195 case TCKind._tk_union :
196 return "IDL:omg.org/CORBA/UnionSeq:1.0";
198 case TCKind._tk_enum :
199 return "IDL:omg.org/CORBA/EnumSeq:1.0";
201 case TCKind._tk_string :
202 return "IDL:omg.org/CORBA/StringSeq:1.0";
204 case TCKind._tk_sequence :
205 return "IDL:omg.org/CORBA/SequenceSeq:1.0";
207 case TCKind._tk_array :
208 return "IDL:omg.org/CORBA/ArraySeq:1.0";
210 case TCKind._tk_alias :
211 return "IDL:omg.org/CORBA/AliasSeq:1.0";
213 case TCKind._tk_except :
214 return "IDL:omg.org/CORBA/ExceptSeq:1.0";
216 case TCKind._tk_longlong :
217 return "IDL:omg.org/CORBA/LongLongSeq:1.0";
219 case TCKind._tk_ulonglong :
220 return "IDL:omg.org/CORBA/ULongLongSeq:1.0";
222 case TCKind._tk_longdouble :
223 return "IDL:omg.org/CORBA/LongDoubleSeq:1.0";
225 case TCKind._tk_wchar :
226 return "IDL:omg.org/CORBA/WCharSeq:1.0";
228 case TCKind._tk_wstring :
229 return "IDL:omg.org/CORBA/WStringSeq:1.0";
231 case TCKind._tk_fixed :
232 return "IDL:omg.org/CORBA/FixedSeq:1.0";
234 case TCKind._tk_value :
235 return "IDL:omg.org/CORBA/ValueSeq:1.0";
237 case TCKind._tk_value_box :
238 return "IDL:omg.org/CORBA/Value_boxSeq:1.0";
240 case TCKind._tk_native :
241 return "IDL:omg.org/CORBA/NativeSeq:1.0";
243 case TCKind._tk_abstract_interface :
244 return "IDL:omg.org/CORBA/Abstract_interfaceSeq:1.0";
246 default :
247 throw new BadKind();
252 * Return the array length.
253 * @return the length of the array.
254 * @throws org.omg.CORBA.TypeCodePackage.BadKind
256 public int length()
257 throws org.omg.CORBA.TypeCodePackage.BadKind
259 return length;
263 * Sets the array length to the supplied value.
265 * @param l the new length.
267 public void setLength(int l)
269 this.length = l;