1. /*
  2. * @(#)TCKind.java 1.28 04/05/18
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package org.omg.CORBA;
  8. /**
  9. * The Java mapping of the IDL enum <code>TCKind</code>, which
  10. * specifies the kind of a <code>TypeCode</code> object. There is
  11. * one kind for each primitive and essential IDL data type.
  12. * <P>
  13. * The class <code>TCKind</code> consists of:
  14. * <UL>
  15. * <LI>a set of <code>int</code> constants, one for each
  16. * kind of IDL data type. These <code>int</code> constants
  17. * make it possible to use a <code>switch</code> statement.
  18. * <LI>a set of <code>TCKind</code> constants, one for each
  19. * kind of IDL data type. The <code>value</code> field for
  20. * each <code>TCKind</code> instance is initialized with
  21. * the <code>int</code> constant that corresponds with
  22. * the IDL data type that the instance represents.
  23. * <LI>the method <code>from_int</code>for converting
  24. * an <code>int</code> to its
  25. * corresponding <code>TCKind</code> instance
  26. * <P>Example:
  27. * <PRE>
  28. * org.omg.CORBA.TCKind k = org.omg.CORBA.TCKind.from_int(
  29. * org.omg.CORBA.TCKind._tk_string);
  30. * </PRE>
  31. * The variable <code>k</code> represents the <code>TCKind</code>
  32. * instance for the IDL type <code>string</code>, which is
  33. * <code>tk_string</code>.
  34. * <P>
  35. * <LI>the method <code>value</code> for accessing the
  36. * <code>_value</code> field of a <code>TCKind</code> constant
  37. * <P>Example:
  38. * <PRE>
  39. * int i = org.omg.CORBA.TCKind.tk_char.value();
  40. * </PRE>
  41. * The variable <code>i</code> represents 9, the value for the
  42. * IDL data type <code>char</code>.
  43. * </UL>
  44. * <P>The <code>value</code> field of a <code>TCKind</code> instance
  45. * is the CDR encoding used for a <code>TypeCode</code> object in
  46. * an IIOP message.
  47. */
  48. public class TCKind {
  49. /**
  50. * The <code>int</code> constant for a <code>null</code> IDL data type.
  51. */
  52. public static final int _tk_null = 0;
  53. /**
  54. * The <code>int</code> constant for the IDL data type <code>void</code>.
  55. */
  56. public static final int _tk_void = 1;
  57. /**
  58. * The <code>int</code> constant for the IDL data type <code>short</code>.
  59. */
  60. public static final int _tk_short = 2;
  61. /**
  62. * The <code>int</code> constant for the IDL data type <code>long</code>.
  63. */
  64. public static final int _tk_long = 3;
  65. /**
  66. * The <code>int</code> constant for the IDL data type <code>ushort</code>.
  67. */
  68. public static final int _tk_ushort = 4;
  69. /**
  70. * The <code>int</code> constant for the IDL data type <code>ulong</code>.
  71. */
  72. public static final int _tk_ulong = 5;
  73. /**
  74. * The <code>int</code> constant for the IDL data type <code>float</code>.
  75. */
  76. public static final int _tk_float = 6;
  77. /**
  78. * The <code>int</code> constant for the IDL data type <code>double</code>.
  79. */
  80. public static final int _tk_double = 7;
  81. /**
  82. * The <code>int</code> constant for the IDL data type <code>boolean</code>.
  83. */
  84. public static final int _tk_boolean = 8;
  85. /**
  86. * The <code>int</code> constant for the IDL data type <code>char</code>.
  87. */
  88. public static final int _tk_char = 9;
  89. /**
  90. * The <code>int</code> constant for the IDL data type <code>octet</code>.
  91. */
  92. public static final int _tk_octet = 10;
  93. /**
  94. * The <code>int</code> constant for the IDL data type <code>any</code>.
  95. */
  96. public static final int _tk_any = 11;
  97. /**
  98. * The <code>int</code> constant for the IDL data type <code>TypeCode</code>.
  99. */
  100. public static final int _tk_TypeCode = 12;
  101. /**
  102. * The <code>int</code> constant for the IDL data type <code>Principal</code>.
  103. */
  104. public static final int _tk_Principal = 13;
  105. /**
  106. * The <code>int</code> constant for the IDL data type <code>objref</code>.
  107. */
  108. public static final int _tk_objref = 14;
  109. /**
  110. * The <code>int</code> constant for the IDL data type <code>struct</code>.
  111. */
  112. public static final int _tk_struct = 15;
  113. /**
  114. * The <code>int</code> constant for the IDL data type <code>union</code>.
  115. */
  116. public static final int _tk_union = 16;
  117. /**
  118. * The <code>int</code> constant for the IDL data type <code>enum</code>.
  119. */
  120. public static final int _tk_enum = 17;
  121. /**
  122. * The <code>int</code> constant for the IDL data type <code>string</code>.
  123. */
  124. public static final int _tk_string = 18;
  125. /**
  126. * The <code>int</code> constant for the IDL data type <code>sequence</code>.
  127. */
  128. public static final int _tk_sequence = 19;
  129. /**
  130. * The <code>int</code> constant for the IDL data type <code>array</code>.
  131. */
  132. public static final int _tk_array = 20;
  133. /**
  134. * The <code>int</code> constant for the IDL data type <code>alias</code>.
  135. */
  136. public static final int _tk_alias = 21;
  137. /**
  138. * The <code>int</code> constant for the IDL data type <code>except</code>.
  139. */
  140. public static final int _tk_except = 22;
  141. /**
  142. * The <code>int</code> constant for the IDL data type <code>longlong</code>.
  143. */
  144. public static final int _tk_longlong = 23;
  145. /**
  146. * The <code>int</code> constant for the IDL data type <code>ulonglong</code>.
  147. */
  148. public static final int _tk_ulonglong = 24;
  149. /**
  150. * The <code>int</code> constant for the IDL data type <code>longdouble</code>.
  151. */
  152. public static final int _tk_longdouble = 25;
  153. /**
  154. * The <code>int</code> constant for the IDL data type <code>wchar</code>.
  155. */
  156. public static final int _tk_wchar = 26;
  157. /**
  158. * The <code>int</code> constant for the IDL data type <code>wstring</code>.
  159. */
  160. public static final int _tk_wstring = 27;
  161. /**
  162. * The <code>int</code> constant for the IDL data type <code>fixed</code>.
  163. */
  164. public static final int _tk_fixed = 28;
  165. /**
  166. * The <code>int</code> constant for the IDL data type <code>value</code>.
  167. */
  168. public static final int _tk_value = 29; // orbos 98-01-18: Objects By Value
  169. /**
  170. * The <code>int</code> constant for the IDL data type <code>value_box</code>.
  171. */
  172. public static final int _tk_value_box = 30; // orbos 98-01-18: Objects By Value
  173. /**
  174. * The <code>int</code> constant for the IDL data type <code>native</code>.
  175. */
  176. public static final int _tk_native = 31; // Verify
  177. /**
  178. * The <code>int</code> constant for the IDL data type <code>abstract interface</code>.
  179. */
  180. public static final int _tk_abstract_interface = 32;
  181. /**
  182. * The <code>TCKind</code> constant whose <code>value</code> field is
  183. * initialized with <code>TCKind._tk_null</code>.
  184. */
  185. public static final TCKind tk_null = new TCKind(_tk_null);
  186. /**
  187. * The <code>TCKind</code> constant whose <code>value</code> field is
  188. * initialized with <code>TCKind._tk_void</code>.
  189. */
  190. public static final TCKind tk_void = new TCKind(_tk_void);
  191. /**
  192. * The <code>TCKind</code> constant whose <code>value</code> field is
  193. * initialized with <code>TCKind._tk_short</code>.
  194. */
  195. public static final TCKind tk_short = new TCKind(_tk_short);
  196. /**
  197. * The <code>TCKind</code> constant whose <code>value</code> field is
  198. * initialized with <code>TCKind._tk_long</code>.
  199. */
  200. public static final TCKind tk_long = new TCKind(_tk_long);
  201. /**
  202. * The <code>TCKind</code> constant whose <code>value</code> field is
  203. * initialized with <code>TCKind._tk_ushort</code>.
  204. */
  205. public static final TCKind tk_ushort = new TCKind(_tk_ushort);
  206. /**
  207. * The <code>TCKind</code> constant whose <code>value</code> field is
  208. * initialized with <code>TCKind._tk_ulong</code>.
  209. */
  210. public static final TCKind tk_ulong = new TCKind(_tk_ulong);
  211. /**
  212. * The <code>TCKind</code> constant whose <code>value</code> field is
  213. * initialized with <code>TCKind._tk_float</code>.
  214. */
  215. public static final TCKind tk_float = new TCKind(_tk_float);
  216. /**
  217. * The <code>TCKind</code> constant whose <code>value</code> field is
  218. * initialized with <code>TCKind._tk_double</code>.
  219. */
  220. public static final TCKind tk_double = new TCKind(_tk_double);
  221. /**
  222. * The <code>TCKind</code> constant whose <code>value</code> field is
  223. * initialized with <code>TCKind._tk_boolean</code>.
  224. */
  225. public static final TCKind tk_boolean = new TCKind(_tk_boolean);
  226. /**
  227. * The <code>TCKind</code> constant whose <code>value</code> field is
  228. * initialized with <code>TCKind._tk_char</code>.
  229. */
  230. public static final TCKind tk_char = new TCKind(_tk_char);
  231. /**
  232. * The <code>TCKind</code> constant whose <code>value</code> field is
  233. * initialized with <code>TCKind._tk_octet</code>.
  234. */
  235. public static final TCKind tk_octet = new TCKind(_tk_octet);
  236. /**
  237. * The <code>TCKind</code> constant whose <code>value</code> field is
  238. * initialized with <code>TCKind._tk_any</code>.
  239. */
  240. public static final TCKind tk_any = new TCKind(_tk_any);
  241. /**
  242. * The <code>TCKind</code> constant whose <code>value</code> field is
  243. * initialized with <code>TCKind._tk_TypeCode</code>.
  244. */
  245. public static final TCKind tk_TypeCode = new TCKind(_tk_TypeCode);
  246. /**
  247. * The <code>TCKind</code> constant whose <code>value</code> field is
  248. * initialized with <code>TCKind._tk_Principal</code>.
  249. */
  250. public static final TCKind tk_Principal = new TCKind(_tk_Principal);
  251. /**
  252. * The <code>TCKind</code> constant whose <code>value</code> field is
  253. * initialized with <code>TCKind._tk_objref</code>.
  254. */
  255. public static final TCKind tk_objref = new TCKind(_tk_objref);
  256. /**
  257. * The <code>TCKind</code> constant whose <code>value</code> field is
  258. * initialized with <code>TCKind._tk_struct</code>.
  259. */
  260. public static final TCKind tk_struct = new TCKind(_tk_struct);
  261. /**
  262. * The <code>TCKind</code> constant whose <code>value</code> field is
  263. * initialized with <code>TCKind._tk_union</code>.
  264. */
  265. public static final TCKind tk_union = new TCKind(_tk_union);
  266. /**
  267. * The <code>TCKind</code> constant whose <code>value</code> field is
  268. * initialized with <code>TCKind._tk_enum</code>.
  269. */
  270. public static final TCKind tk_enum = new TCKind(_tk_enum);
  271. /**
  272. * The <code>TCKind</code> constant whose <code>value</code> field is
  273. * initialized with <code>TCKind._tk_string</code>.
  274. */
  275. public static final TCKind tk_string = new TCKind(_tk_string);
  276. /**
  277. * The <code>TCKind</code> constant whose <code>value</code> field is
  278. * initialized with <code>TCKind._tk_sequence</code>.
  279. */
  280. public static final TCKind tk_sequence = new TCKind(_tk_sequence);
  281. /**
  282. * The <code>TCKind</code> constant whose <code>value</code> field is
  283. * initialized with <code>TCKind._tk_array</code>.
  284. */
  285. public static final TCKind tk_array = new TCKind(_tk_array);
  286. /**
  287. * The <code>TCKind</code> constant whose <code>value</code> field is
  288. * initialized with <code>TCKind._tk_alias</code>.
  289. */
  290. public static final TCKind tk_alias = new TCKind(_tk_alias);
  291. /**
  292. * The <code>TCKind</code> constant whose <code>value</code> field is
  293. * initialized with <code>TCKind._tk_except</code>.
  294. */
  295. public static final TCKind tk_except = new TCKind(_tk_except);
  296. /**
  297. * The <code>TCKind</code> constant whose <code>value</code> field is
  298. * initialized with <code>TCKind._tk_longlong</code>.
  299. */
  300. public static final TCKind tk_longlong = new TCKind(_tk_longlong);
  301. /**
  302. * The <code>TCKind</code> constant whose <code>value</code> field is
  303. * initialized with <code>TCKind._tk_ulonglong</code>.
  304. */
  305. public static final TCKind tk_ulonglong = new TCKind(_tk_ulonglong);
  306. /**
  307. * The <code>TCKind</code> constant whose <code>value</code> field is
  308. * initialized with <code>TCKind._tk_longdouble</code>.
  309. */
  310. public static final TCKind tk_longdouble = new TCKind(_tk_longdouble);
  311. /**
  312. * The <code>TCKind</code> constant whose <code>value</code> field is
  313. * initialized with <code>TCKind._tk_wchar</code>.
  314. */
  315. public static final TCKind tk_wchar = new TCKind(_tk_wchar);
  316. /**
  317. * The <code>TCKind</code> constant whose <code>value</code> field is
  318. * initialized with <code>TCKind._tk_wstring</code>.
  319. */
  320. public static final TCKind tk_wstring = new TCKind(_tk_wstring);
  321. /**
  322. * The <code>TCKind</code> constant whose <code>value</code> field is
  323. * initialized with <code>TCKind._tk_fixed</code>.
  324. */
  325. public static final TCKind tk_fixed = new TCKind(_tk_fixed);
  326. // orbos 98-01-18: Objects By Value -- begin
  327. /**
  328. * The <code>TCKind</code> constant whose <code>value</code> field is
  329. * initialized with <code>TCKind._tk_value</code>.
  330. */
  331. public static final TCKind tk_value = new TCKind(_tk_value);
  332. /**
  333. * The <code>TCKind</code> constant whose <code>value</code> field is
  334. * initialized with <code>TCKind._tk_value_box</code>.
  335. */
  336. public static final TCKind tk_value_box = new TCKind(_tk_value_box);
  337. // orbos 98-01-18: Objects By Value -- end
  338. /**
  339. * The <code>TCKind</code> constant whose <code>value</code> field is
  340. * initialized with <code>TCKind._tk_native</code>.
  341. */
  342. public static final TCKind tk_native = new TCKind(_tk_native);
  343. /**
  344. * The <code>TCKind</code> constant whose <code>value</code> field is
  345. * initialized with <code>TCKind._tk_abstract_interface</code>.
  346. */
  347. public static final TCKind tk_abstract_interface = new TCKind(_tk_abstract_interface);
  348. /**
  349. * Retrieves the value of this <code>TCKind</code> instance.
  350. *
  351. * @return the <code>int</code> that represents the kind of
  352. * IDL data type for this <code>TCKind</code> instance
  353. */
  354. public int value() {
  355. return _value;
  356. }
  357. /**
  358. * Converts the given <code>int</code> to the corresponding
  359. * <code>TCKind</code> instance.
  360. *
  361. * @param i the <code>int</code> to convert. It must be one of
  362. * the <code>int</code> constants in the class
  363. * <code>TCKind</code>.
  364. * @return the <code>TCKind</code> instance whose <code>value</code>
  365. * field matches the given <code>int</code>
  366. * @exception BAD_PARAM if the given <code>int</code> does not
  367. * match the <code>_value</code> field of
  368. * any <code>TCKind</code> instance
  369. */
  370. public static TCKind from_int(int i) {
  371. switch (i) {
  372. case _tk_null:
  373. return tk_null;
  374. case _tk_void:
  375. return tk_void;
  376. case _tk_short:
  377. return tk_short;
  378. case _tk_long:
  379. return tk_long;
  380. case _tk_ushort:
  381. return tk_ushort;
  382. case _tk_ulong:
  383. return tk_ulong;
  384. case _tk_float:
  385. return tk_float;
  386. case _tk_double:
  387. return tk_double;
  388. case _tk_boolean:
  389. return tk_boolean;
  390. case _tk_char:
  391. return tk_char;
  392. case _tk_octet:
  393. return tk_octet;
  394. case _tk_any:
  395. return tk_any;
  396. case _tk_TypeCode:
  397. return tk_TypeCode;
  398. case _tk_Principal:
  399. return tk_Principal;
  400. case _tk_objref:
  401. return tk_objref;
  402. case _tk_struct:
  403. return tk_struct;
  404. case _tk_union:
  405. return tk_union;
  406. case _tk_enum:
  407. return tk_enum;
  408. case _tk_string:
  409. return tk_string;
  410. case _tk_sequence:
  411. return tk_sequence;
  412. case _tk_array:
  413. return tk_array;
  414. case _tk_alias:
  415. return tk_alias;
  416. case _tk_except:
  417. return tk_except;
  418. case _tk_longlong:
  419. return tk_longlong;
  420. case _tk_ulonglong:
  421. return tk_ulonglong;
  422. case _tk_longdouble:
  423. return tk_longdouble;
  424. case _tk_wchar:
  425. return tk_wchar;
  426. case _tk_wstring:
  427. return tk_wstring;
  428. case _tk_fixed:
  429. return tk_fixed;
  430. case _tk_value: // orbos 98-01-18: Objects By Value
  431. return tk_value;
  432. case _tk_value_box: // orbos 98-01-18: Objects By Value
  433. return tk_value_box;
  434. case _tk_native:
  435. return tk_native;
  436. case _tk_abstract_interface:
  437. return tk_abstract_interface;
  438. default:
  439. throw new org.omg.CORBA.BAD_PARAM();
  440. }
  441. }
  442. /**
  443. * Creates a new <code>TCKind</code> instance initialized with the given
  444. * <code>int</code>.
  445. * @deprecated Do not use this constructor as this method should be private
  446. * according to the OMG specification. Use {@link #from_int(int)} instead.
  447. *
  448. * @param _value the <code>int</code> to convert. It must be one of
  449. * the <code>int</code> constants in the class
  450. * <code>TCKind</code>.
  451. * @return a new <code>TCKind</code> instance whose <code>value</code>
  452. * field matches the given <code>int</code>
  453. */
  454. @Deprecated
  455. protected TCKind(int _value){
  456. this._value = _value;
  457. }
  458. private int _value;
  459. }