DefinitionKind.java 13 KB

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