TCKind.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. /* TCKind.java -- java to IDL mapping constants.
  2. Copyright (C) 2005 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package org.omg.CORBA;
  32. /**
  33. * The basic constants, used in java to IDL mapping.
  34. * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
  35. */
  36. public class TCKind
  37. {
  38. /**
  39. * The integer constant, indicating IDL data type
  40. * <code>null</code>.
  41. */
  42. public static final int _tk_null = 0;
  43. /**
  44. * The integer constant, indicating IDL data type
  45. * <code>void</code>.
  46. */
  47. public static final int _tk_void = 1;
  48. /**
  49. * The integer constant, indicating IDL data type
  50. * <code>short</code>.
  51. */
  52. public static final int _tk_short = 2;
  53. /**
  54. * The integer constant, indicating IDL data type
  55. * <code>long</code>.
  56. */
  57. public static final int _tk_long = 3;
  58. /**
  59. * The integer constant, indicating IDL data type
  60. * <code>ushort</code>.
  61. */
  62. public static final int _tk_ushort = 4;
  63. /**
  64. * The integer constant, indicating IDL data type
  65. * <code>ulong</code>.
  66. */
  67. public static final int _tk_ulong = 5;
  68. /**
  69. * The integer constant, indicating IDL data type
  70. * <code>float</code>.
  71. */
  72. public static final int _tk_float = 6;
  73. /**
  74. * The integer constant, indicating IDL data type
  75. * <code>double</code>.
  76. */
  77. public static final int _tk_double = 7;
  78. /**
  79. * The integer constant, indicating IDL data type
  80. * <code>boolean</code>.
  81. */
  82. public static final int _tk_boolean = 8;
  83. /**
  84. * The integer constant, indicating IDL data type
  85. * <code>char</code>.
  86. */
  87. public static final int _tk_char = 9;
  88. /**
  89. * The integer constant, indicating IDL data type
  90. * <code>octet</code>.
  91. */
  92. public static final int _tk_octet = 10;
  93. /**
  94. * The integer constant, indicating IDL data type
  95. * <code>any</code>.
  96. */
  97. public static final int _tk_any = 11;
  98. /**
  99. * The integer constant, indicating IDL data type
  100. * <code>TypeCode</code>.
  101. */
  102. public static final int _tk_TypeCode = 12;
  103. /**
  104. * The integer constant, indicating IDL data type
  105. * <code>Principal</code>.
  106. */
  107. public static final int _tk_Principal = 13;
  108. /**
  109. * The integer constant, indicating IDL data type
  110. * <code>objref</code>.
  111. */
  112. public static final int _tk_objref = 14;
  113. /**
  114. * The integer constant, indicating IDL data type
  115. * <code>struct</code>.
  116. */
  117. public static final int _tk_struct = 15;
  118. /**
  119. * The integer constant, indicating IDL data type
  120. * <code>union</code>.
  121. */
  122. public static final int _tk_union = 16;
  123. /**
  124. * The integer constant, indicating IDL data type
  125. * <code>enum</code>.
  126. */
  127. public static final int _tk_enum = 17;
  128. /**
  129. * The integer constant, indicating IDL data type
  130. * <code>string</code>.
  131. */
  132. public static final int _tk_string = 18;
  133. /**
  134. * The integer constant, indicating IDL data type
  135. * <code>sequence</code>.
  136. */
  137. public static final int _tk_sequence = 19;
  138. /**
  139. * The integer constant, indicating IDL data type
  140. * <code>array</code>.
  141. */
  142. public static final int _tk_array = 20;
  143. /**
  144. * The integer constant, indicating IDL data type
  145. * <code>alias</code>.
  146. */
  147. public static final int _tk_alias = 21;
  148. /**
  149. * The integer constant, indicating IDL data type
  150. * <code>except</code>.
  151. */
  152. public static final int _tk_except = 22;
  153. /**
  154. * The integer constant, indicating IDL data type
  155. * <code>longlong</code>.
  156. */
  157. public static final int _tk_longlong = 23;
  158. /**
  159. * The integer constant, indicating IDL data type
  160. * <code>ulonglong</code>.
  161. */
  162. public static final int _tk_ulonglong = 24;
  163. /**
  164. * The integer constant, indicating IDL data type
  165. * <code>longdouble</code>.
  166. */
  167. public static final int _tk_longdouble = 25;
  168. /**
  169. * The integer constant, indicating IDL data type
  170. * <code>wchar</code>.
  171. */
  172. public static final int _tk_wchar = 26;
  173. /**
  174. * The integer constant, indicating IDL data type
  175. * <code>wstring</code>.
  176. */
  177. public static final int _tk_wstring = 27;
  178. /**
  179. * The integer constant, indicating IDL data type
  180. * <code>fixed</code>.
  181. */
  182. public static final int _tk_fixed = 28;
  183. /**
  184. * The integer constant, indicating IDL data type
  185. * <code>value</code>.
  186. */
  187. public static final int _tk_value = 29;
  188. /**
  189. * The integer constant, indicating IDL data type
  190. * <code>value_box</code>.
  191. */
  192. public static final int _tk_value_box = 30;
  193. /**
  194. * The integer constant, indicating IDL data type
  195. * <code>native</code>.
  196. */
  197. public static final int _tk_native = 31;
  198. /**
  199. * The integer constant, indicating IDL data type
  200. * <code>abstract_interface</code>.
  201. */
  202. public static final int _tk_abstract_interface = 32;
  203. /**
  204. * The TCKind constant, indicating IDL data type
  205. * <code>null</code>
  206. */
  207. public static final TCKind tk_null = new TCKind(_tk_null);
  208. /**
  209. * The TCKind constant, indicating IDL data type
  210. * <code>void</code>
  211. */
  212. public static final TCKind tk_void = new TCKind(_tk_void);
  213. /**
  214. * The TCKind constant, indicating IDL data type
  215. * <code>short</code>
  216. */
  217. public static final TCKind tk_short = new TCKind(_tk_short);
  218. /**
  219. * The TCKind constant, indicating IDL data type
  220. * <code>long</code>
  221. */
  222. public static final TCKind tk_long = new TCKind(_tk_long);
  223. /**
  224. * The TCKind constant, indicating IDL data type
  225. * <code>ushort</code>
  226. */
  227. public static final TCKind tk_ushort = new TCKind(_tk_ushort);
  228. /**
  229. * The TCKind constant, indicating IDL data type
  230. * <code>ulong</code>
  231. */
  232. public static final TCKind tk_ulong = new TCKind(_tk_ulong);
  233. /**
  234. * The TCKind constant, indicating IDL data type
  235. * <code>float</code>
  236. */
  237. public static final TCKind tk_float = new TCKind(_tk_float);
  238. /**
  239. * The TCKind constant, indicating IDL data type
  240. * <code>double</code>
  241. */
  242. public static final TCKind tk_double = new TCKind(_tk_double);
  243. /**
  244. * The TCKind constant, indicating IDL data type
  245. * <code>boolean</code>
  246. */
  247. public static final TCKind tk_boolean = new TCKind(_tk_boolean);
  248. /**
  249. * The TCKind constant, indicating IDL data type
  250. * <code>char</code>
  251. */
  252. public static final TCKind tk_char = new TCKind(_tk_char);
  253. /**
  254. * The TCKind constant, indicating IDL data type
  255. * <code>octet</code>
  256. */
  257. public static final TCKind tk_octet = new TCKind(_tk_octet);
  258. /**
  259. * The TCKind constant, indicating IDL data type
  260. * <code>any</code>
  261. */
  262. public static final TCKind tk_any = new TCKind(_tk_any);
  263. /**
  264. * The TCKind constant, indicating IDL data type
  265. * <code>TypeCode</code>
  266. */
  267. public static final TCKind tk_TypeCode = new TCKind(_tk_TypeCode);
  268. /**
  269. * The TCKind constant, indicating IDL data type
  270. * <code>Principal</code>
  271. */
  272. public static final TCKind tk_Principal = new TCKind(_tk_Principal);
  273. /**
  274. * The TCKind constant, indicating IDL data type
  275. * <code>objref</code>
  276. */
  277. public static final TCKind tk_objref = new TCKind(_tk_objref);
  278. /**
  279. * The TCKind constant, indicating IDL data type
  280. * <code>struct</code>
  281. */
  282. public static final TCKind tk_struct = new TCKind(_tk_struct);
  283. /**
  284. * The TCKind constant, indicating IDL data type
  285. * <code>union</code>
  286. */
  287. public static final TCKind tk_union = new TCKind(_tk_union);
  288. /**
  289. * The TCKind constant, indicating IDL data type
  290. * <code>enum</code>
  291. */
  292. public static final TCKind tk_enum = new TCKind(_tk_enum);
  293. /**
  294. * The TCKind constant, indicating IDL data type
  295. * <code>string</code>
  296. */
  297. public static final TCKind tk_string = new TCKind(_tk_string);
  298. /**
  299. * The TCKind constant, indicating IDL data type
  300. * <code>sequence</code>
  301. */
  302. public static final TCKind tk_sequence = new TCKind(_tk_sequence);
  303. /**
  304. * The TCKind constant, indicating IDL data type
  305. * <code>array</code>
  306. */
  307. public static final TCKind tk_array = new TCKind(_tk_array);
  308. /**
  309. * The TCKind constant, indicating IDL data type
  310. * <code>alias</code>
  311. */
  312. public static final TCKind tk_alias = new TCKind(_tk_alias);
  313. /**
  314. * The TCKind constant, indicating IDL data type
  315. * <code>except</code>
  316. */
  317. public static final TCKind tk_except = new TCKind(_tk_except);
  318. /**
  319. * The TCKind constant, indicating IDL data type
  320. * <code>longlong</code>
  321. */
  322. public static final TCKind tk_longlong = new TCKind(_tk_longlong);
  323. /**
  324. * The TCKind constant, indicating IDL data type
  325. * <code>ulonglong</code>
  326. */
  327. public static final TCKind tk_ulonglong = new TCKind(_tk_ulonglong);
  328. /**
  329. * The TCKind constant, indicating IDL data type
  330. * <code>longdouble</code>
  331. */
  332. public static final TCKind tk_longdouble = new TCKind(_tk_longdouble);
  333. /**
  334. * The TCKind constant, indicating IDL data type
  335. * <code>wchar</code>
  336. */
  337. public static final TCKind tk_wchar = new TCKind(_tk_wchar);
  338. /**
  339. * The TCKind constant, indicating IDL data type
  340. * <code>wstring</code>
  341. */
  342. public static final TCKind tk_wstring = new TCKind(_tk_wstring);
  343. /**
  344. * The TCKind constant, indicating IDL data type
  345. * <code>fixed</code>
  346. */
  347. public static final TCKind tk_fixed = new TCKind(_tk_fixed);
  348. /**
  349. * The TCKind constant, indicating IDL data type
  350. * <code>value</code>
  351. */
  352. public static final TCKind tk_value = new TCKind(_tk_value);
  353. /**
  354. * The TCKind constant, indicating IDL data type
  355. * <code>value_box</code>
  356. */
  357. public static final TCKind tk_value_box = new TCKind(_tk_value_box);
  358. /**
  359. * The TCKind constant, indicating IDL data type
  360. * <code>native</code>
  361. */
  362. public static final TCKind tk_native = new TCKind(_tk_native);
  363. /**
  364. * The TCKind constant, indicating IDL data type
  365. * <code>abstract_interface</code>
  366. */
  367. public static final TCKind tk_abstract_interface =
  368. new TCKind(_tk_abstract_interface);
  369. /**
  370. * The kind value for this instance.
  371. */
  372. private final int _value;
  373. /**
  374. * The array of all tk_... instances, sorted by the kind number.
  375. *
  376. * As long as the kind numbers make the continuos sequence, starting from 0,
  377. * the members can be found just by direct indexing.
  378. */
  379. private static final TCKind[] tk =
  380. new TCKind[]
  381. {
  382. tk_null, tk_void, tk_short, tk_long, tk_ushort, tk_ulong, tk_float,
  383. tk_double, tk_boolean, tk_char, tk_octet, tk_any, tk_TypeCode,
  384. tk_Principal, tk_objref, tk_struct, tk_union, tk_enum, tk_string,
  385. tk_sequence, tk_array, tk_alias, tk_except, tk_longlong, tk_ulonglong,
  386. tk_longdouble, tk_wchar, tk_wstring, tk_fixed, tk_value, tk_value_box,
  387. tk_native, tk_abstract_interface
  388. };
  389. /**
  390. * Creates a new TCKind instance with the given integer constant value.
  391. * @deprecated it is recommended to use {@link #from_int(int)} that
  392. * reuses existing TCKind object instead of allocating the new instance.
  393. * @param kind one of the <code>_tk_..</code> constants.
  394. */
  395. protected TCKind(int kind)
  396. {
  397. _value = kind;
  398. }
  399. /**
  400. * Returns the integer value, corresponding this instance of TCKind.
  401. * @return the <code>_tk_..</code> value, matching this instance.
  402. */
  403. public int value()
  404. {
  405. return _value;
  406. }
  407. /**
  408. * Return a TCKind object, matching the given integer code.
  409. * @param _tk_nnn the TCKind code, one of <code>_tk_..</code> constants.
  410. * @return the matching instance of TCKind, on of tk_.. constants.
  411. * @throws BAD_PARAM if the given integer constant is not one of the
  412. * valid <code>_tk_..</code> constants.
  413. */
  414. public static TCKind from_int(int _tk_nnn)
  415. {
  416. try {
  417. return tk[_tk_nnn];
  418. }
  419. catch (ArrayIndexOutOfBoundsException aex) {
  420. throw new BAD_PARAM("Invalid _tk_ code "+_tk_nnn);
  421. }
  422. }
  423. }