OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [gnu/] [CORBA/] [typecodes/] [ArrayTypeCode.java] - Blame information for rev 769

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 769 jeremybenn
/* ArrayTypeCode.java --
2
   Copyright (C) 2005 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
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.
10
 
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.
15
 
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.
20
 
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.
25
 
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. */
37
 
38
 
39
package gnu.CORBA.typecodes;
40
 
41
 
42
import org.omg.CORBA.TCKind;
43
import org.omg.CORBA.TypeCode;
44
import org.omg.CORBA.TypeCodePackage.BadKind;
45
 
46
/**
47
 * A TypeCode for arrays.
48
 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
49
 */
50
public class ArrayTypeCode
51
  extends PrimitiveTypeCode
52
{
53
  /**
54
   * Use serialVersionUID for interoperability.
55
   */
56
  private static final long serialVersionUID = 1;
57
 
58
 
59
  /**
60
   * The array components.
61
   */
62
  TypeCode of;
63
 
64
  /**
65
   * The length of the array, must be updated when setting
66
   * a new value.
67
   */
68
  private int length;
69
 
70
  /**
71
   * Create a primitive array type code, defining the sequence
72
   * {@link TCKind.tk_sequence)} with
73
   * the given member type.
74
   *
75
   * @param array_of the sequence member type.
76
   */
77
  public ArrayTypeCode(TCKind array_of)
78
  {
79
    super(TCKind.tk_sequence);
80
    of = new PrimitiveTypeCode(array_of);
81
  }
82
 
83
  /**
84
   * Create a primitive array type code, defining the array, sequence
85
   * or other type  with the given member type.
86
   *
87
   * @param this_type the type of this type (normally either
88
   * sequence of array).
89
   * @param array_of the sequence member type.
90
   */
91
  public ArrayTypeCode(TCKind this_type, TypeCode array_of)
92
  {
93
    super(this_type);
94
    of = array_of;
95
  }
96
 
97
  /**
98
   * Return the array component type.
99
   * @return the array component type
100
   * @throws org.omg.CORBA.TypeCodePackage.BadKind
101
   */
102
  public TypeCode content_type()
103
                        throws org.omg.CORBA.TypeCodePackage.BadKind
104
  {
105
    return of;
106
  }
107
 
108
  /**
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.
112
   *
113
   * @param other the other TypeCode
114
   * @return true if <code>other</code> is an array with the same
115
   * component type.
116
   */
117
  public boolean equal(TypeCode other)
118
  {
119
    try
120
      {
121
        return kind() == other.kind() &&
122
               content_type() == other.content_type();
123
      }
124
    catch (BadKind ex)
125
      {
126
        // Should not be thrown.
127
        return false;
128
      }
129
  }
130
 
131
  /**
132
   * Returns the agreed Id in the form of
133
   * <code>IDL:omg.org/CORBA/ {type name} Seq:1.0</code>.
134
   *
135
   * @return the Id of this TypeCode.
136
   *
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.
141
   */
142
  public String id()
143
            throws org.omg.CORBA.TypeCodePackage.BadKind
144
  {
145
    switch (content_type().kind().value())
146
      {
147
        case TCKind._tk_null :
148
          return "IDL:omg.org/CORBA/NullSeq:1.0";
149
 
150
        case TCKind._tk_void :
151
          return "IDL:omg.org/CORBA/VoidSeq:1.0";
152
 
153
        case TCKind._tk_short :
154
          return "IDL:omg.org/CORBA/ShortSeq:1.0";
155
 
156
        case TCKind._tk_long :
157
          return "IDL:omg.org/CORBA/LongSeq:1.0";
158
 
159
        case TCKind._tk_ushort :
160
          return "IDL:omg.org/CORBA/UShortSeq:1.0";
161
 
162
        case TCKind._tk_ulong :
163
          return "IDL:omg.org/CORBA/ULongSeq:1.0";
164
 
165
        case TCKind._tk_float :
166
          return "IDL:omg.org/CORBA/FloatSeq:1.0";
167
 
168
        case TCKind._tk_double :
169
          return "IDL:omg.org/CORBA/DoubleSeq:1.0";
170
 
171
        case TCKind._tk_boolean :
172
          return "IDL:omg.org/CORBA/BooleanSeq:1.0";
173
 
174
        case TCKind._tk_char :
175
          return "IDL:omg.org/CORBA/CharSeq:1.0";
176
 
177
        case TCKind._tk_octet :
178
          return "IDL:omg.org/CORBA/OctetSeq:1.0";
179
 
180
        case TCKind._tk_any :
181
          return "IDL:omg.org/CORBA/AnySeq:1.0";
182
 
183
        case TCKind._tk_TypeCode :
184
          return "IDL:omg.org/CORBA/TypeCodeSeq:1.0";
185
 
186
        case TCKind._tk_Principal :
187
          return "IDL:omg.org/CORBA/PrincipalSeq:1.0";
188
 
189
        case TCKind._tk_objref :
190
          return "IDL:omg.org/CORBA/ObjrefSeq:1.0";
191
 
192
        case TCKind._tk_struct :
193
          return "IDL:omg.org/CORBA/StructSeq:1.0";
194
 
195
        case TCKind._tk_union :
196
          return "IDL:omg.org/CORBA/UnionSeq:1.0";
197
 
198
        case TCKind._tk_enum :
199
          return "IDL:omg.org/CORBA/EnumSeq:1.0";
200
 
201
        case TCKind._tk_string :
202
          return "IDL:omg.org/CORBA/StringSeq:1.0";
203
 
204
        case TCKind._tk_sequence :
205
          return "IDL:omg.org/CORBA/SequenceSeq:1.0";
206
 
207
        case TCKind._tk_array :
208
          return "IDL:omg.org/CORBA/ArraySeq:1.0";
209
 
210
        case TCKind._tk_alias :
211
          return "IDL:omg.org/CORBA/AliasSeq:1.0";
212
 
213
        case TCKind._tk_except :
214
          return "IDL:omg.org/CORBA/ExceptSeq:1.0";
215
 
216
        case TCKind._tk_longlong :
217
          return "IDL:omg.org/CORBA/LongLongSeq:1.0";
218
 
219
        case TCKind._tk_ulonglong :
220
          return "IDL:omg.org/CORBA/ULongLongSeq:1.0";
221
 
222
        case TCKind._tk_longdouble :
223
          return "IDL:omg.org/CORBA/LongDoubleSeq:1.0";
224
 
225
        case TCKind._tk_wchar :
226
          return "IDL:omg.org/CORBA/WCharSeq:1.0";
227
 
228
        case TCKind._tk_wstring :
229
          return "IDL:omg.org/CORBA/WStringSeq:1.0";
230
 
231
        case TCKind._tk_fixed :
232
          return "IDL:omg.org/CORBA/FixedSeq:1.0";
233
 
234
        case TCKind._tk_value :
235
          return "IDL:omg.org/CORBA/ValueSeq:1.0";
236
 
237
        case TCKind._tk_value_box :
238
          return "IDL:omg.org/CORBA/Value_boxSeq:1.0";
239
 
240
        case TCKind._tk_native :
241
          return "IDL:omg.org/CORBA/NativeSeq:1.0";
242
 
243
        case TCKind._tk_abstract_interface :
244
          return "IDL:omg.org/CORBA/Abstract_interfaceSeq:1.0";
245
 
246
        default :
247
          throw new BadKind();
248
      }
249
  }
250
 
251
  /**
252
   * Return the array length.
253
   * @return the length of the array.
254
   * @throws org.omg.CORBA.TypeCodePackage.BadKind
255
   */
256
  public int length()
257
             throws org.omg.CORBA.TypeCodePackage.BadKind
258
  {
259
    return length;
260
  }
261
 
262
  /**
263
   * Sets the array length to the supplied value.
264
   *
265
   * @param l the new length.
266
   */
267
  public void setLength(int l)
268
  {
269
    this.length = l;
270
  }
271
 
272
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.