TypeCode implements the IDL pseudo interface TypeCode. TypeCode is used to describe arbitrary complex IDL type structures at runtime. A TypeCode consists of a kind and a sequence of parameters (a parameter is of type CORBA.Any). The kind classifies the TypeCode: for example, whether it is an IDL basic type, a struct, a sequence and so on. TypeCode constant values are defined in the OrbixWeb class TCKind. The parameters give the details of the type definition. For example, the IDL type sequence<long, 20> has the kind TCKind.tk_sequence and has parameters long and 20.The parameters of each
TypeCode are:|
KIND
|
PARAMETER LIST
|
|---|---|
TCKind.tk_null | NONE |
TCKind.tk_void | NONE |
TCKind.tk_short | NONE |
TCKind.tk_long | NONE |
TCKind.tk_ushort | NONE |
TCKind.tk_ulong | NONE |
TCKind.tk_float | NONE |
TCKind.tk_double | NONE |
TCKind.tk_boolean | NONE |
TCKind.tk_char | NONE |
TCKind.tk_octet | NONE |
TCKind.tk_any | NONE |
TCKind.tk_TypeCode | NONE |
TCKind.tk_Principal | NONE |
TCKind.tk_objref | { interface-id }
|
TCKind.tk_struct | { struct-name,
member-name, TypeCode,
...<repeat pairs>... }
|
TCKind.tk_union | { union-name, switch-TypeCode,
label-value, member-name,
TypeCode,
...<repeat triples>... }
|
TCKind.tk_enum | { enum-name, enum-id,
...<repeat enum-id>... }
|
TCKind.tk_string | { maxlen-integer }
|
TCKind.tk_sequence | { TypeCode, maxlen-integer }
|
TCKind.tk_array | { TypeCode, length-integer,
<repeat length-integer>... }
|
A
TypeCode of kind TCKind.tk_objref has a single parameter giving the interface name.A
TypeCode of kind TCKind.tk_struct has one parameter giving the struct name, and has two parameters for each member of the struct: the first giving the member's name and the second giving its TypeCode. A struct with N members has 2N+1 parameters.A
TypeCode of kind TCKind.tk_union has parameters giving the union name, the TypeCode of the switch (discriminator) of the union, and then three parameters for each member of the union: the first giving the label value, the second giving the member name and the third giving the member's TypeCode. If the union has a default member then the triple for this will have a label-value of 0 and the TypeCode of the corresponding any returned by parameter() will be the TypeCode for an octet, which is not a valid switch type for a union. Thus this 0 can be distinguished from a normal 0 switch value.A
TypeCode of kind TCKind.tk_enum has one parameter giving the enum name, and then one parameter for each enumerate constant. Enumerate constants are represented as strings.A
TypeCode of kind TCKind.tk_string has one parameteran integer giving the maximum length of the string. A 0 length indicates an unbounded string.A
TypeCode of kind TCKind.tk_sequence has two parameters: a TypeCode for the element types, and a long for the length. A 0 length indicates an unbounded sequence.A
TypeCode of kind TCKind.tk_array has N+1 parameters, where N is the number of dimensions of the array. The first parameter is a TypeCode for the element types; the remainder are of type long.Note that a
TypeCode for an IDL exception is of kind TCKind.tk_struct and has the same parameters as a TypeCode for a struct.An IDL operation with a parameter of type
TypeCode translates into a Java method with a parameter of type TypeCode.A
TypeCode object reference constant declaration can be generated by the IDL compiler from named type definitions that appear in an IDL filethat is, from the following types:
A number ofinterfacetypedefstructunionenum
TypeCode object reference constants are always available to allow the user to access TypeCodes for standard types. These are defined in the CORBA class.
// IDL
// In module CORBA
enum TCKind {
tk_null, tk_void,
tk_short, tk_long, tk_ushort, tk_ulong,
tk_float, tk_double, tk_boolean, tk_char,
tk_octet, tk_any, tk_TypeCode, tk_Principal,
tk_objref, tk_struct, tk_union, tk_enum,
tk_string, tk_sequence, tk_array
};
exception Bounds {};
pseudo interface TypeCode {
TCKind kind();
long param_count();
any parameter(in long index) raises(Bounds);
boolean equal(in TypeCode tc);
};
// Java
package IE.Iona.Orbix2.CORBA;
public class TypeCode {
// Constructors
public TypeCode();
public TypeCode(TypeCode tc);
public TypeCode(String tc_info);
// Methods
public void copy(TypeCode tc);
public java.lang.Object clone ();
public boolean compare(TypeCode tc);
public int kind();
public int param_count();
public Any parameter(int index) throws Bounds;
public boolean equals(java.lang.Object _obj);
public String toString();
// Object Methods
public static TypeCode IT_create();
public static TypeCode IT_create(TypeCode tc);
public static TypeCode IT_create(String tc_info);
public static TypeCode _nil();
// Member Variable
public String _tc_string;
}
CORBA.TCKind
public TypeCode();
TypeCode is created with the default kind, tk_null.
CORBA.TypeCode.IT_create()Other
TypeCode constructors.
public TypeCode(TypeCode tc);
CORBA.TypeCode.IT_create()Other
TypeCode constructor.
public TypeCode(String tc_info);
TypeCode for the specified TypeCode string.
CORBA.TypeCode.IT_create()Other
TypeCode constructors.
public static TypeCode _nil();
TypeCode.
CORBA.is_nil()
public String _tc_string;
TypeCode string. OrbixWeb programmers need not be aware of the format of TypeCode strings.
CORBA.toString()
public java.lang.Object clone();
TypeCode to a new TypeCode object and returns the new object.
public boolean compare(TypeCode tc);
TypeCode specified in parameter tc holds the same value as the current TypeCode object.
public void copy(TypeCode tc);
TypeCode specified in parameter tc to the current object.
public boolean equals(java.lang.Object _obj);
TypeCode object with _obj. Two TypeCodes are equal when the IDL definitions from which they are compiled denote equal types.
true if the TypeCodes are equal; returns false if they are unequal, or if _obj is not a TypeCode object.
public static TypeCode IT_create();
TypeCode pseudo object, OrbixWeb provides the IT_create() method to initialise an object reference for a TypeCode.The
TypeCode is created with the default kind, tk_null.
public static TypeCode IT_create(TypeCode tc);
TypeCode pseudo object, OrbixWeb provides the IT_create() method to initialise an object reference for a TypeCode.The
TypeCode created is a copy of the TypeCode specified in parameter tc.
public static TypeCode IT_create(String tc_info);
TypeCode pseudo object, OrbixWeb provides the IT_create() method to initialise an object reference for a TypeCode.The
TypeCode is constructed from the TypeCode string tc_info.
public int kind();
TypeCode.
CORBA.TCKind.
CORBA.TCKind()
public int param_count();
TypeCode. For example, the IDL type sequence<long, 20> has two parameters: long and 20.
public Any parameter(int index) throws Bounds;
index. For example, the IDL type sequence<long, 20> has two parameters: long and 20. Parameters are indexed from 0 to (param_count()-1).
Bounds exception is raised if an attempt is made to access a non-existent parameter.
public String toString();
TypeCode string. OrbixWeb programmers need not be aware of the format of TypeCode strings.
CORBA._tc_string()