001/* TypeCode.java --
002   Copyright (C) 2005 Free Software Foundation, Inc.
003
004This file is part of GNU Classpath.
005
006GNU Classpath is free software; you can redistribute it and/or modify
007it under the terms of the GNU General Public License as published by
008the Free Software Foundation; either version 2, or (at your option)
009any later version.
010
011GNU Classpath is distributed in the hope that it will be useful, but
012WITHOUT ANY WARRANTY; without even the implied warranty of
013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014General Public License for more details.
015
016You should have received a copy of the GNU General Public License
017along with GNU Classpath; see the file COPYING.  If not, write to the
018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
01902110-1301 USA.
020
021Linking this library statically or dynamically with other modules is
022making a combined work based on this library.  Thus, the terms and
023conditions of the GNU General Public License cover the whole
024combination.
025
026As a special exception, the copyright holders of this library give you
027permission to link this library with independent modules to produce an
028executable, regardless of the license terms of these independent
029modules, and to copy and distribute the resulting executable under
030terms of your choice, provided that you also meet, for each linked
031independent module, the terms and conditions of the license of that
032module.  An independent module is a module which is not derived from
033or based on this library.  If you modify this library, you may extend
034this exception to your version of the library, but you are not
035obligated to do so.  If you do not wish to do so, delete this
036exception statement from your version. */
037
038
039package org.omg.CORBA;
040
041import org.omg.CORBA.TypeCodePackage.BadKind;
042import org.omg.CORBA.portable.IDLEntity;
043
044import java.io.Serializable;
045
046/**
047 * An information about a CORBA data type.
048 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
049 */
050public abstract class TypeCode
051  implements IDLEntity, Serializable
052{
053  /**
054   * Use serialVersionUID for interoperability.
055   * Using the version 1.4 UID.
056   */
057  private static final long serialVersionUID = -6521025782489515676L;
058
059  /**
060   * For value types that support inheritance this method returns the
061   * of the ancestor type code.
062   *
063   * @return the ancestor TypeCode.
064   *
065   * @throws BadKind for all typecodes except the value type typecodes.
066   */
067  public abstract TypeCode concrete_base_type()
068                                       throws BadKind;
069
070  /**
071   * For sequences, arrays, aliases and value boxes, returns the IDL type for
072   * the members of the object.
073   * @return a TypeCode of the memebers of this type.
074   * @throws BadKind for types other than
075   * sequences, arrays, aliases and value boxes.
076   */
077  public abstract TypeCode content_type()
078                                 throws BadKind;
079
080  /**
081   * For unions, returs the index of the default member.
082   * @return the index of the default member, -1 if there is
083   * no default member.
084   * @throws BadKind if this type is not
085   * a union.
086   */
087  public abstract int default_index()
088                             throws BadKind;
089
090  /**
091   * Returs definition of member labels for untions
092   * @return a TypeCode, describing all non-default member labels.
093   * @throws BadKind if this type is not a
094   * union.
095   */
096  public abstract TypeCode discriminator_type()
097                                       throws BadKind;
098
099  /**
100   * Test two types for equality.
101   *
102   * @param other the other type to compere with
103   * @return true if the types are interchangeable.
104   */
105  public abstract boolean equal(TypeCode other);
106
107  /**
108   * Following the current 1.4 API specifcation, this should just throw
109   * NO_IMPLEMENT.
110   * @throws org.omg.CORBA.NO_IMPLEMENT, always.
111   */
112  public abstract boolean equivalent(TypeCode other);
113
114  /**
115   * For the fixed type, returns the number of digits.
116   * @return the number of digits for the fixed type
117   * @throws BadKind if this is not a fixed
118   * type.
119   */
120  public abstract short fixed_digits()
121                              throws BadKind;
122
123  /**
124   * Returns the scale for the fixed type. The returned value can be either
125   * positive (the number of digits to the right of the decimal point) or
126   * negative (adds zeros to the left of the decimal point).
127   * @return the scale.
128   * @throws BadKind if this is not a fixed
129   * type.
130   */
131  public abstract short fixed_scale()
132                             throws BadKind;
133
134  /**
135   * Returns a version of this instance without the optional memeber and
136   * member name fields.
137   * @return the truncated version.
138   */
139  public abstract TypeCode get_compact_typecode();
140
141  /**
142   * Returns the RepositoryId globally identifying the type, defined by
143   * this TypeCode.
144   * @return tje RepositoryId. In some cases, it may be an empty string.
145   * @throws BadKind if the type is other than
146   * reference, structure, union, enumeration, alias, exception, valuetype,
147   * boxed valuetype and also native and abstract interfaces.
148   */
149  public abstract String id()
150                     throws BadKind;
151
152  /**
153   * Return the kind of this type code object.
154   * @return one of the <code>TCKind.t_..</code> fields.
155   */
156  public abstract TCKind kind();
157
158  /**
159   * Returns the number of elements in the type. For arrays, this
160   * method returns the length of the array. For strings and sequences,
161   * it returns the bound of the type, zero indicating the unbounded
162   * type.
163   *
164   * @return length or bound
165   *
166   * @throws BadKind for types other than
167   * string, sequence and array.
168   */
169  public abstract int length()
170                      throws BadKind;
171
172  /**
173   * Returns the number of type memebers.
174   *
175   * @return the number of memebers
176   * @throws BadKind for types other than
177   * structure, union, enumeration or exception.
178   */
179  public abstract int member_count()
180                            throws BadKind;
181
182  /**
183   * Retrieves the label of the union member at the given index.
184   * For the default member, this label is the zero octet.
185   *
186   * @param index the index of the union memeber.
187   *
188   * @return the label
189   *
190   * @throws BadKind if this is not a union
191   * type.
192   * @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is out of
193   * valid bounds.
194   */
195  public abstract Any member_label(int index)
196                            throws BadKind,
197                                   org.omg.CORBA.TypeCodePackage.Bounds;
198
199  /**
200   * Retrieves the simple name of the member identified by the given index.
201   *
202   * @param index the index of the memeber.
203   *
204   * @return the member name that in some cases can be an empty string.
205   *
206   * @throws BadKind for types other than
207   * structure, union or enumeration.
208   * @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is out of
209   * valid bounds.
210   */
211  public abstract String member_name(int index)
212                              throws BadKind,
213                                     org.omg.CORBA.TypeCodePackage.Bounds;
214
215  /**
216   * Retrieves the member type of the member identified by the given index.
217   *
218   * @param index the index of the memeber.
219   *
220   * @return the member type.
221   *
222   * @throws BadKind for types other than
223   * structure, union, enumeration or exception.
224   * @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is out of
225   * valid bounds.
226   */
227  public abstract TypeCode member_type(int index)
228                                throws BadKind,
229                                       org.omg.CORBA.TypeCodePackage.Bounds;
230
231  /**
232   * Returns the visibility scope of the member at the given index.
233   * This operation can only be invoked on non-boxed value types.
234   *
235   * @param index the index of the member
236   *
237   * @return either PRIVATE_MEMBER.value or PUBLIC_MEMBER.value
238   *
239   * @throws BadKind if this is not a non boxed
240   * value type.
241   *
242   * @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is out of
243   * valid bounds.
244   */
245  public abstract short member_visibility(int index)
246                                   throws BadKind,
247                                          org.omg.CORBA.TypeCodePackage.Bounds;
248
249  /**
250   * Retrieves the simple name identifying this TypeCode object
251   * within its enclosing scope.
252   * @return the name, can be an empty string.
253   * @throws BadKind for typer other than
254   * reference, structure, union, enumeration, alias, exception,
255   * valuetype, boxed valuetype, native, and abstract interface
256   */
257  public abstract String name()
258                       throws BadKind;
259
260  /**
261   * Returns a constant indicating the modifier of the value type.
262   *
263   * @return one of the following constants:
264   * VM_NONE.value, VM_ABSTRACT.value, VM_CUSTOM.value, or
265   * VM_TRUNCATABLE.value,
266   *
267   * @throws BadKind for all types other than value type.
268   */
269  public abstract short type_modifier()
270                               throws BadKind;
271}