1. /*
  2. * @(#)TypeCode.java 1.50 01/02/09
  3. *
  4. * Copyright 1996-2001 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package org.omg.CORBA;
  11. import org.omg.CORBA.TypeCodePackage.*;
  12. import org.omg.CORBA.portable.IDLEntity;
  13. /**
  14. * A container for information about a specific CORBA data
  15. * type.
  16. *<P>
  17. * <code>TypeCode</code> objects are used:
  18. * <UL>
  19. * <LI>in the Dynamic Invocation Interface -- to indicate the types
  20. * of the actual arguments or the type of the return value. <BR>
  21. * <code>NamedValue</code> objects are used to represent arguments and
  22. * return values. One of their components is an <code>Any</code>
  23. * object, which in turn has as one of its components a
  24. * <code>TypeCode</code> object.
  25. * <LI>by an Interface Repository to represent the type specifications
  26. * that are part of many OMG IDL declarations
  27. * </UL>
  28. * <P>
  29. * The representation of a <code>TypeCode</code> object is opaque,
  30. * but abstractly, a <code>TypeCode</code> object consists of:
  31. * <UL>
  32. * <LI>a <code>kind</code> field, which is set to an instance
  33. * of the class <code>TCKind</code>
  34. * <LI>zero or more additional fields appropriate
  35. * for the particular kind. For example, the
  36. * <code>TypeCode</code> object
  37. * describing the OMG IDL type <code>1ong</code> has kind
  38. * <code>TCKind.tk_long</code> and no additional fields.
  39. * The <code>TypeCode</code> describing OMG IDL type
  40. * <code>sequence<boolean, 10></code> has a <code>kind</code> field
  41. * with the value
  42. * <code>TCKind.tk_sequence</code> and also fields with the values
  43. * <code>boolean</code> and <code>10</code> for the
  44. * type of sequence elements and the length of the sequence. <p>
  45. * </UL>
  46. *
  47. * <code>TypeCode</code> objects can be obtained in various ways:
  48. * <OL>
  49. * <LI>from a call to the method <code>Any.insert_X</code>, where X is
  50. * a basic IDL type. This method creates a <code>TypeCode</code> object
  51. * for type X and assigns it to the <code>Any</code> object's
  52. * <code>type</code> field.
  53. * <LI>from invocations of methods in the ORB class
  54. * <P>For example, the following creates a <code>TypeCode</code>
  55. * object for a <code>string</code> with a maximum of 30 characters:
  56. * <PRE>
  57. * org.omg.CORBA.TypeCode tcString = orb.create_string_tc(30);
  58. * </PRE>
  59. * <P> The following creates a <code>TypeCode</code>
  60. * object for an <code>array</code> of five <code>string</code>s:
  61. * <PRE>
  62. * org.omg.CORBA.TypeCode tcArray = orb.create_array_tc(
  63. * 5, TCKind.tk_string);
  64. * </PRE>
  65. * <P> The following creates a <code>TypeCode</code>
  66. * object for an interface named "Account":
  67. * <PRE>
  68. * org.omg.CORBA.TypeCode tcInterface = orb.create_interface_tc(
  69. * "thisId", "Account");
  70. * </PRE>
  71. * <LI>as the return value from the <code>_type</code> method
  72. * in <code>Holder</code> classes for user-defined
  73. * IDL types. These <code>Holder</code> classes are generated
  74. * by the <code>idltojava</code> compiler.
  75. * <LI>from a CORBA Interface Repository
  76. * </OL>
  77. * <P>
  78. * Most of the methods in the class <code>TypeCode</code>
  79. * are accessors, and the information contained in a <code>TypeCode</code>
  80. * object is specific to a particular type. Therefore, methods
  81. * must be invoked
  82. * only on the kind of type codes to which they apply. If an
  83. * accessor method
  84. * tries to access information from an inappropriate kind of
  85. * type code, it will throw
  86. * the exception <code>TypeCodePackage.BadKind</code>. For example,
  87. * if the method <code>discriminator_type</code> is called on anything
  88. * other than a <code>union</code>, it will throw <code>BadKind</code>
  89. * because only <code>union</code>s have a discriminator.
  90. * The following list shows which methods apply to which kinds of
  91. * type codes:
  92. * <P>
  93. * These methods may be invoked on all <code>TypeCode</code> kinds:
  94. * <UL>
  95. * <LI><code>equal</code>
  96. * <LI><code>kind</code>
  97. * </UL>
  98. * <P>
  99. * These methods may be invoked on <code>objref</code>, <code>struct</code>,
  100. * <code>union</code>, <code>enum</code>,
  101. * <code>alias</code>, <code>exception</code>, <code>value</code>,
  102. * <code>value_box</code>, <code>native</code>,
  103. * and <code>abstract_interface</code>:
  104. * <UL>
  105. * <LI><code>id</code>
  106. * <LI><code>name</code>
  107. * </UL>
  108. * <P>
  109. * These methods may be invoked on <code>struct</code>,
  110. * <code>union</code>, <code>enum</code>,
  111. * and <code>exception</code>:
  112. * <UL>
  113. * <LI><code>member_count</code>
  114. * <LI><code>member_name</code>
  115. * </UL>
  116. * <P>
  117. * These methods may be invoked on <code>struct</code>,
  118. * <code>union</code>, and <code>exception</code>:
  119. * <UL>
  120. * <LI><code>member_type(int index)</code>
  121. * </UL>
  122. * <P>
  123. * These methods may be invoked on <code>union</code>:
  124. * <UL>
  125. * <LI><code>member_label</code>
  126. * <LI><code>discriminator_type</code>
  127. * <LI><code>default_index</code>
  128. * </UL>
  129. * <P>
  130. * These methods may be invoked on <code>string</code>,
  131. * <code>sequence</code>, and <code>array</code>:
  132. * <UL>
  133. * <LI><code>length</code>
  134. * </UL>
  135. * <P>
  136. * These methods may be invoked on <code>alias</code>,
  137. * <code>sequence</code>, <code>array</code>, and <code>value_box</code>:
  138. * <UL>
  139. * <LI><code>content_type</code>
  140. * </UL>
  141. * <P>
  142. * Unlike other CORBA pseudo-objects, <code>TypeCode</code>
  143. * objects can be passed as general IDL parameters. <p>
  144. * The methods <code>parameter</code> and <code>param_count</code>,
  145. * which are deprecated, are not mapped. <p>
  146. *
  147. * Java IDL extends the CORBA specification to allow all operations permitted
  148. * on a <code>struct</code> <code>TypeCode</code> to be permitted
  149. * on an <code>exception</code> <code>TypeCode</code> as well. <p>
  150. *
  151. * @version 1.25 09/09/97
  152. */
  153. public abstract class TypeCode implements IDLEntity {
  154. /**
  155. * Compares this <code>TypeCode</code> object with the given one,
  156. * testing for equality. <code>TypeCode</code> objects are equal if
  157. * they are interchangeable and give identical results when
  158. * <code>TypeCode</code> operations are applied to them.
  159. *
  160. * @param tc the <code>TypeCode</code> object to compare against
  161. * @return <code>true</code> if the type codes are equal;
  162. * <code>false</code> otherwise
  163. */
  164. public abstract boolean equal(TypeCode tc);
  165. /**
  166. * Tests to see if the given <code>TypeCode</code> object is
  167. * equivalent to this <code>TypeCode</code> object.
  168. * <P>
  169. * Not implemented; see package comments.
  170. *
  171. * @param tc the typecode to compare with this typecode
  172. *
  173. * @return <code>true</code> if the given typecode is equivalent to
  174. * this typecode; <code>false</code> otherwise
  175. * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
  176. * comments for unimplemented features</a>
  177. */
  178. public boolean equivalent(TypeCode tc) {
  179. throw new org.omg.CORBA.NO_IMPLEMENT();
  180. }
  181. /**
  182. * Strips out all optional name and member name fields,
  183. * but leaves all alias typecodes intact.
  184. * @return a <code>TypeCode</code> object with optional name and
  185. * member name fields stripped out, except for alias typecodes,
  186. * which are left intact
  187. * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
  188. * comments for unimplemented features</a>
  189. */
  190. public TypeCode get_compact_typecode() {
  191. throw new org.omg.CORBA.NO_IMPLEMENT();
  192. }
  193. /**
  194. * Retrieves the kind of this <code>TypeCode</code> object.
  195. * The kind of a type code determines which <code>TypeCode</code>
  196. * methods may legally be invoked on it.
  197. * <P>
  198. * The method <code>kind</code> may be invoked on any
  199. * <code>TypeCode</code> object.
  200. *
  201. * @return the <code>TCKind</code> instance indicating the
  202. * value of the <code>kind</code> field of this
  203. * <code>TypeCode</code> object
  204. */
  205. public abstract TCKind kind();
  206. /**
  207. * Retrieves the RepositoryId globally identifying the type
  208. * of this <code>TypeCode</code> object.
  209. * <P>
  210. * The method <code>id</code> can be invoked on object reference,
  211. * structure, union, enumeration, alias, exception, valuetype,
  212. * boxed valuetype, native, and abstract interface type codes.
  213. * Object reference, exception, valuetype, boxed valuetype,
  214. * native, and abstract interface <code>TypeCode</code> objects
  215. * always have a RepositoryId.
  216. * Structure, union, enumeration, and alias <code>TypeCode</code> objects
  217. * obtained from the Interface Repository or the method
  218. * <code>ORB.create_operation_list</code>
  219. * also always have a RepositoryId. If there is no RepositoryId, the
  220. * method can return an empty string.
  221. *
  222. * @return the RepositoryId for this <code>TypeCode</code> object
  223. * or an empty string if there is no RepositoryID
  224. * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
  225. * is invoked on an inappropriate kind of<code>TypeCode</code>
  226. * object
  227. */
  228. public abstract String id() throws BadKind;
  229. /**
  230. * Retrieves the simple name identifying this <code>TypeCode</code>
  231. * object within its
  232. * enclosing scope. Since names are local to a Repository, the
  233. * name returned from a <code>TypeCode</code> object
  234. * may not match the name of the
  235. * type in any particular Repository, and may even be an empty
  236. * string.
  237. * <P>
  238. * The method <code>name</code> can be invoked on object reference,
  239. * structure, union, enumeration, alias, exception, valuetype,
  240. * boxed valuetype, native, and abstract interface
  241. * <code>TypeCode</code> objects.
  242. *
  243. * @return the name identifying this <code>TypeCode</code> object
  244. * or an empty string
  245. * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
  246. * is invoked on an inappropriate kind of<code>TypeCode</code>
  247. * object
  248. */
  249. public abstract String name() throws BadKind;
  250. /**
  251. * Retrieves the number of members in the type described by
  252. * this <code>TypeCode</code> object.
  253. * <P>
  254. * The method <code>member_count</code> can be invoked on
  255. * structure, union, and enumeration <code>TypeCode</code> objects.
  256. * Java IDL extends the CORBA specification to allow this method to
  257. * operate on exceptions as well.
  258. *
  259. * @return the number of members constituting the type described
  260. * by this <code>TypeCode</code> object
  261. *
  262. * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
  263. * is invoked on an inappropriate kind of <code>TypeCode</code>
  264. * object
  265. */
  266. public abstract int member_count() throws BadKind;
  267. /**
  268. * Retrieves the simple name of the member identified by
  269. * the given index. Since names are local to a
  270. * Repository, the name returned from a <code>TypeCode</code> object
  271. * may not match the name of the member in any particular
  272. * Repository, and may even be an empty string.
  273. * <P>
  274. * The method <code>member_name</code> can be invoked on structure, union,
  275. * and enumeration <code>TypeCode</code> objects.
  276. * Java IDL extends the CORBA specification to allow this method to
  277. * operate on exceptions as well.
  278. *
  279. * @param index index of the member for which a name is being reqested
  280. * @return simple name of the member identified by the
  281. * index or an empty string
  282. * @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is equal
  283. * to or greater than
  284. * the number of members constituting the type
  285. * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
  286. * is invoked on an inappropriate kind of <code>TypeCode</code>
  287. * object
  288. */
  289. public abstract String member_name(int index)
  290. throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds;
  291. /**
  292. * Retrieves the <code>TypeCode</code> object describing the type
  293. * of the member identified by the given index.
  294. * <P>
  295. * The method <code>member_type</code> can be invoked on structure
  296. * and union <code>TypeCode</code> objects.
  297. * Java IDL extends the CORBA specification to allow this method to
  298. * operate on exceptions as well.
  299. *
  300. * @param index index of the member for which type information
  301. * is begin requested
  302. * @return the <code>TypeCode</code> object describing the
  303. * member at the given index
  304. * @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is
  305. * equal to or greater than
  306. * the number of members constituting the type
  307. * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
  308. * is invoked on an inappropriate kind of <code>TypeCode</code>
  309. * object
  310. */
  311. public abstract TypeCode member_type(int index)
  312. throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds;
  313. /**
  314. * Retrieves the label of the union member
  315. * identified by the given index. For the default member,
  316. * the label is the zero octet.
  317. *<P>
  318. * The method <code>member_label</code> can only be invoked on union
  319. * <code>TypeCode</code> objects.
  320. *
  321. * @param index index of the union member for which the
  322. * label is being requested
  323. * @return an <code>Any</code> object describing the label of
  324. * the requested union member or the zero octet for
  325. * the default member
  326. * @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is
  327. * equal to or greater than
  328. * the number of members constituting the union
  329. * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
  330. * is invoked on a non-union <code>TypeCode</code>
  331. * object
  332. */
  333. public abstract Any member_label(int index)
  334. throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds;
  335. /**
  336. * Returns a <code>TypeCode</code> object describing
  337. * all non-default member labels.
  338. * The method <code>discriminator_type</code> can be invoked only
  339. * on union <code>TypeCode</code> objects.
  340. *
  341. * @return the <code>TypeCode</code> object describing
  342. * the non-default member labels
  343. * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
  344. * is invoked on a non-union <code>TypeCode</code>
  345. * object
  346. */
  347. public abstract TypeCode discriminator_type()
  348. throws BadKind;
  349. /**
  350. * Returns the index of the
  351. * default member, or -1 if there is no default member.
  352. * <P>
  353. * The method <code>default_index</code> can be invoked only on union
  354. * <code>TypeCode</code> objects.
  355. *
  356. * @return the index of the default member, or -1 if
  357. * there is no default member
  358. * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
  359. * is invoked on a non-union <code>TypeCode</code>
  360. * object
  361. */
  362. public abstract int default_index() throws BadKind;
  363. /**
  364. * Returns the number of elements in the type described by
  365. * this <code>TypeCode</code> object.
  366. * For strings and sequences, it returns the
  367. * bound, with zero indicating an unbounded string or sequence.
  368. * For arrays, it returns the number of elements in the array.
  369. * <P>
  370. * The method <code>length</code> can be invoked on string, sequence, and
  371. * array <code>TypeCode</code> objects.
  372. *
  373. * @return the bound for strings and sequences, or the
  374. * number of elements for arrays
  375. * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
  376. * is invoked on an inappropriate kind of <code>TypeCode</code>
  377. * object
  378. */
  379. public abstract int length() throws BadKind;
  380. /**
  381. * Returns the <code>TypeCode</code> object representing the
  382. * IDL type for the members of the object described by this
  383. * <code>TypeCode</code> object.
  384. * For sequences and arrays, it returns the
  385. * element type. For aliases, it returns the original type. Note
  386. * that multidimensional arrays are represented by nesting
  387. * <code>TypeCode</code> objects, one per dimension.
  388. * For boxed valuetypes, it returns the boxed type.
  389. *<P>
  390. * The method <code>content_type</code> can be invoked on sequence, array,
  391. * alias, and boxed valuetype <code>TypeCode</code> objects.
  392. *
  393. * @return a <code>TypeCode</code> object representing
  394. * the element type for sequences and arrays, the
  395. * original type for aliases, or the
  396. * boxed type for boxed valuetypes.
  397. * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
  398. * is invoked on an inappropriate kind of <code>TypeCode</code>
  399. * object
  400. */
  401. public abstract TypeCode content_type() throws BadKind;
  402. /**
  403. * Returns the number of digits in the fixed type described by this
  404. * <code>TypeCode</code> object. For example, the typecode for
  405. * the number 3000.275d could be <code>fixed<7,3></code>, where
  406. * 7 is the precision and 3 is the scale.
  407. *
  408. * @return the total number of digits
  409. * @throws org.omg.CORBA.TypeCodePackage.BadKind if this method
  410. * is invoked on an inappropriate kind of <code>TypeCode</code>
  411. * object
  412. *
  413. * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
  414. * comments for unimplemented features</a>
  415. */
  416. public short fixed_digits() throws BadKind {
  417. throw new org.omg.CORBA.NO_IMPLEMENT();
  418. }
  419. /**
  420. * Returns the scale of the fixed type described by this
  421. * <code>TypeCode</code> object. A positive number indicates the
  422. * number of digits to the right of the decimal point.
  423. * For example, the number 3000d could have the
  424. * typecode <code>fixed<4,0></code>, where the first number is
  425. * the precision and the second number is the scale.
  426. * A negative number is also possible and adds zeroes to the
  427. * left of the decimal point. In this case, <code>fixed<1,-3></code>,
  428. * could be the typecode for the number 3000d.
  429. *
  430. * @return the scale of the fixed type that this
  431. * <code>TypeCode</code> object describes
  432. * @throws org.omg.CORBA.TypeCodePackage.BadKind if this method
  433. * is invoked on an inappropriate kind of <code>TypeCode</code>
  434. * object
  435. * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
  436. * comments for unimplemented features</a>
  437. */
  438. public short fixed_scale() throws BadKind {
  439. throw new org.omg.CORBA.NO_IMPLEMENT();
  440. }
  441. /**
  442. * Returns the constant that indicates the visibility of the member
  443. * at the given index.
  444. *
  445. * This operation can only be invoked on non-boxed value
  446. * <code>TypeCode</code> objects.
  447. *
  448. * @param index an <code>int</code> indicating the index into the
  449. * value
  450. * @return either <code>PRIVATE_MEMBER.value</code> or
  451. * <code>PUBLIC_MEMBER.value</code>
  452. * @throws org.omg.CORBA.TypeCodePackage.BadKind if this method
  453. * is invoked on a non-value type <code>TypeCode</code>
  454. * object
  455. * @throws org.omg.CORBA.TypeCodePackage.Bounds
  456. * if the given index is out of bounds
  457. * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
  458. * comments for unimplemented features</a>
  459. */
  460. public short member_visibility(int index)
  461. throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds
  462. {
  463. throw new org.omg.CORBA.NO_IMPLEMENT();
  464. }
  465. /**
  466. * Returns a constant indicating the modifier of the value type
  467. * that this <code>TypeCode</code> object describes. The constant
  468. * returned must be one of the following: <code>VM_NONE.value</code>,
  469. * <code>VM_ABSTRACT.value</code>, <code>VM_CUSTOM.value</code>,
  470. * or <code>VM_TRUNCATABLE.value</code>,
  471. *
  472. * @return a constant describing the value type
  473. * that this <code>TypeCode</code> object describes
  474. * @throws org.omg.CORBA.TypeCodePackage.BadKind
  475. * if this method
  476. * is invoked on a non-value type <code>TypeCode</code>
  477. * object
  478. * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
  479. * comments for unimplemented features</a>
  480. */
  481. public short type_modifier() throws BadKind {
  482. throw new org.omg.CORBA.NO_IMPLEMENT();
  483. }
  484. /**
  485. * Returns the <code>TypeCode</code> object that describes the concrete base type
  486. * of the value type that this <code>TypeCode</code> object describes.
  487. * Returns null if it doesn't have a concrete base type.
  488. *
  489. * @return the <code>TypeCode</code> object that describes the
  490. * concrete base type of the value type
  491. * that this <code>TypeCode</code> object describes
  492. * @throws org.omg.CORBA.TypeCodePackage.BadKind if this method
  493. * is invoked on a non-boxed value type <code>TypeCode</code> object
  494. * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
  495. * comments for unimplemented features</a>
  496. */
  497. public TypeCode concrete_base_type() throws BadKind {
  498. throw new org.omg.CORBA.NO_IMPLEMENT();
  499. }
  500. }