Frames | No Frames |
1: /* DefinitionKind.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 org.omg.CORBA; 40: 41: import org.omg.CORBA.portable.IDLEntity; 42: 43: import java.io.Serializable; 44: 45: /** 46: * This class indicates the kind of the definition, stored in the interface 47: * repository. 48: * 49: * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) 50: */ 51: public class DefinitionKind 52: implements IDLEntity, Serializable 53: { 54: /** 55: * Use v1.4 serialVersionUID for interoperability. 56: */ 57: private static final long serialVersionUID = -8601167576704143376L; 58: 59: /** 60: * Indicates that the current definition defines has no definition kind. 61: */ 62: public static final int _dk_none = 0; 63: 64: /** 65: * This is a "wildcard '*'", used in cases where any definition kind 66: * is appropriate . 67: */ 68: public static final int _dk_all = 1; 69: 70: /** 71: * Indicates that the current definition defines an attribute. 72: */ 73: public static final int _dk_Attribute = 2; 74: 75: /** 76: * Indicates that the current definition defines a constant. 77: */ 78: public static final int _dk_Constant = 3; 79: 80: /** 81: * Indicates that the current definition defines an exception. 82: */ 83: public static final int _dk_Exception = 4; 84: 85: /** 86: * Indicates that the current definition defines an interface. 87: * The interface definition can contain constants, types, 88: * exceptions, operations, and attributes. 89: */ 90: public static final int _dk_Interface = 5; 91: 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. 97: */ 98: public static final int _dk_Module = 6; 99: 100: /** 101: * Indicates that the current definition defines an operation, including 102: * the lists of parameters and exceptions raised by this operation. 103: */ 104: public static final int _dk_Operation = 7; 105: 106: /** 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. 111: */ 112: public static final int _dk_Typedef = 8; 113: 114: /** 115: * Indicates that the current definition defines an alias. 116: */ 117: public static final int _dk_Alias = 9; 118: 119: /** 120: * Indicates that the current definition defines a structure. 121: */ 122: public static final int _dk_Struct = 10; 123: 124: /** 125: * Indicates that the current definition defines a union. 126: */ 127: public static final int _dk_Union = 11; 128: 129: /** 130: * Indicates that the current definition defines an enumeration. 131: */ 132: public static final int _dk_Enum = 12; 133: 134: /** 135: * Indicates that the current definition defines a primitive type. 136: */ 137: public static final int _dk_Primitive = 13; 138: 139: /** 140: * Indicates that the current definition defines a string. 141: */ 142: public static final int _dk_String = 14; 143: 144: /** 145: * Indicates that the current definition defines a sequence. 146: */ 147: public static final int _dk_Sequence = 15; 148: 149: /** 150: * Indicates that the current definition defines an array. 151: */ 152: public static final int _dk_Array = 16; 153: 154: /** 155: * Indicates that the current definition defines an another interface 156: * repository. 157: */ 158: public static final int _dk_Repository = 17; 159: 160: /** 161: * Indicates that the current definition defines a wide (usually 16-bit 162: * per character) string. 163: */ 164: public static final int _dk_Wstring = 18; 165: 166: /** 167: * Indicates that the current definition defines a CORBA <code>fixed</code>. 168: */ 169: public static final int _dk_Fixed = 19; 170: 171: /** 172: * Indicates that the current definition defines a value. 173: */ 174: public static final int _dk_Value = 20; 175: 176: /** 177: * Indicates that the current definition defines a value box. 178: */ 179: public static final int _dk_ValueBox = 21; 180: 181: /** 182: * Indicates that the current definition defines value member. 183: */ 184: public static final int _dk_ValueMember = 22; 185: 186: /** 187: * Indicates that the current definition defines a Native. 188: */ 189: public static final int _dk_Native = 23; 190: 191: /** 192: * Indicates that the current definition defines an abstract interface. 193: */ 194: public static final int _dk_AbstractInterface = 24; 195: 196: /** 197: * Indicates that the current definition defines has no definition kind. 198: */ 199: public static final DefinitionKind dk_none = new DefinitionKind(_dk_none); 200: 201: /** 202: * This is a "wildcard '*'", used in cases where any definition kind 203: * is appropriate . 204: */ 205: public static final DefinitionKind dk_all = new DefinitionKind(_dk_all); 206: 207: /** 208: * Indicates that the current definition defines an attribute. 209: */ 210: public static final DefinitionKind dk_Attribute = new DefinitionKind(_dk_Attribute); 211: 212: /** 213: * Indicates that the current definition defines a constant. 214: */ 215: public static final DefinitionKind dk_Constant = new DefinitionKind(_dk_Constant); 216: 217: /** 218: * Indicates that the current definition defines an exception. 219: */ 220: public static final DefinitionKind dk_Exception = new DefinitionKind(_dk_Exception); 221: 222: /** 223: * Indicates that the current definition defines an interface. 224: * The interface definition can contain constants, types, 225: * exceptions, operations, and attributes. 226: */ 227: public static final DefinitionKind dk_Interface = new DefinitionKind(_dk_Interface); 228: 229: /** 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. 234: */ 235: public static final DefinitionKind dk_Module = new DefinitionKind(_dk_Module); 236: 237: /** 238: * Indicates that the current definition defines an operation, including 239: * the lists of parameters and exceptions raised by this operation. 240: */ 241: public static final DefinitionKind dk_Operation = new DefinitionKind(_dk_Operation); 242: 243: /** 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. 248: */ 249: public static final DefinitionKind dk_Typedef = new DefinitionKind(_dk_Typedef); 250: 251: /** 252: * Indicates that the current definition defines an alias. 253: */ 254: public static final DefinitionKind dk_Alias = new DefinitionKind(_dk_Alias); 255: 256: /** 257: * Indicates that the current definition defines a structure. 258: */ 259: public static final DefinitionKind dk_Struct = new DefinitionKind(_dk_Struct); 260: 261: /** 262: * Indicates that the current definition defines a union. 263: */ 264: public static final DefinitionKind dk_Union = new DefinitionKind(_dk_Union); 265: 266: /** 267: * Indicates that the current definition defines an enumeration. 268: */ 269: public static final DefinitionKind dk_Enum = new DefinitionKind(_dk_Enum); 270: 271: /** 272: * Indicates that the current definition defines a primitive type. 273: */ 274: public static final DefinitionKind dk_Primitive = new DefinitionKind(_dk_Primitive); 275: 276: /** 277: * Indicates that the current definition defines a string. 278: */ 279: public static final DefinitionKind dk_String = new DefinitionKind(_dk_String); 280: 281: /** 282: * Indicates that the current definition defines a sequence. 283: */ 284: public static final DefinitionKind dk_Sequence = new DefinitionKind(_dk_Sequence); 285: 286: /** 287: * Indicates that the current definition defines an array. 288: */ 289: public static final DefinitionKind dk_Array = new DefinitionKind(_dk_Array); 290: 291: /** 292: * Indicates that the current definition defines an another interface 293: * repository. 294: */ 295: public static final DefinitionKind dk_Repository = 296: new DefinitionKind(_dk_Repository); 297: 298: /** 299: * Indicates that the current definition defines a wide (usually 16-bit 300: * per character) string. 301: */ 302: public static final DefinitionKind dk_Wstring = new DefinitionKind(_dk_Wstring); 303: 304: /** 305: * Indicates that the current definition defines a CORBA <code>fixed</code>. 306: */ 307: public static final DefinitionKind dk_Fixed = new DefinitionKind(_dk_Fixed); 308: 309: /** 310: * Indicates that the current definition defines a value. 311: */ 312: public static final DefinitionKind dk_Value = new DefinitionKind(_dk_Value); 313: 314: /** 315: * Indicates that the current definition defines a value box. 316: */ 317: public static final DefinitionKind dk_ValueBox = new DefinitionKind(_dk_ValueBox); 318: 319: /** 320: * Indicates that the current definition defines value member. 321: */ 322: public static final DefinitionKind dk_ValueMember = 323: new DefinitionKind(_dk_ValueMember); 324: 325: /** 326: * Indicates that the current definition defines a Native. 327: */ 328: public static final DefinitionKind dk_Native = new DefinitionKind(_dk_Native); 329: 330: /** 331: * Indicates that the current definition defines . 332: */ 333: public static final DefinitionKind dk_AbstractInterface = 334: new DefinitionKind(_dk_AbstractInterface); 335: 336: /** 337: * The defintion code of the current instance of the definition kind. 338: */ 339: private final int kind; 340: 341: /** 342: * The table of the definition kinds 343: */ 344: private static DefinitionKind[] table; 345: 346: /** 347: * Creates a definition kind with the given integer definition kind code. 348: * 349: * @param a_kind a definition kind code, one of the _dk_.. constants, 350: * defined in this class. 351: */ 352: protected DefinitionKind(int a_kind) 353: { 354: kind = a_kind; 355: } 356: 357: /** 358: * Get the definition code of the current instance of the definition kind. 359: * 360: * @return one of the _dk_... constants, defined in this class. 361: */ 362: public int value() 363: { 364: return kind; 365: } 366: 367: /** 368: * Get the definition kind, corresponding the given integer code. 369: * 370: * @param a_kind the definition kind code, one of the _dk_... constants, 371: * defined in this class. 372: * 373: * @return the corresponding definition kind, one of the dk_... constants, 374: * defined in this class. 375: * 376: * @throws BAD_PARAM if the given integer does not match any definition 377: * kind. 378: */ 379: public static DefinitionKind from_int(int a_kind) 380: { 381: if (table == null) 382: fill_table(); 383: try 384: { 385: return table [ a_kind ]; 386: } 387: catch (ArrayIndexOutOfBoundsException ex) 388: { 389: throw new BAD_PARAM("No def. kind " + a_kind); 390: } 391: } 392: 393: /** 394: * Fill the conversion table on demand. 395: */ 396: private static void fill_table() 397: { 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; 424: } 425: }