duke@1: /* ohair@158: * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@158: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@158: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@158: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@158: * or visit www.oracle.com if you need additional information or have any ohair@158: * questions. duke@1: */ duke@1: duke@1: package org.omg.CORBA; duke@1: duke@1: import org.omg.CORBA.TypeCodePackage.*; duke@1: import org.omg.CORBA.portable.IDLEntity; duke@1: duke@1: /** duke@1: * A container for information about a specific CORBA data duke@1: * type. duke@1: *
duke@1: * TypeCode
objects are used:
duke@1: *
NamedValue
objects are used to represent arguments and
duke@1: * return values. One of their components is an Any
duke@1: * object, which in turn has as one of its components a
duke@1: * TypeCode
object.
duke@1: *
duke@1: * The representation of a TypeCode
object is opaque,
duke@1: * but abstractly, a TypeCode
object consists of:
duke@1: *
kind
field, which is set to an instance
duke@1: * of the class TCKind
duke@1: * TypeCode
object
duke@1: * describing the OMG IDL type 1ong
has kind
duke@1: * TCKind.tk_long
and no additional fields.
duke@1: * The TypeCode
describing OMG IDL type
duke@1: * sequence<boolean, 10>
has a kind
field
duke@1: * with the value
duke@1: * TCKind.tk_sequence
and also fields with the values
duke@1: * boolean
and 10
for the
duke@1: * type of sequence elements and the length of the sequence. duke@1: *
TypeCode
objects can be obtained in various ways:
duke@1: * Any.insert_X
, where X is
duke@1: * a basic IDL type. This method creates a TypeCode
object
duke@1: * for type X and assigns it to the Any
object's
duke@1: * type
field.
duke@1: * For example, the following creates a TypeCode
duke@1: * object for a string
with a maximum of 30 characters:
duke@1: *
duke@1: * org.omg.CORBA.TypeCode tcString = orb.create_string_tc(30); duke@1: *duke@1: *
The following creates a TypeCode
duke@1: * object for an array
of five string
s:
duke@1: *
duke@1: * org.omg.CORBA.TypeCode tcArray = orb.create_array_tc( duke@1: * 5, TCKind.tk_string); duke@1: *duke@1: *
The following creates a TypeCode
duke@1: * object for an interface named "Account":
duke@1: *
duke@1: * org.omg.CORBA.TypeCode tcInterface = orb.create_interface_tc( duke@1: * "thisId", "Account"); duke@1: *duke@1: *
_type
method
duke@1: * in Holder
classes for user-defined
duke@1: * IDL types. These Holder
classes are generated
duke@1: * by the idltojava
compiler.
duke@1: *
duke@1: * Most of the methods in the class TypeCode
duke@1: * are accessors, and the information contained in a TypeCode
duke@1: * object is specific to a particular type. Therefore, methods
duke@1: * must be invoked
duke@1: * only on the kind of type codes to which they apply. If an
duke@1: * accessor method
duke@1: * tries to access information from an inappropriate kind of
duke@1: * type code, it will throw
duke@1: * the exception TypeCodePackage.BadKind
. For example,
duke@1: * if the method discriminator_type
is called on anything
duke@1: * other than a union
, it will throw BadKind
duke@1: * because only union
s have a discriminator.
duke@1: * The following list shows which methods apply to which kinds of
duke@1: * type codes:
duke@1: *
duke@1: * These methods may be invoked on all TypeCode
kinds:
duke@1: *
equal
duke@1: * kind
duke@1: *
duke@1: * These methods may be invoked on objref
, struct
,
duke@1: * union
, enum
,
duke@1: * alias
, exception
, value
,
duke@1: * value_box
, native
,
duke@1: * and abstract_interface
:
duke@1: *
id
duke@1: * name
duke@1: *
duke@1: * These methods may be invoked on struct
,
duke@1: * union
, enum
,
duke@1: * and exception
:
duke@1: *
member_count
duke@1: * member_name
duke@1: *
duke@1: * These methods may be invoked on struct
,
duke@1: * union
, and exception
:
duke@1: *
member_type(int index)
duke@1: *
duke@1: * These methods may be invoked on union
:
duke@1: *
member_label
duke@1: * discriminator_type
duke@1: * default_index
duke@1: *
duke@1: * These methods may be invoked on string
,
duke@1: * sequence
, and array
:
duke@1: *
length
duke@1: *
duke@1: * These methods may be invoked on alias
,
duke@1: * sequence
, array
, and value_box
:
duke@1: *
content_type
duke@1: *
duke@1: * Unlike other CORBA pseudo-objects, TypeCode
duke@1: * objects can be passed as general IDL parameters.
duke@1: * The methods parameter
and param_count
,
duke@1: * which are deprecated, are not mapped.
duke@1: *
duke@1: * Java IDL extends the CORBA specification to allow all operations permitted
duke@1: * on a struct
TypeCode
to be permitted
duke@1: * on an exception
TypeCode
as well.
duke@1: *
duke@1: */
duke@1: public abstract class TypeCode implements IDLEntity {
duke@1:
duke@1: /**
duke@1: * Compares this TypeCode
object with the given one,
duke@1: * testing for equality. TypeCode
objects are equal if
duke@1: * they are interchangeable and give identical results when
duke@1: * TypeCode
operations are applied to them.
duke@1: *
duke@1: * @param tc the TypeCode
object to compare against
duke@1: * @return true
if the type codes are equal;
duke@1: * false
otherwise
duke@1: */
duke@1:
duke@1: public abstract boolean equal(TypeCode tc);
duke@1:
duke@1: /**
duke@1: * Tests to see if the given TypeCode
object is
duke@1: * equivalent to this TypeCode
object.
duke@1: *
duke@1: *
duke@1: *
duke@1: * @param tc the typecode to compare with this typecode
duke@1: *
duke@1: * @return true
if the given typecode is equivalent to
duke@1: * this typecode; false
otherwise
duke@1: *
duke@1: */
duke@1: public abstract boolean equivalent(TypeCode tc);
duke@1:
duke@1: /**
duke@1: * Strips out all optional name and member name fields,
duke@1: * but leaves all alias typecodes intact.
duke@1: * @return a TypeCode
object with optional name and
duke@1: * member name fields stripped out, except for alias typecodes,
duke@1: * which are left intact
duke@1: * @see CORBA
package
duke@1: * comments for unimplemented features
duke@1: */
duke@1: public abstract TypeCode get_compact_typecode();
duke@1:
duke@1:
duke@1: /**
duke@1: * Retrieves the kind of this TypeCode
object.
duke@1: * The kind of a type code determines which TypeCode
duke@1: * methods may legally be invoked on it.
duke@1: *
duke@1: * The method kind
may be invoked on any
duke@1: * TypeCode
object.
duke@1: *
duke@1: * @return the TCKind
instance indicating the
duke@1: * value of the kind
field of this
duke@1: * TypeCode
object
duke@1: */
duke@1:
duke@1: public abstract TCKind kind();
duke@1:
duke@1: /**
duke@1: * Retrieves the RepositoryId globally identifying the type
duke@1: * of this TypeCode
object.
duke@1: *
duke@1: * The method id
can be invoked on object reference,
duke@1: * structure, union, enumeration, alias, exception, valuetype,
duke@1: * boxed valuetype, native, and abstract interface type codes.
duke@1: * Object reference, exception, valuetype, boxed valuetype,
duke@1: * native, and abstract interface TypeCode
objects
duke@1: * always have a RepositoryId.
duke@1: * Structure, union, enumeration, and alias TypeCode
objects
duke@1: * obtained from the Interface Repository or the method
duke@1: * ORB.create_operation_list
duke@1: * also always have a RepositoryId. If there is no RepositoryId, the
duke@1: * method can return an empty string.
duke@1: *
duke@1: * @return the RepositoryId for this TypeCode
object
duke@1: * or an empty string if there is no RepositoryID
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
duke@1: * is invoked on an inappropriate kind ofTypeCode
duke@1: * object
duke@1: */
duke@1:
duke@1: public abstract String id() throws BadKind;
duke@1:
duke@1: /**
duke@1: * Retrieves the simple name identifying this TypeCode
duke@1: * object within its
duke@1: * enclosing scope. Since names are local to a Repository, the
duke@1: * name returned from a TypeCode
object
duke@1: * may not match the name of the
duke@1: * type in any particular Repository, and may even be an empty
duke@1: * string.
duke@1: *
duke@1: * The method name
can be invoked on object reference,
duke@1: * structure, union, enumeration, alias, exception, valuetype,
duke@1: * boxed valuetype, native, and abstract interface
duke@1: * TypeCode
objects.
duke@1: *
duke@1: * @return the name identifying this TypeCode
object
duke@1: * or an empty string
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
duke@1: * is invoked on an inappropriate kind ofTypeCode
duke@1: * object
duke@1: */
duke@1:
duke@1: public abstract String name() throws BadKind;
duke@1:
duke@1: /**
duke@1: * Retrieves the number of members in the type described by
duke@1: * this TypeCode
object.
duke@1: *
duke@1: * The method member_count
can be invoked on
duke@1: * structure, union, and enumeration TypeCode
objects.
duke@1: * Java IDL extends the CORBA specification to allow this method to
duke@1: * operate on exceptions as well.
duke@1: *
duke@1: * @return the number of members constituting the type described
duke@1: * by this TypeCode
object
duke@1: *
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
duke@1: * is invoked on an inappropriate kind of TypeCode
duke@1: * object
duke@1: */
duke@1:
duke@1: public abstract int member_count() throws BadKind;
duke@1:
duke@1: /**
duke@1: * Retrieves the simple name of the member identified by
duke@1: * the given index. Since names are local to a
duke@1: * Repository, the name returned from a TypeCode
object
duke@1: * may not match the name of the member in any particular
duke@1: * Repository, and may even be an empty string.
duke@1: *
duke@1: * The method member_name
can be invoked on structure, union,
duke@1: * and enumeration TypeCode
objects.
duke@1: * Java IDL extends the CORBA specification to allow this method to
duke@1: * operate on exceptions as well.
duke@1: *
duke@1: * @param index index of the member for which a name is being reqested
duke@1: * @return simple name of the member identified by the
duke@1: * index or an empty string
duke@1: * @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is equal
duke@1: * to or greater than
duke@1: * the number of members constituting the type
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
duke@1: * is invoked on an inappropriate kind of TypeCode
duke@1: * object
duke@1: */
duke@1:
duke@1: public abstract String member_name(int index)
duke@1: throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds;
duke@1:
duke@1: /**
duke@1: * Retrieves the TypeCode
object describing the type
duke@1: * of the member identified by the given index.
duke@1: *
duke@1: * The method member_type
can be invoked on structure
duke@1: * and union TypeCode
objects.
duke@1: * Java IDL extends the CORBA specification to allow this method to
duke@1: * operate on exceptions as well.
duke@1: *
duke@1: * @param index index of the member for which type information
duke@1: * is begin requested
duke@1: * @return the TypeCode
object describing the
duke@1: * member at the given index
duke@1: * @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is
duke@1: * equal to or greater than
duke@1: * the number of members constituting the type
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
duke@1: * is invoked on an inappropriate kind of TypeCode
duke@1: * object
duke@1: */
duke@1:
duke@1: public abstract TypeCode member_type(int index)
duke@1: throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds;
duke@1:
duke@1: /**
duke@1: * Retrieves the label of the union member
duke@1: * identified by the given index. For the default member,
duke@1: * the label is the zero octet.
duke@1: *
duke@1: * The method member_label
can only be invoked on union
duke@1: * TypeCode
objects.
duke@1: *
duke@1: * @param index index of the union member for which the
duke@1: * label is being requested
duke@1: * @return an Any
object describing the label of
duke@1: * the requested union member or the zero octet for
duke@1: * the default member
duke@1: * @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is
duke@1: * equal to or greater than
duke@1: * the number of members constituting the union
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
duke@1: * is invoked on a non-union TypeCode
duke@1: * object
duke@1: */
duke@1:
duke@1: public abstract Any member_label(int index)
duke@1: throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds;
duke@1:
duke@1: /**
duke@1: * Returns a TypeCode
object describing
duke@1: * all non-default member labels.
duke@1: * The method discriminator_type
can be invoked only
duke@1: * on union TypeCode
objects.
duke@1: *
duke@1: * @return the TypeCode
object describing
duke@1: * the non-default member labels
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
duke@1: * is invoked on a non-union TypeCode
duke@1: * object
duke@1: */
duke@1:
duke@1: public abstract TypeCode discriminator_type()
duke@1: throws BadKind;
duke@1:
duke@1: /**
duke@1: * Returns the index of the
duke@1: * default member, or -1 if there is no default member.
duke@1: *
duke@1: * The method default_index
can be invoked only on union
duke@1: * TypeCode
objects.
duke@1: *
duke@1: * @return the index of the default member, or -1 if
duke@1: * there is no default member
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
duke@1: * is invoked on a non-union TypeCode
duke@1: * object
duke@1: */
duke@1:
duke@1: public abstract int default_index() throws BadKind;
duke@1:
duke@1: /**
duke@1: * Returns the number of elements in the type described by
duke@1: * this TypeCode
object.
duke@1: * For strings and sequences, it returns the
duke@1: * bound, with zero indicating an unbounded string or sequence.
duke@1: * For arrays, it returns the number of elements in the array.
duke@1: *
duke@1: * The method length
can be invoked on string, sequence, and
duke@1: * array TypeCode
objects.
duke@1: *
duke@1: * @return the bound for strings and sequences, or the
duke@1: * number of elements for arrays
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
duke@1: * is invoked on an inappropriate kind of TypeCode
duke@1: * object
duke@1: */
duke@1:
duke@1: public abstract int length() throws BadKind;
duke@1:
duke@1: /**
duke@1: * Returns the TypeCode
object representing the
duke@1: * IDL type for the members of the object described by this
duke@1: * TypeCode
object.
duke@1: * For sequences and arrays, it returns the
duke@1: * element type. For aliases, it returns the original type. Note
duke@1: * that multidimensional arrays are represented by nesting
duke@1: * TypeCode
objects, one per dimension.
duke@1: * For boxed valuetypes, it returns the boxed type.
duke@1: *
duke@1: * The method content_type
can be invoked on sequence, array,
duke@1: * alias, and boxed valuetype TypeCode
objects.
duke@1: *
duke@1: * @return a TypeCode
object representing
duke@1: * the element type for sequences and arrays, the
duke@1: * original type for aliases, or the
duke@1: * boxed type for boxed valuetypes.
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
duke@1: * is invoked on an inappropriate kind of TypeCode
duke@1: * object
duke@1: */
duke@1:
duke@1: public abstract TypeCode content_type() throws BadKind;
duke@1:
duke@1:
duke@1: /**
duke@1: * Returns the number of digits in the fixed type described by this
duke@1: * TypeCode
object. For example, the typecode for
duke@1: * the number 3000.275d could be fixed<7,3>
, where
duke@1: * 7 is the precision and 3 is the scale.
duke@1: *
duke@1: * @return the total number of digits
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if this method
duke@1: * is invoked on an inappropriate kind of TypeCode
duke@1: * object
duke@1: *
duke@1: */
duke@1: public abstract short fixed_digits() throws BadKind ;
duke@1:
duke@1: /**
duke@1: * Returns the scale of the fixed type described by this
duke@1: * TypeCode
object. A positive number indicates the
duke@1: * number of digits to the right of the decimal point.
duke@1: * For example, the number 3000d could have the
duke@1: * typecode fixed<4,0>
, where the first number is
duke@1: * the precision and the second number is the scale.
duke@1: * A negative number is also possible and adds zeroes to the
duke@1: * left of the decimal point. In this case, fixed<1,-3>
,
duke@1: * could be the typecode for the number 3000d.
duke@1: *
duke@1: * @return the scale of the fixed type that this
duke@1: * TypeCode
object describes
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if this method
duke@1: * is invoked on an inappropriate kind of TypeCode
duke@1: * object
duke@1: */
duke@1: public abstract short fixed_scale() throws BadKind ;
duke@1:
duke@1: /**
duke@1: * Returns the constant that indicates the visibility of the member
duke@1: * at the given index.
duke@1: *
duke@1: * This operation can only be invoked on non-boxed value
duke@1: * TypeCode
objects.
duke@1: *
duke@1: * @param index an int
indicating the index into the
duke@1: * value
duke@1: * @return either PRIVATE_MEMBER.value
or
duke@1: * PUBLIC_MEMBER.value
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if this method
duke@1: * is invoked on a non-value type TypeCode
duke@1: * object
duke@1: * @throws org.omg.CORBA.TypeCodePackage.Bounds
duke@1: * if the given index is out of bounds
duke@1: * @see CORBA
package
duke@1: * comments for unimplemented features
duke@1: */
duke@1:
duke@1: abstract public short member_visibility(int index)
duke@1: throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds ;
duke@1:
duke@1: /**
duke@1: * Returns a constant indicating the modifier of the value type
duke@1: * that this TypeCode
object describes. The constant
duke@1: * returned must be one of the following: VM_NONE.value
,
duke@1: * VM_ABSTRACT.value
, VM_CUSTOM.value
,
duke@1: * or VM_TRUNCATABLE.value
,
duke@1: *
duke@1: * @return a constant describing the value type
duke@1: * that this TypeCode
object describes
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind
duke@1: * if this method
duke@1: * is invoked on a non-value type TypeCode
duke@1: * object
duke@1: * @see CORBA
package
duke@1: * comments for unimplemented features
duke@1: */
duke@1:
duke@1: abstract public short type_modifier() throws BadKind ;
duke@1:
duke@1: /**
duke@1: * Returns the TypeCode
object that describes the concrete base type
duke@1: * of the value type that this TypeCode
object describes.
duke@1: * Returns null if it doesn't have a concrete base type.
duke@1: *
duke@1: * @return the TypeCode
object that describes the
duke@1: * concrete base type of the value type
duke@1: * that this TypeCode
object describes
duke@1: * @throws org.omg.CORBA.TypeCodePackage.BadKind if this method
duke@1: * is invoked on a non-boxed value type TypeCode
object
duke@1: * @see CORBA
package
duke@1: * comments for unimplemented features
duke@1: */
duke@1:
duke@1: abstract public TypeCode concrete_base_type() throws BadKind ;
duke@1: }