1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package org.omg.CORBA;
  27 
  28 
  29 /**
  30  * The Java mapping of the IDL enum <code>TCKind</code>, which
  31  * specifies the kind of a <code>TypeCode</code> object.  There is
  32  * one kind for each primitive and essential IDL data type.
  33  * <P>
  34  * The class <code>TCKind</code> consists of:
  35  * <UL>
  36  * <LI>a set of <code>int</code> constants, one for each
  37  * kind of IDL data type.  These <code>int</code> constants
  38  * make it possible to use a <code>switch</code> statement.
  39  * <LI>a set of <code>TCKind</code> constants, one for each
  40  * kind of IDL data type.  The <code>value</code> field for
  41  * each <code>TCKind</code> instance is initialized with
  42  * the <code>int</code> constant that corresponds with
  43  * the IDL data type that the instance represents.
  44  * <LI>the method <code>from_int</code>for converting
  45  * an <code>int</code> to its
  46  * corresponding <code>TCKind</code> instance
  47  * <P>Example:
  48  * <PRE>
  49  *      org.omg.CORBA.TCKind k = org.omg.CORBA.TCKind.from_int(
  50  *                         org.omg.CORBA.TCKind._tk_string);
  51  * </PRE>
  52  * The variable <code>k</code> represents the <code>TCKind</code>
  53  * instance for the IDL type <code>string</code>, which is
  54  * <code>tk_string</code>.
  55  *
  56  * <LI>the method <code>value</code> for accessing the
  57  * <code>_value</code> field of a <code>TCKind</code> constant
  58  * <P>Example:
  59  * <PRE>
  60  *   int i = org.omg.CORBA.TCKind.tk_char.value();
  61  * </PRE>
  62  * The variable <code>i</code> represents 9, the value for the
  63  * IDL data type <code>char</code>.
  64  * </UL>
  65  * <P>The <code>value</code> field of a <code>TCKind</code> instance
  66  * is the CDR encoding used for a <code>TypeCode</code> object in
  67  * an IIOP message.
  68  */
  69 
  70 public class TCKind {
  71 
  72     /**
  73      * The <code>int</code> constant for a <code>null</code> IDL data type.
  74      */
  75     public static final int _tk_null = 0;
  76 
  77     /**
  78      * The <code>int</code> constant for the IDL data type <code>void</code>.
  79      */
  80     public static final int _tk_void = 1;
  81 
  82     /**
  83      * The <code>int</code> constant for the IDL data type <code>short</code>.
  84      */
  85     public static final int _tk_short = 2;
  86 
  87     /**
  88      * The <code>int</code> constant for the IDL data type <code>long</code>.
  89      */
  90     public static final int _tk_long = 3;
  91 
  92     /**
  93      * The <code>int</code> constant for the IDL data type <code>ushort</code>.
  94      */
  95     public static final int _tk_ushort = 4;
  96 
  97     /**
  98      * The <code>int</code> constant for the IDL data type <code>ulong</code>.
  99      */
 100     public static final int _tk_ulong = 5;
 101 
 102     /**
 103      * The <code>int</code> constant for the IDL data type <code>float</code>.
 104      */
 105     public static final int _tk_float = 6;
 106 
 107     /**
 108      * The <code>int</code> constant for the IDL data type <code>double</code>.
 109      */
 110     public static final int _tk_double = 7;
 111 
 112     /**
 113      * The <code>int</code> constant for the IDL data type <code>boolean</code>.
 114      */
 115     public static final int _tk_boolean = 8;
 116 
 117     /**
 118      * The <code>int</code> constant for the IDL data type <code>char</code>.
 119      */
 120     public static final int _tk_char = 9;
 121 
 122     /**
 123      * The <code>int</code> constant for the IDL data type <code>octet</code>.
 124      */
 125     public static final int _tk_octet = 10;
 126 
 127     /**
 128      * The <code>int</code> constant for the IDL data type <code>any</code>.
 129      */
 130     public static final int _tk_any = 11;
 131 
 132     /**
 133      * The <code>int</code> constant for the IDL data type <code>TypeCode</code>.
 134      */
 135     public static final int _tk_TypeCode = 12;
 136 
 137     /**
 138      * The <code>int</code> constant for the IDL data type <code>Principal</code>.
 139      */
 140     public static final int _tk_Principal = 13;
 141 
 142     /**
 143      * The <code>int</code> constant for the IDL data type <code>objref</code>.
 144      */
 145     public static final int _tk_objref = 14;
 146 
 147     /**
 148      * The <code>int</code> constant for the IDL data type <code>struct</code>.
 149      */
 150     public static final int _tk_struct = 15;
 151 
 152     /**
 153      * The <code>int</code> constant for the IDL data type <code>union</code>.
 154      */
 155     public static final int _tk_union = 16;
 156 
 157     /**
 158      * The <code>int</code> constant for the IDL data type <code>enum</code>.
 159      */
 160     public static final int _tk_enum = 17;
 161 
 162     /**
 163      * The <code>int</code> constant for the IDL data type <code>string</code>.
 164      */
 165     public static final int _tk_string = 18;
 166 
 167     /**
 168      * The <code>int</code> constant for the IDL data type <code>sequence</code>.
 169      */
 170     public static final int _tk_sequence = 19;
 171 
 172     /**
 173      * The <code>int</code> constant for the IDL data type <code>array</code>.
 174      */
 175     public static final int _tk_array = 20;
 176 
 177     /**
 178      * The <code>int</code> constant for the IDL data type <code>alias</code>.
 179      */
 180     public static final int _tk_alias = 21;
 181 
 182     /**
 183      * The <code>int</code> constant for the IDL data type <code>except</code>.
 184      */
 185     public static final int _tk_except = 22;
 186 
 187     /**
 188      * The <code>int</code> constant for the IDL data type <code>longlong</code>.
 189      */
 190     public static final int _tk_longlong = 23;
 191 
 192     /**
 193      * The <code>int</code> constant for the IDL data type <code>ulonglong</code>.
 194      */
 195     public static final int _tk_ulonglong = 24;
 196 
 197     /**
 198      * The <code>int</code> constant for the IDL data type <code>longdouble</code>.
 199      */
 200     public static final int _tk_longdouble = 25;
 201 
 202     /**
 203      * The <code>int</code> constant for the IDL data type <code>wchar</code>.
 204      */
 205     public static final int _tk_wchar = 26;
 206 
 207     /**
 208      * The <code>int</code> constant for the IDL data type <code>wstring</code>.
 209      */
 210     public static final int _tk_wstring = 27;
 211 
 212     /**
 213      * The <code>int</code> constant for the IDL data type <code>fixed</code>.
 214      */
 215     public static final int _tk_fixed = 28;
 216 
 217     /**
 218      * The <code>int</code> constant for the IDL data type <code>value</code>.
 219      */
 220     public static final int _tk_value = 29;             // orbos 98-01-18: Objects By Value
 221 
 222     /**
 223      * The <code>int</code> constant for the IDL data type <code>value_box</code>.
 224      */
 225     public static final int _tk_value_box = 30; // orbos 98-01-18: Objects By Value
 226 
 227     /**
 228      * The <code>int</code> constant for the IDL data type <code>native</code>.
 229      */
 230     public static final int _tk_native = 31;        // Verify
 231 
 232     /**
 233      * The <code>int</code> constant for the IDL data type <code>abstract interface</code>.
 234      */
 235     public static final int _tk_abstract_interface = 32;
 236 
 237 
 238     /**
 239      * The <code>TCKind</code> constant whose <code>value</code> field is
 240      * initialized with <code>TCKind._tk_null</code>.
 241      */
 242     public static final TCKind tk_null = new TCKind(_tk_null);
 243 
 244     /**
 245      * The <code>TCKind</code> constant whose <code>value</code> field is
 246      * initialized with <code>TCKind._tk_void</code>.
 247      */
 248     public static final TCKind tk_void = new TCKind(_tk_void);
 249 
 250     /**
 251      * The <code>TCKind</code> constant whose <code>value</code> field is
 252      * initialized with <code>TCKind._tk_short</code>.
 253      */
 254     public static final TCKind tk_short = new TCKind(_tk_short);
 255 
 256     /**
 257      * The <code>TCKind</code> constant whose <code>value</code> field is
 258      * initialized with <code>TCKind._tk_long</code>.
 259      */
 260     public static final TCKind tk_long = new TCKind(_tk_long);
 261 
 262     /**
 263      * The <code>TCKind</code> constant whose <code>value</code> field is
 264      * initialized with <code>TCKind._tk_ushort</code>.
 265      */
 266     public static final TCKind tk_ushort = new TCKind(_tk_ushort);
 267 
 268     /**
 269      * The <code>TCKind</code> constant whose <code>value</code> field is
 270      * initialized with <code>TCKind._tk_ulong</code>.
 271      */
 272     public static final TCKind tk_ulong = new TCKind(_tk_ulong);
 273 
 274     /**
 275      * The <code>TCKind</code> constant whose <code>value</code> field is
 276      * initialized with <code>TCKind._tk_float</code>.
 277      */
 278     public static final TCKind tk_float = new TCKind(_tk_float);
 279 
 280     /**
 281      * The <code>TCKind</code> constant whose <code>value</code> field is
 282      * initialized with <code>TCKind._tk_double</code>.
 283      */
 284     public static final TCKind tk_double = new TCKind(_tk_double);
 285 
 286     /**
 287      * The <code>TCKind</code> constant whose <code>value</code> field is
 288      * initialized with <code>TCKind._tk_boolean</code>.
 289      */
 290     public static final TCKind tk_boolean = new TCKind(_tk_boolean);
 291 
 292     /**
 293      * The <code>TCKind</code> constant whose <code>value</code> field is
 294      * initialized with <code>TCKind._tk_char</code>.
 295      */
 296     public static final TCKind tk_char = new TCKind(_tk_char);
 297 
 298     /**
 299      * The <code>TCKind</code> constant whose <code>value</code> field is
 300      * initialized with <code>TCKind._tk_octet</code>.
 301      */
 302     public static final TCKind tk_octet = new TCKind(_tk_octet);
 303 
 304     /**
 305      * The <code>TCKind</code> constant whose <code>value</code> field is
 306      * initialized with <code>TCKind._tk_any</code>.
 307      */
 308     public static final TCKind tk_any = new TCKind(_tk_any);
 309 
 310     /**
 311      * The <code>TCKind</code> constant whose <code>value</code> field is
 312      * initialized with <code>TCKind._tk_TypeCode</code>.
 313      */
 314     public static final TCKind tk_TypeCode = new TCKind(_tk_TypeCode);
 315 
 316     /**
 317      * The <code>TCKind</code> constant whose <code>value</code> field is
 318      * initialized with <code>TCKind._tk_Principal</code>.
 319      */
 320     public static final TCKind tk_Principal = new TCKind(_tk_Principal);
 321 
 322     /**
 323      * The <code>TCKind</code> constant whose <code>value</code> field is
 324      * initialized with <code>TCKind._tk_objref</code>.
 325      */
 326     public static final TCKind tk_objref = new TCKind(_tk_objref);
 327 
 328     /**
 329      * The <code>TCKind</code> constant whose <code>value</code> field is
 330      * initialized with <code>TCKind._tk_struct</code>.
 331      */
 332     public static final TCKind tk_struct = new TCKind(_tk_struct);
 333 
 334     /**
 335      * The <code>TCKind</code> constant whose <code>value</code> field is
 336      * initialized with <code>TCKind._tk_union</code>.
 337      */
 338     public static final TCKind tk_union = new TCKind(_tk_union);
 339 
 340     /**
 341      * The <code>TCKind</code> constant whose <code>value</code> field is
 342      * initialized with <code>TCKind._tk_enum</code>.
 343      */
 344     public static final TCKind tk_enum = new TCKind(_tk_enum);
 345 
 346     /**
 347      * The <code>TCKind</code> constant whose <code>value</code> field is
 348      * initialized with <code>TCKind._tk_string</code>.
 349      */
 350     public static final TCKind tk_string = new TCKind(_tk_string);
 351 
 352     /**
 353      * The <code>TCKind</code> constant whose <code>value</code> field is
 354      * initialized with <code>TCKind._tk_sequence</code>.
 355      */
 356     public static final TCKind tk_sequence = new TCKind(_tk_sequence);
 357 
 358     /**
 359      * The <code>TCKind</code> constant whose <code>value</code> field is
 360      * initialized with <code>TCKind._tk_array</code>.
 361      */
 362     public static final TCKind tk_array = new TCKind(_tk_array);
 363 
 364     /**
 365      * The <code>TCKind</code> constant whose <code>value</code> field is
 366      * initialized with <code>TCKind._tk_alias</code>.
 367      */
 368     public static final TCKind tk_alias = new TCKind(_tk_alias);
 369 
 370     /**
 371      * The <code>TCKind</code> constant whose <code>value</code> field is
 372      * initialized with <code>TCKind._tk_except</code>.
 373      */
 374     public static final TCKind tk_except = new TCKind(_tk_except);
 375 
 376     /**
 377      * The <code>TCKind</code> constant whose <code>value</code> field is
 378      * initialized with <code>TCKind._tk_longlong</code>.
 379      */
 380     public static final TCKind tk_longlong = new TCKind(_tk_longlong);
 381 
 382     /**
 383      * The <code>TCKind</code> constant whose <code>value</code> field is
 384      * initialized with <code>TCKind._tk_ulonglong</code>.
 385      */
 386     public static final TCKind tk_ulonglong = new TCKind(_tk_ulonglong);
 387 
 388     /**
 389      * The <code>TCKind</code> constant whose <code>value</code> field is
 390      * initialized with <code>TCKind._tk_longdouble</code>.
 391      */
 392     public static final TCKind tk_longdouble = new TCKind(_tk_longdouble);
 393 
 394     /**
 395      * The <code>TCKind</code> constant whose <code>value</code> field is
 396      * initialized with <code>TCKind._tk_wchar</code>.
 397      */
 398     public static final TCKind tk_wchar = new TCKind(_tk_wchar);
 399 
 400     /**
 401      * The <code>TCKind</code> constant whose <code>value</code> field is
 402      * initialized with <code>TCKind._tk_wstring</code>.
 403      */
 404     public static final TCKind tk_wstring = new TCKind(_tk_wstring);
 405 
 406     /**
 407      * The <code>TCKind</code> constant whose <code>value</code> field is
 408      * initialized with <code>TCKind._tk_fixed</code>.
 409      */
 410     public static final TCKind tk_fixed = new TCKind(_tk_fixed);
 411 
 412     // orbos 98-01-18: Objects By Value -- begin
 413 
 414     /**
 415      * The <code>TCKind</code> constant whose <code>value</code> field is
 416      * initialized with <code>TCKind._tk_value</code>.
 417      */
 418     public static final TCKind tk_value = new TCKind(_tk_value);
 419 
 420     /**
 421      * The <code>TCKind</code> constant whose <code>value</code> field is
 422      * initialized with <code>TCKind._tk_value_box</code>.
 423      */
 424     public static final TCKind tk_value_box = new TCKind(_tk_value_box);
 425     // orbos 98-01-18: Objects By Value -- end
 426 
 427     /**
 428      * The <code>TCKind</code> constant whose <code>value</code> field is
 429      * initialized with <code>TCKind._tk_native</code>.
 430      */
 431     public static final TCKind tk_native = new TCKind(_tk_native);
 432 
 433     /**
 434      * The <code>TCKind</code> constant whose <code>value</code> field is
 435      * initialized with <code>TCKind._tk_abstract_interface</code>.
 436      */
 437     public static final TCKind tk_abstract_interface = new TCKind(_tk_abstract_interface);
 438 
 439 
 440 
 441 
 442     /**
 443      * Retrieves the value of this <code>TCKind</code> instance.
 444      *
 445      * @return  the <code>int</code> that represents the kind of
 446      * IDL data type for this <code>TCKind</code> instance
 447      */
 448     public int value() {
 449         return _value;
 450     }
 451 
 452     /**
 453      * Converts the given <code>int</code> to the corresponding
 454      * <code>TCKind</code> instance.
 455      *
 456      * @param i the <code>int</code> to convert.  It must be one of
 457      *         the <code>int</code> constants in the class
 458      *         <code>TCKind</code>.
 459      * @return  the <code>TCKind</code> instance whose <code>value</code>
 460      * field matches the given <code>int</code>
 461      * @exception  BAD_PARAM  if the given <code>int</code> does not
 462      * match the <code>_value</code> field of
 463      * any <code>TCKind</code> instance
 464      */
 465     public static TCKind from_int(int i) {
 466         switch (i) {
 467         case _tk_null:
 468             return tk_null;
 469         case _tk_void:
 470             return tk_void;
 471         case _tk_short:
 472             return tk_short;
 473         case _tk_long:
 474             return tk_long;
 475         case _tk_ushort:
 476             return tk_ushort;
 477         case _tk_ulong:
 478             return tk_ulong;
 479         case _tk_float:
 480             return tk_float;
 481         case _tk_double:
 482             return tk_double;
 483         case _tk_boolean:
 484             return tk_boolean;
 485         case _tk_char:
 486             return tk_char;
 487         case _tk_octet:
 488             return tk_octet;
 489         case _tk_any:
 490             return tk_any;
 491         case _tk_TypeCode:
 492             return tk_TypeCode;
 493         case _tk_Principal:
 494             return tk_Principal;
 495         case _tk_objref:
 496             return tk_objref;
 497         case _tk_struct:
 498             return tk_struct;
 499         case _tk_union:
 500             return tk_union;
 501         case _tk_enum:
 502             return tk_enum;
 503         case _tk_string:
 504             return tk_string;
 505         case _tk_sequence:
 506             return tk_sequence;
 507         case _tk_array:
 508             return tk_array;
 509         case _tk_alias:
 510             return tk_alias;
 511         case _tk_except:
 512             return tk_except;
 513         case _tk_longlong:
 514             return tk_longlong;
 515         case _tk_ulonglong:
 516             return tk_ulonglong;
 517         case _tk_longdouble:
 518             return tk_longdouble;
 519         case _tk_wchar:
 520             return tk_wchar;
 521         case _tk_wstring:
 522             return tk_wstring;
 523         case _tk_fixed:
 524             return tk_fixed;
 525         case _tk_value:         // orbos 98-01-18: Objects By Value
 526             return tk_value;
 527         case _tk_value_box:     // orbos 98-01-18: Objects By Value
 528             return tk_value_box;
 529         case _tk_native:
 530             return tk_native;
 531         case _tk_abstract_interface:
 532             return tk_abstract_interface;
 533         default:
 534             throw new org.omg.CORBA.BAD_PARAM();
 535         }
 536     }
 537 
 538 
 539     /**
 540     * Creates a new <code>TCKind</code> instance initialized with the given
 541     * <code>int</code>.
 542     * @deprecated Do not use this constructor as this method should be private
 543     * according to the OMG specification. Use {@link #from_int(int)} instead.
 544     *
 545     * @param  _value the <code>int</code> to convert.  It must be one of
 546     *         the <code>int</code> constants in the class
 547     *         <code>TCKind</code>.
 548     */
 549     @Deprecated
 550     protected TCKind(int _value){
 551         this._value = _value;
 552     }
 553     private int _value;
 554 }