- java.lang.Object
-
- org.omg.CORBA.TypeCode
-
- All Implemented Interfaces:
Serializable,IDLEntity
public abstract class TypeCode extends Object implements IDLEntity
A container for information about a specific CORBA data type.TypeCodeobjects are used:- in the Dynamic Invocation Interface -- to indicate the types
of the actual arguments or the type of the return value.
NamedValueobjects are used to represent arguments and return values. One of their components is anAnyobject, which in turn has as one of its components aTypeCodeobject. - by an Interface Repository to represent the type specifications that are part of many OMG IDL declarations
The representation of a
TypeCodeobject is opaque, but abstractly, aTypeCodeobject consists of:- a
kindfield, which is set to an instance of the classTCKind - zero or more additional fields appropriate
for the particular kind. For example, the
TypeCodeobject describing the OMG IDL type1onghas kindTCKind.tk_longand no additional fields. TheTypeCodedescribing OMG IDL typesequence<boolean, 10>has akindfield with the valueTCKind.tk_sequenceand also fields with the valuesbooleanand10for the type of sequence elements and the length of the sequence.
TypeCodeobjects can be obtained in various ways:- from a call to the method
Any.insert_X, where X is a basic IDL type. This method creates aTypeCodeobject for type X and assigns it to theAnyobject'stypefield. - from invocations of methods in the ORB class
For example, the following creates a
TypeCodeobject for astringwith a maximum of 30 characters:org.omg.CORBA.TypeCode tcString = orb.create_string_tc(30);
The following creates a
TypeCodeobject for anarrayof fivestrings:org.omg.CORBA.TypeCode tcArray = orb.create_array_tc( 5, TCKind.tk_string);The following creates a
TypeCodeobject for an interface named "Account":org.omg.CORBA.TypeCode tcInterface = orb.create_interface_tc( "thisId", "Account"); - as the return value from the
_typemethod inHolderclasses for user-defined IDL types. TheseHolderclasses are generated by theidltojavacompiler. - from a CORBA Interface Repository
Most of the methods in the class
TypeCodeare accessors, and the information contained in aTypeCodeobject is specific to a particular type. Therefore, methods must be invoked only on the kind of type codes to which they apply. If an accessor method tries to access information from an inappropriate kind of type code, it will throw the exceptionTypeCodePackage.BadKind. For example, if the methoddiscriminator_typeis called on anything other than aunion, it will throwBadKindbecause onlyunions have a discriminator. The following list shows which methods apply to which kinds of type codes:These methods may be invoked on all
TypeCodekinds:equalkind
These methods may be invoked on
objref,struct,union,enum,alias,exception,value,value_box,native, andabstract_interface:idname
These methods may be invoked on
struct,union,enum, andexception:member_countmember_name
These methods may be invoked on
struct,union, andexception:member_type(int index)
These methods may be invoked on
union:member_labeldiscriminator_typedefault_index
These methods may be invoked on
string,sequence, andarray:length
These methods may be invoked on
alias,sequence,array, andvalue_box:content_type
Unlike other CORBA pseudo-objects,
TypeCodeobjects can be passed as general IDL parameters.The methods
parameterandparam_count, which are deprecated, are not mapped.Java IDL extends the CORBA specification to allow all operations permitted on a
structTypeCodeto be permitted on anexceptionTypeCodeas well.
-
-
Constructor Summary
Constructors Constructor Description TypeCode()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract TypeCodeconcrete_base_type()Returns theTypeCodeobject that describes the concrete base type of the value type that thisTypeCodeobject describes.abstract TypeCodecontent_type()Returns theTypeCodeobject representing the IDL type for the members of the object described by thisTypeCodeobject.abstract intdefault_index()Returns the index of the default member, or -1 if there is no default member.abstract TypeCodediscriminator_type()Returns aTypeCodeobject describing all non-default member labels.abstract booleanequal(TypeCode tc)Compares thisTypeCodeobject with the given one, testing for equality.abstract booleanequivalent(TypeCode tc)Tests to see if the givenTypeCodeobject is equivalent to thisTypeCodeobject.abstract shortfixed_digits()Returns the number of digits in the fixed type described by thisTypeCodeobject.abstract shortfixed_scale()Returns the scale of the fixed type described by thisTypeCodeobject.abstract TypeCodeget_compact_typecode()Strips out all optional name and member name fields, but leaves all alias typecodes intact.abstract Stringid()Retrieves the RepositoryId globally identifying the type of thisTypeCodeobject.abstract TCKindkind()Retrieves the kind of thisTypeCodeobject.abstract intlength()Returns the number of elements in the type described by thisTypeCodeobject.abstract intmember_count()Retrieves the number of members in the type described by thisTypeCodeobject.abstract Anymember_label(int index)Retrieves the label of the union member identified by the given index.abstract Stringmember_name(int index)Retrieves the simple name of the member identified by the given index.abstract TypeCodemember_type(int index)Retrieves theTypeCodeobject describing the type of the member identified by the given index.abstract shortmember_visibility(int index)Returns the constant that indicates the visibility of the member at the given index.abstract Stringname()Retrieves the simple name identifying thisTypeCodeobject within its enclosing scope.abstract shorttype_modifier()Returns a constant indicating the modifier of the value type that thisTypeCodeobject describes.
-
-
-
Method Detail
-
equal
public abstract boolean equal(TypeCode tc)
Compares thisTypeCodeobject with the given one, testing for equality.TypeCodeobjects are equal if they are interchangeable and give identical results whenTypeCodeoperations are applied to them.- Parameters:
tc- theTypeCodeobject to compare against- Returns:
trueif the type codes are equal;falseotherwise
-
equivalent
public abstract boolean equivalent(TypeCode tc)
Tests to see if the givenTypeCodeobject is equivalent to thisTypeCodeobject.- Parameters:
tc- the typecode to compare with this typecode- Returns:
trueif the given typecode is equivalent to this typecode;falseotherwise
-
get_compact_typecode
public abstract TypeCode get_compact_typecode()
Strips out all optional name and member name fields, but leaves all alias typecodes intact.- Returns:
- a
TypeCodeobject with optional name and member name fields stripped out, except for alias typecodes, which are left intact - See Also:
CORBApackage comments for unimplemented features
-
kind
public abstract TCKind kind()
Retrieves the kind of thisTypeCodeobject. The kind of a type code determines whichTypeCodemethods may legally be invoked on it.The method
kindmay be invoked on anyTypeCodeobject.- Returns:
- the
TCKindinstance indicating the value of thekindfield of thisTypeCodeobject
-
id
public abstract String id() throws BadKind
Retrieves the RepositoryId globally identifying the type of thisTypeCodeobject.The method
idcan be invoked on object reference, structure, union, enumeration, alias, exception, valuetype, boxed valuetype, native, and abstract interface type codes. Object reference, exception, valuetype, boxed valuetype, native, and abstract interfaceTypeCodeobjects always have a RepositoryId. Structure, union, enumeration, and aliasTypeCodeobjects obtained from the Interface Repository or the methodORB.create_operation_listalso always have a RepositoryId. If there is no RepositoryId, the method can return an empty string.- Returns:
- the RepositoryId for this
TypeCodeobject or an empty string if there is no RepositoryID - Throws:
BadKind- if the method is invoked on an inappropriate kind ofTypeCodeobject
-
name
public abstract String name() throws BadKind
Retrieves the simple name identifying thisTypeCodeobject within its enclosing scope. Since names are local to a Repository, the name returned from aTypeCodeobject may not match the name of the type in any particular Repository, and may even be an empty string.The method
namecan be invoked on object reference, structure, union, enumeration, alias, exception, valuetype, boxed valuetype, native, and abstract interfaceTypeCodeobjects.- Returns:
- the name identifying this
TypeCodeobject or an empty string - Throws:
BadKind- if the method is invoked on an inappropriate kind ofTypeCodeobject
-
member_count
public abstract int member_count() throws BadKindRetrieves the number of members in the type described by thisTypeCodeobject.The method
member_countcan be invoked on structure, union, and enumerationTypeCodeobjects. Java IDL extends the CORBA specification to allow this method to operate on exceptions as well.- Returns:
- the number of members constituting the type described
by this
TypeCodeobject - Throws:
BadKind- if the method is invoked on an inappropriate kind ofTypeCodeobject
-
member_name
public abstract String member_name(int index) throws BadKind, Bounds
Retrieves the simple name of the member identified by the given index. Since names are local to a Repository, the name returned from aTypeCodeobject may not match the name of the member in any particular Repository, and may even be an empty string.The method
member_namecan be invoked on structure, union, and enumerationTypeCodeobjects. Java IDL extends the CORBA specification to allow this method to operate on exceptions as well.- Parameters:
index- index of the member for which a name is being reqested- Returns:
- simple name of the member identified by the index or an empty string
- Throws:
Bounds- if the index is equal to or greater than the number of members constituting the typeBadKind- if the method is invoked on an inappropriate kind ofTypeCodeobject
-
member_type
public abstract TypeCode member_type(int index) throws BadKind, Bounds
Retrieves theTypeCodeobject describing the type of the member identified by the given index.The method
member_typecan be invoked on structure and unionTypeCodeobjects. Java IDL extends the CORBA specification to allow this method to operate on exceptions as well.- Parameters:
index- index of the member for which type information is begin requested- Returns:
- the
TypeCodeobject describing the member at the given index - Throws:
Bounds- if the index is equal to or greater than the number of members constituting the typeBadKind- if the method is invoked on an inappropriate kind ofTypeCodeobject
-
member_label
public abstract Any member_label(int index) throws BadKind, Bounds
Retrieves the label of the union member identified by the given index. For the default member, the label is the zero octet.The method
member_labelcan only be invoked on unionTypeCodeobjects.- Parameters:
index- index of the union member for which the label is being requested- Returns:
- an
Anyobject describing the label of the requested union member or the zero octet for the default member - Throws:
Bounds- if the index is equal to or greater than the number of members constituting the unionBadKind- if the method is invoked on a non-unionTypeCodeobject
-
discriminator_type
public abstract TypeCode discriminator_type() throws BadKind
Returns aTypeCodeobject describing all non-default member labels. The methoddiscriminator_typecan be invoked only on unionTypeCodeobjects.- Returns:
- the
TypeCodeobject describing the non-default member labels - Throws:
BadKind- if the method is invoked on a non-unionTypeCodeobject
-
default_index
public abstract int default_index() throws BadKindReturns the index of the default member, or -1 if there is no default member.The method
default_indexcan be invoked only on unionTypeCodeobjects.- Returns:
- the index of the default member, or -1 if there is no default member
- Throws:
BadKind- if the method is invoked on a non-unionTypeCodeobject
-
length
public abstract int length() throws BadKindReturns the number of elements in the type described by thisTypeCodeobject. For strings and sequences, it returns the bound, with zero indicating an unbounded string or sequence. For arrays, it returns the number of elements in the array.The method
lengthcan be invoked on string, sequence, and arrayTypeCodeobjects.- Returns:
- the bound for strings and sequences, or the number of elements for arrays
- Throws:
BadKind- if the method is invoked on an inappropriate kind ofTypeCodeobject
-
content_type
public abstract TypeCode content_type() throws BadKind
Returns theTypeCodeobject representing the IDL type for the members of the object described by thisTypeCodeobject. For sequences and arrays, it returns the element type. For aliases, it returns the original type. Note that multidimensional arrays are represented by nestingTypeCodeobjects, one per dimension. For boxed valuetypes, it returns the boxed type.The method
content_typecan be invoked on sequence, array, alias, and boxed valuetypeTypeCodeobjects.- Returns:
- a
TypeCodeobject representing the element type for sequences and arrays, the original type for aliases, or the boxed type for boxed valuetypes. - Throws:
BadKind- if the method is invoked on an inappropriate kind ofTypeCodeobject
-
fixed_digits
public abstract short fixed_digits() throws BadKindReturns the number of digits in the fixed type described by thisTypeCodeobject. For example, the typecode for the number 3000.275d could befixed<7,3>, where 7 is the precision and 3 is the scale.- Returns:
- the total number of digits
- Throws:
BadKind- if this method is invoked on an inappropriate kind ofTypeCodeobject
-
fixed_scale
public abstract short fixed_scale() throws BadKindReturns the scale of the fixed type described by thisTypeCodeobject. A positive number indicates the number of digits to the right of the decimal point. For example, the number 3000d could have the typecodefixed<4,0>, where the first number is the precision and the second number is the scale. A negative number is also possible and adds zeroes to the left of the decimal point. In this case,fixed<1,-3>, could be the typecode for the number 3000d.- Returns:
- the scale of the fixed type that this
TypeCodeobject describes - Throws:
BadKind- if this method is invoked on an inappropriate kind ofTypeCodeobject
-
member_visibility
public abstract short member_visibility(int index) throws BadKind, BoundsReturns the constant that indicates the visibility of the member at the given index. This operation can only be invoked on non-boxed valueTypeCodeobjects.- Parameters:
index- anintindicating the index into the value- Returns:
- either
PRIVATE_MEMBER.valueorPUBLIC_MEMBER.value - Throws:
BadKind- if this method is invoked on a non-value typeTypeCodeobjectBounds- if the given index is out of bounds- See Also:
CORBApackage comments for unimplemented features
-
type_modifier
public abstract short type_modifier() throws BadKindReturns a constant indicating the modifier of the value type that thisTypeCodeobject describes. The constant returned must be one of the following:VM_NONE.value,VM_ABSTRACT.value,VM_CUSTOM.value, orVM_TRUNCATABLE.value,- Returns:
- a constant describing the value type
that this
TypeCodeobject describes - Throws:
BadKind- if this method is invoked on a non-value typeTypeCodeobject- See Also:
CORBApackage comments for unimplemented features
-
concrete_base_type
public abstract TypeCode concrete_base_type() throws BadKind
Returns theTypeCodeobject that describes the concrete base type of the value type that thisTypeCodeobject describes. Returns null if it doesn't have a concrete base type.- Returns:
- the
TypeCodeobject that describes the concrete base type of the value type that thisTypeCodeobject describes - Throws:
BadKind- if this method is invoked on a non-boxed value typeTypeCodeobject- See Also:
CORBApackage comments for unimplemented features
-
-