|
JavaTM 2 Platform Standard Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
An object that enables the dynamic management of Any
values. A DynAny object allows a program to use
an Any object
when the program has no static information about the type of the
Any object. The DynAny interface
provides methods for traversing the data value associated with an
Any object at run time and for extracting the primitive
constituents of the data value.
A DynAny object is associated with a data value
that may correspond to a copy of the value inserted into an
Any object. The DynAny object may be seen as
owning a pointer to an external buffer that holds some representation
of the data value.
For data values that are constructed types (IDL
struct, sequence, array, union, and so on), the DynAny
object also can be thought of as holding a pointer to a buffer offset
where the current component of the constructed type is being represented.
The buffer pointer effectively points
to the space used to represent the first component of the data value
when the programmer creates the DynAny object. Calling
the DynAny method next will move the pointer
to the next component, making it possible to iterate through the
components of a constructed data value. The buffer pointer is moved
back to the first component each time the method rewind
is called.
DynAny methods make it possible to do the following:
DynAny object
DynAny object from another
DynAny object
DynAny object from an
Any value
Any value from a DynAny
object
DynAny object
DynAny object
DynAny object
DynAny object
Inserting a basic data type value into a constructed DynAny
object implies initializing the next component of the constructed data
value associated with the DynAny object. For example,
invoking the method insert_boolean in a DynStruct
implies inserting a boolean data value as the next member
of the associated struct data value.
Creating a DynAny object can be done by:
DynAny object
org.omg.CORBA.ORB method (create_dyn_any,
create_dyn_struct, create_dyn_sequence, and so on)
Dynamic creation of an Any object containing a value
of a basic data type typically involves the following:
DynAny object using
ORB.create_basic_dyn_any,
passing it the type code associated with the basic data type value to
be created
DynAny object (insert_boolean if the
DynAny is of type boolean, for example)
Any object by invoking the method
to_any on the initialized DynAny object
Dynamic creation of an Any object containing a value
of a constructed data type typically involves the following:
DynAny object using the appropriate ORB
method (for example, ORB.create_dyn_struct for an IDL struct),
passing it the type code associated with the constructed data type value to
be created
DynStruct
(or other constructed type) object
current_component to get a
DynAny object for that component
insert method
on the DynAny object returned by
the method current_component to initialize
the component
next to move to the next component
and continue to get the current component, initialize it, and move
to the next component until there are no more components (the method
next returns false)
DynAny objects generated for each member of the
constructed type
Any object by invoking the method
to_any on the initialized DynAny object
DynAny objects are intended to be local to the
process in which they are created and used. Any method that
attempts to export references to DynAny objects
to other processes or to externalize them with the method
org.omg.CORBA.ORB.object_to_string will throw a
MARSHAL exception. Also, even though DynAny
objects are derived from the interface Object, invoking
methods from Object will throw the NO_IMPLEMENT
exception. An attempt to use a DynAny object with the
DII (Dynamic Invocation Interface) may throw a NO_IMPLEMENT
exception.
The following classes are derived from DynAny
and define additional methods relevant to their particular
IDL type: DynFixed, DynStruct, DynSequence,
DynArray, DynUnion, DynEnum,
DynAny, and DynValue.
| Method Summary | |
void |
assign(DynAny dyn_any)
Initializes the value associated with this DynAny
object with the value associated with the given DynAny
object. |
DynAny |
copy()
Clone this DnyAny. |
DynAny |
current_component()
Returns a DynAny object reference that can
be used to get/set the value of the component currently accessed. |
void |
destroy()
Destroys this DynAny object and frees any resources
used to represent the data value associated with it. |
void |
from_any(Any value)
Initializes the value associated with this DynAny
object with the value associated with the given Any
object. |
Any |
get_any()
Retrieves the org.omg.CORBA.Any contained
in this DynAny object. |
boolean |
get_boolean()
Retrieves the boolean contained
in this DynAny object. |
char |
get_char()
Retrieves the char contained
in this DynAny object. |
double |
get_double()
Retrieves the double contained
in this DynAny object. |
float |
get_float()
Retrieves the float contained
in this DynAny object. |
int |
get_long()
Retrieves the int contained
in this DynAny object. |
long |
get_longlong()
Retrieves the long contained
in this DynAny object. |
byte |
get_octet()
Retrieves the byte contained
in this DynAny object. |
Object |
get_reference()
Retrieves the org.omg.CORBA.Other contained
in this DynAny object. |
short |
get_short()
Retrieves the short contained
in this DynAny object. |
String |
get_string()
Retrieves the String contained
in this DynAny object. |
TypeCode |
get_typecode()
Retrieves the org.omg.CORBA.TypeCode contained
in this DynAny object. |
int |
get_ulong()
Retrieves the int contained
in this DynAny object. |
long |
get_ulonglong()
Retrieves the long contained
in this DynAny object. |
short |
get_ushort()
Retrieves the short contained
in this DynAny object. |
Serializable |
get_val()
Retrieves the java.io.Serializable object contained
in this DynAny object. |
char |
get_wchar()
Retrieves the char contained
in this DynAny object. |
String |
get_wstring()
Retrieves the String contained
in this DynAny object. |
void |
insert_any(Any value)
Inserts the given org.omg.CORBA.Any object as the value for this
DynAny object. |
void |
insert_boolean(boolean value)
Inserts the given boolean as the value for this
DynAny object. |
void |
insert_char(char value)
Inserts the given char as the value for this
DynAny object. |
void |
insert_double(double value)
Inserts the given double as the value for this
DynAny object. |
void |
insert_float(float value)
Inserts the given float as the value for this
DynAny object. |
void |
insert_long(int value)
Inserts the given int as the value for this
DynAny object. |
void |
insert_longlong(long value)
Inserts the given long as the value for this
DynAny object. |
void |
insert_octet(byte value)
Inserts the given byte as the value for this
DynAny object. |
void |
insert_reference(Object value)
Inserts the given org.omg.CORBA.Object as the value for this
DynAny object. |
void |
insert_short(short value)
Inserts the given short as the value for this
DynAny object. |
void |
insert_string(String value)
Inserts the given String object as the value for this
DynAny object. |
void |
insert_typecode(TypeCode value)
Inserts the given org.omg.CORBA.TypeCode as the value for this
DynAny object. |
void |
insert_ulong(int value)
Inserts the given int as the value for this
DynAny object. |
void |
insert_ulonglong(long value)
Inserts the given long as the value for this
DynAny object. |
void |
insert_ushort(short value)
Inserts the given short as the value for this
DynAny object. |
void |
insert_val(Serializable value)
Inserts the given java.io.Serializable object as the value for this
DynAny object. |
void |
insert_wchar(char value)
Inserts the given char as the value for this
DynAny object. |
void |
insert_wstring(String value)
Inserts the given String as the value for this
DynAny object. |
boolean |
next()
Moves to the next component of this DynAny object. |
void |
rewind()
Moves the internal pointer to the first component. |
boolean |
seek(int index)
Moves the internal pointer to the given index. |
Any |
to_any()
Creates an Any object from this DynAny
object. |
TypeCode |
type()
Retrieves the TypeCode object contained in
this DynAny object. |
| Methods inherited from interface org.omg.CORBA.Object |
_create_request,
_create_request,
_duplicate,
_get_domain_managers,
_get_interface_def,
_get_policy,
_hash,
_is_a,
_is_equivalent,
_non_existent,
_release,
_request,
_set_policy_override |
| Method Detail |
public TypeCode type()
TypeCode object contained in
this DynAny object. Note that the type code
associated with a DynAny object is initialized
at the time DynAny is created and cannot be changed
during the lifetime of the DynAny object.TypeCode object describing the
value contained in this DynAny object
public void assign(DynAny dyn_any)
throws Invalid
DynAny
object with the value associated with the given DynAny
object.dyn_any - the DynAny object whose value will be
used to initialize this DynAny objectorg.omg.CORBA.DynAnyPackage.Invalid - if the given DynAny object has a type code
that is not equivalent or has not been assigned a value
public void from_any(Any value)
throws Invalid
DynAny
object with the value associated with the given Any
object.value - the Any object whose value will be
used to initialize this DynAny objectorg.omg.CORBA.DynAnyPackage.Invalid - if the given Any object has a type code
that is not equivalent or has not been assigned a value
public Any to_any()
throws Invalid
Any object from this DynAny
object. The type code and value of this DynAny
object are copied into the newly-created Any object.Any objectorg.omg.CORBA.DynAnyPackage.Invalid - if
this DynAny object has not been correctly
created or does not contain a meaningful valuepublic void destroy()
DynAny object and frees any resources
used to represent the data value associated with it. This method
also destroys all DynAny objects obtained from it.
Destruction of DynAny objects should be handled with
care, taking into account issues dealing with the representation of
data values associated with DynAny objects. A programmer
who wants to destroy a DynAny object but still be able
to manipulate some component of the data value associated with it,
should first create a DynAny object for the component
and then make a copy of the created DynAny object.
public DynAny copy()
DynAny.
public void insert_boolean(boolean value)
throws InvalidValue
boolean as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the boolean to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_octet(byte value)
throws InvalidValue
byte as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the byte to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_char(char value)
throws InvalidValue
char as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the char to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_short(short value)
throws InvalidValue
short as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the short to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_ushort(short value)
throws InvalidValue
short as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the short to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_long(int value)
throws InvalidValue
int as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the int to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_ulong(int value)
throws InvalidValue
int as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the int to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_float(float value)
throws InvalidValue
float as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the float to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_double(double value)
throws InvalidValue
double as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the double to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_string(String value)
throws InvalidValue
String object as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the String to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_reference(Object value)
throws InvalidValue
org.omg.CORBA.Object as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the org.omg.CORBA.Object to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_typecode(TypeCode value)
throws InvalidValue
org.omg.CORBA.TypeCode as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the org.omg.CORBA.TypeCode to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_longlong(long value)
throws InvalidValue
long as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the long to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_ulonglong(long value)
throws InvalidValue
long as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the long to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_wchar(char value)
throws InvalidValue
char as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the char to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_wstring(String value)
throws InvalidValue
String as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the String to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_any(Any value)
throws InvalidValue
org.omg.CORBA.Any object as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the org.omg.CORBA.Any object to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public void insert_val(Serializable value)
throws InvalidValue
java.io.Serializable object as the value for this
DynAny object.
If this method is called on a constructed DynAny
object, it initializes the next component of the constructed data
value associated with this DynAny object.
value - the java.io.Serializable object to insert into this
DynAny objectorg.omg.CORBA.DynAnyPackage.InvalidValue - if the value inserted is not consistent with the type
of the accessed component in this DynAny object
public Serializable get_val()
throws TypeMismatch
java.io.Serializable object contained
in this DynAny object.java.io.Serializable object that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a java.io.Serializable object
public boolean get_boolean()
throws TypeMismatch
boolean contained
in this DynAny object.boolean that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a boolean
public byte get_octet()
throws TypeMismatch
byte contained
in this DynAny object.byte that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a byte
public char get_char()
throws TypeMismatch
char contained
in this DynAny object.char that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a char
public short get_short()
throws TypeMismatch
short contained
in this DynAny object.short that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a short
public short get_ushort()
throws TypeMismatch
short contained
in this DynAny object.short that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a short
public int get_long()
throws TypeMismatch
int contained
in this DynAny object.int that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a int
public int get_ulong()
throws TypeMismatch
int contained
in this DynAny object.int that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a int
public float get_float()
throws TypeMismatch
float contained
in this DynAny object.float that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a float
public double get_double()
throws TypeMismatch
double contained
in this DynAny object.double that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a double
public String get_string()
throws TypeMismatch
String contained
in this DynAny object.String that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a String
public Object get_reference()
throws TypeMismatch
org.omg.CORBA.Other contained
in this DynAny object.org.omg.CORBA.Other that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for an org.omg.CORBA.Other
public TypeCode get_typecode()
throws TypeMismatch
org.omg.CORBA.TypeCode contained
in this DynAny object.org.omg.CORBA.TypeCode that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a org.omg.CORBA.TypeCode
public long get_longlong()
throws TypeMismatch
long contained
in this DynAny object.long that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a long
public long get_ulonglong()
throws TypeMismatch
long contained
in this DynAny object.long that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a long
public char get_wchar()
throws TypeMismatch
char contained
in this DynAny object.char that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a char
public String get_wstring()
throws TypeMismatch
String contained
in this DynAny object.String that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a String
public Any get_any()
throws TypeMismatch
org.omg.CORBA.Any contained
in this DynAny object.org.omg.CORBA.Any that is the
value for this DynAny objectorg.omg.CORBA.DynAnyPackage.TypeMismatch - if the type code of the accessed component in this
DynAny object is not equivalent to
the type code for a org.omg.CORBA.Anypublic DynAny current_component()
DynAny object reference that can
be used to get/set the value of the component currently accessed.
The appropriate or insert method
can be called on the resulting DynAny object
to initialize the component.
The appropriate get method
can be called on the resulting DynAny object
to extract the value of the component.public boolean next()
DynAny object.
This method is used for iterating through the components of
a constructed type, effectively moving a pointer from one
component to the next. The pointer starts out on the first
component when a DynAny object is created.true if the pointer points to a component;
false if there are no more components or this
DynAny is associated with a basic type rather than
a constructed typepublic boolean seek(int index)
index - an int indicating the position to which
the pointer should move. The first position is 0.true if the pointer points to a component;
false if there is no component at the designated
index. If this DynAny object is associated with a
basic type, this method returns false for any index
other than 0.public void rewind()
|
JavaTM 2 Platform Standard Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||