Create a recursive
TypeCode
object which
serves as a placeholder for a concrete TypeCode during the process of creating
TypeCodes which contain recursion. The id parameter specifies the repository id of
the type for which the recursive TypeCode is serving as a placeholder. Once the
recursive TypeCode has been properly embedded in the enclosing TypeCode which
corresponds to the specified repository id, it will function as a normal TypeCode.
Invoking operations on the recursive TypeCode before it has been embedded in the
enclosing TypeCode will result in a
BAD_TYPECODE
exception.
For example, the following IDL type declaration contains recursion:
Struct Node {
Sequence<Node> subnodes;
};
To create a TypeCode for struct Node, you would invoke the TypeCode creation
operations as shown below:
String nodeID = "IDL:Node:1.0";
TypeCode recursiveSeqTC = orb.create_sequence_tc(0, orb.create_recursive_tc(nodeID));
StructMember[] members = { new StructMember("subnodes", recursiveSeqTC, null) };
TypeCode structNodeTC = orb.create_struct_tc(nodeID, "Node", members);
Also note that the following is an illegal IDL type declaration:
Struct Node {
Node next;
};
Recursive types can only appear within sequences which can be empty.
That way marshaling problems, when transmitting the struct in an Any, are avoided.
Returns:
the requested TypeCode
Parameters:
- id - the logical id of the referenced type