Merge from mainline.
[official-gcc.git] / libjava / classpath / org / omg / CORBA / DefinitionKind.java
blobac185bdacea9a6a8f84b9a4d3117b6c41096bf27
1 /* DefinitionKind.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 org.omg.CORBA;
41 import org.omg.CORBA.portable.IDLEntity;
43 import java.io.Serializable;
45 /**
46 * This class indicates the kind of the definition, stored in the interface
47 * repository.
49 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
51 public class DefinitionKind
52 implements IDLEntity, Serializable
54 /**
55 * Use v1.4 serialVersionUID for interoperability.
57 private static final long serialVersionUID = -8601167576704143376L;
59 /**
60 * Indicates that the current definition defines has no definition kind.
62 public static final int _dk_none = 0;
64 /**
65 * This is a "wildcard '*'", used in cases where any definition kind
66 * is appropriate .
68 public static final int _dk_all = 1;
70 /**
71 * Indicates that the current definition defines an attribute.
73 public static final int _dk_Attribute = 2;
75 /**
76 * Indicates that the current definition defines a constant.
78 public static final int _dk_Constant = 3;
80 /**
81 * Indicates that the current definition defines an exception.
83 public static final int _dk_Exception = 4;
85 /**
86 * Indicates that the current definition defines an interface.
87 * The interface definition can contain constants, types,
88 * exceptions, operations, and attributes.
90 public static final int _dk_Interface = 5;
92 /**
93 * Indicates that the current definition defines a Module.
94 * The Module can contain constants, typedefs, exceptions and also
95 * interface, component, home, value or event type definitions.
96 * The module can also enclose other (nested) modules.
98 public static final int _dk_Module = 6;
101 * Indicates that the current definition defines an operation, including
102 * the lists of parameters and exceptions raised by this operation.
104 public static final int _dk_Operation = 7;
107 * Indicates that the current definition defines a named type that is not
108 * an interface nor a value definition. Generally, it also cannot be
109 * a definition of component, home and event, but these three kinds are
110 * not listed in this class.
112 public static final int _dk_Typedef = 8;
115 * Indicates that the current definition defines an alias.
117 public static final int _dk_Alias = 9;
120 * Indicates that the current definition defines a structure.
122 public static final int _dk_Struct = 10;
125 * Indicates that the current definition defines a union.
127 public static final int _dk_Union = 11;
130 * Indicates that the current definition defines an enumeration.
132 public static final int _dk_Enum = 12;
135 * Indicates that the current definition defines a primitive type.
137 public static final int _dk_Primitive = 13;
140 * Indicates that the current definition defines a string.
142 public static final int _dk_String = 14;
145 * Indicates that the current definition defines a sequence.
147 public static final int _dk_Sequence = 15;
150 * Indicates that the current definition defines an array.
152 public static final int _dk_Array = 16;
155 * Indicates that the current definition defines an another interface
156 * repository.
158 public static final int _dk_Repository = 17;
161 * Indicates that the current definition defines a wide (usually 16-bit
162 * per character) string.
164 public static final int _dk_Wstring = 18;
167 * Indicates that the current definition defines a CORBA <code>fixed</code>.
169 public static final int _dk_Fixed = 19;
172 * Indicates that the current definition defines a value.
174 public static final int _dk_Value = 20;
177 * Indicates that the current definition defines a value box.
179 public static final int _dk_ValueBox = 21;
182 * Indicates that the current definition defines value member.
184 public static final int _dk_ValueMember = 22;
187 * Indicates that the current definition defines a Native.
189 public static final int _dk_Native = 23;
192 * Indicates that the current definition defines an abstract interface.
194 public static final int _dk_AbstractInterface = 24;
197 * Indicates that the current definition defines has no definition kind.
199 public static final DefinitionKind dk_none = new DefinitionKind(_dk_none);
202 * This is a "wildcard '*'", used in cases where any definition kind
203 * is appropriate .
205 public static final DefinitionKind dk_all = new DefinitionKind(_dk_all);
208 * Indicates that the current definition defines an attribute.
210 public static final DefinitionKind dk_Attribute = new DefinitionKind(_dk_Attribute);
213 * Indicates that the current definition defines a constant.
215 public static final DefinitionKind dk_Constant = new DefinitionKind(_dk_Constant);
218 * Indicates that the current definition defines an exception.
220 public static final DefinitionKind dk_Exception = new DefinitionKind(_dk_Exception);
223 * Indicates that the current definition defines an interface.
224 * The interface definition can contain constants, types,
225 * exceptions, operations, and attributes.
227 public static final DefinitionKind dk_Interface = new DefinitionKind(_dk_Interface);
230 * Indicates that the current definition defines a Module.
231 * The Module can contain constants, typedefs, exceptions and also
232 * interface, component, home, value or event type definitions.
233 * The module can also enclose other (nested) modules.
235 public static final DefinitionKind dk_Module = new DefinitionKind(_dk_Module);
238 * Indicates that the current definition defines an operation, including
239 * the lists of parameters and exceptions raised by this operation.
241 public static final DefinitionKind dk_Operation = new DefinitionKind(_dk_Operation);
244 * Indicates that the current definition defines a named type that is not
245 * an interface nor a value definition. Generally, it also cannot be
246 * a definition of component, home and event, but these three kinds are
247 * not listed in this class.
249 public static final DefinitionKind dk_Typedef = new DefinitionKind(_dk_Typedef);
252 * Indicates that the current definition defines an alias.
254 public static final DefinitionKind dk_Alias = new DefinitionKind(_dk_Alias);
257 * Indicates that the current definition defines a structure.
259 public static final DefinitionKind dk_Struct = new DefinitionKind(_dk_Struct);
262 * Indicates that the current definition defines a union.
264 public static final DefinitionKind dk_Union = new DefinitionKind(_dk_Union);
267 * Indicates that the current definition defines an enumeration.
269 public static final DefinitionKind dk_Enum = new DefinitionKind(_dk_Enum);
272 * Indicates that the current definition defines a primitive type.
274 public static final DefinitionKind dk_Primitive = new DefinitionKind(_dk_Primitive);
277 * Indicates that the current definition defines a string.
279 public static final DefinitionKind dk_String = new DefinitionKind(_dk_String);
282 * Indicates that the current definition defines a sequence.
284 public static final DefinitionKind dk_Sequence = new DefinitionKind(_dk_Sequence);
287 * Indicates that the current definition defines an array.
289 public static final DefinitionKind dk_Array = new DefinitionKind(_dk_Array);
292 * Indicates that the current definition defines an another interface
293 * repository.
295 public static final DefinitionKind dk_Repository =
296 new DefinitionKind(_dk_Repository);
299 * Indicates that the current definition defines a wide (usually 16-bit
300 * per character) string.
302 public static final DefinitionKind dk_Wstring = new DefinitionKind(_dk_Wstring);
305 * Indicates that the current definition defines a CORBA <code>fixed</code>.
307 public static final DefinitionKind dk_Fixed = new DefinitionKind(_dk_Fixed);
310 * Indicates that the current definition defines a value.
312 public static final DefinitionKind dk_Value = new DefinitionKind(_dk_Value);
315 * Indicates that the current definition defines a value box.
317 public static final DefinitionKind dk_ValueBox = new DefinitionKind(_dk_ValueBox);
320 * Indicates that the current definition defines value member.
322 public static final DefinitionKind dk_ValueMember =
323 new DefinitionKind(_dk_ValueMember);
326 * Indicates that the current definition defines a Native.
328 public static final DefinitionKind dk_Native = new DefinitionKind(_dk_Native);
331 * Indicates that the current definition defines .
333 public static final DefinitionKind dk_AbstractInterface =
334 new DefinitionKind(_dk_AbstractInterface);
337 * The defintion code of the current instance of the definition kind.
339 private final int kind;
342 * The table of the definition kinds
344 private static DefinitionKind[] table;
347 * Creates a definition kind with the given integer definition kind code.
349 * @param a_kind a definition kind code, one of the _dk_.. constants,
350 * defined in this class.
352 protected DefinitionKind(int a_kind)
354 kind = a_kind;
358 * Get the definition code of the current instance of the definition kind.
360 * @return one of the _dk_... constants, defined in this class.
362 public int value()
364 return kind;
368 * Get the definition kind, corresponding the given integer code.
370 * @param a_kind the definition kind code, one of the _dk_... constants,
371 * defined in this class.
373 * @return the corresponding definition kind, one of the dk_... constants,
374 * defined in this class.
376 * @throws BAD_PARAM if the given integer does not match any definition
377 * kind.
379 public static DefinitionKind from_int(int a_kind)
381 if (table == null)
382 fill_table();
385 return table [ a_kind ];
387 catch (ArrayIndexOutOfBoundsException ex)
389 throw new BAD_PARAM("No def. kind " + a_kind);
394 * Fill the conversion table on demand.
396 private static void fill_table()
398 table = new DefinitionKind[ 25 ];
399 table [ _dk_none ] = dk_none;
400 table [ _dk_all ] = dk_all;
401 table [ _dk_Attribute ] = dk_Attribute;
402 table [ _dk_Constant ] = dk_Constant;
403 table [ _dk_Exception ] = dk_Exception;
404 table [ _dk_Interface ] = dk_Interface;
405 table [ _dk_Module ] = dk_Module;
406 table [ _dk_Operation ] = dk_Operation;
407 table [ _dk_Typedef ] = dk_Typedef;
408 table [ _dk_Alias ] = dk_Alias;
409 table [ _dk_Struct ] = dk_Struct;
410 table [ _dk_Union ] = dk_Union;
411 table [ _dk_Enum ] = dk_Enum;
412 table [ _dk_Primitive ] = dk_Primitive;
413 table [ _dk_String ] = dk_String;
414 table [ _dk_Sequence ] = dk_Sequence;
415 table [ _dk_Array ] = dk_Array;
416 table [ _dk_Repository ] = dk_Repository;
417 table [ _dk_Wstring ] = dk_Wstring;
418 table [ _dk_Fixed ] = dk_Fixed;
419 table [ _dk_Value ] = dk_Value;
420 table [ _dk_ValueBox ] = dk_ValueBox;
421 table [ _dk_ValueMember ] = dk_ValueMember;
422 table [ _dk_Native ] = dk_Native;
423 table [ _dk_AbstractInterface ] = dk_AbstractInterface;