Class Any
- All Implemented Interfaces:
Serializable
,IDLEntity
- Direct Known Subclasses:
AnyImpl
Any
object is used as a component of a
NamedValue
object, which provides information about
arguments or return values in requests, and which is used to define
name/value pairs in Context
objects.
An Any
object consists of two parts:
- a data value
- a
TypeCode
object describing the type of the data value contained in theAny
object. For example, aTypeCode
object for an array contains a field for the length of the array and a field for the type of elements in the array. (Note that in this case, the second field of theTypeCode
object is itself aTypeCode
object.)
A large part of the Any
class consists of pairs of methods
for inserting values into and extracting values from an
Any
object.
For a given primitive type X, these methods are:
void insert_X(X x)
- This method allows the insertion of
an instance
x
of primitive typeX
into thevalue
field of theAny
object. Note that the methodinsert_X
also resets theAny
object'stype
field if necessary. -
X extract_X()
- This method allows the extraction of an instance of
type
X
from theAny
object.
This method throws the exception
BAD_OPERATION
under two conditions:- the type of the element contained in the
Any
object is notX
- the method
extract_X
is called before thevalue
field of theAny
object has been set
- the type of the element contained in the
There are distinct method pairs for each
primitive IDL data type (insert_long
and extract_long
,
insert_string
and extract_string
, and so on).
The class Any
also has methods for
getting and setting the type code,
for testing two Any
objects for equality,
and for reading an Any
object from a stream or
writing it to a stream.
- Since:
- JDK1.2
- Version:
- 1.12, 09/09/97
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract InputStream
Creates an input stream from which thisAny
object's value can be unmarshalled.abstract OutputStream
Creates an output stream into which thisAny
object's value can be marshalled.abstract boolean
Checks for equality between thisAny
object and the givenAny
object.abstract Any
Extracts theAny
object in thisAny
object'svalue
field.abstract boolean
Extracts theboolean
in thisAny
object'svalue
field.abstract char
Extracts thechar
in thisAny
object'svalue
field.abstract double
Extracts thedouble
in thisAny
object'svalue
field.Extracts thejava.math.BigDecimal
object in thisAny
object'svalue
field.abstract float
Extracts thefloat
in thisAny
object'svalue
field.abstract int
Extracts theint
in thisAny
object'svalue
field.abstract long
Extracts thelong
in thisAny
object'svalue
field.abstract Object
Extracts theorg.omg.CORBA.Object
in thisAny
object'svalue
field.abstract byte
Extracts thebyte
in thisAny
object'svalue
field.Deprecated.Deprecated by CORBA 2.2.abstract short
Extracts theshort
in thisAny
object'svalue
field.Extracts aStreamable
from thisAny
object'svalue
field.abstract String
Extracts theString
object in thisAny
object'svalue
field.abstract TypeCode
Extracts theTypeCode
object in thisAny
object'svalue
field.abstract int
Extracts theint
in thisAny
object'svalue
field.abstract long
Extracts thelong
in thisAny
object'svalue
field.abstract short
Extracts theshort
in thisAny
object'svalue
field.abstract Serializable
Extracts thejava.io.Serializable
object in thisAny
object'svalue
field.abstract char
Extracts thechar
in thisAny
object'svalue
field.abstract String
Extracts theString
object in thisAny
object'svalue
field.abstract void
insert_any
(Any a) Inserts the givenAny
object into thisAny
object'svalue
field.abstract void
insert_boolean
(boolean b) Inserts the givenboolean
into thisAny
object'svalue
field.abstract void
insert_char
(char c) Inserts the givenchar
into thisAny
object'svalue
field.abstract void
insert_double
(double d) Inserts the givendouble
into thisAny
object'svalue
field.void
insert_fixed
(BigDecimal value) Throws anorg.omg.CORBA.NO_IMPLEMENT
exception.void
insert_fixed
(BigDecimal value, TypeCode type) Throws anorg.omg.CORBA.NO_IMPLEMENT
exception.abstract void
insert_float
(float f) Inserts the givenfloat
into thisAny
object'svalue
field.abstract void
insert_long
(int l) Inserts the givenint
into thisAny
object'svalue
field.abstract void
insert_longlong
(long l) Inserts the givenlong
into thisAny
object'svalue
field.abstract void
Inserts the givenorg.omg.CORBA.Object
object into thisAny
object'svalue
field.abstract void
insert_Object
(Object o, TypeCode t) Inserts the givenorg.omg.CORBA.Object
object into thisAny
object'svalue
field.abstract void
insert_octet
(byte b) Inserts the givenbyte
into thisAny
object'svalue
field.void
Deprecated.Deprecated by CORBA 2.2.abstract void
insert_short
(short s) Inserts the givenshort
into thisAny
object'svalue
field.void
Inserts the givenStreamable
object into thisAny
object'svalue
field.abstract void
Inserts the givenString
object into thisAny
object'svalue
field.abstract void
Inserts the givenTypeCode
object into thisAny
object'svalue
field.abstract void
insert_ulong
(int l) Inserts the givenint
into thisAny
object'svalue
field.abstract void
insert_ulonglong
(long l) Inserts the givenlong
into thisAny
object'svalue
field.abstract void
insert_ushort
(short s) Inserts the givenshort
into thisAny
object'svalue
field.abstract void
Inserts the givenjava.io.Serializable
object into thisAny
object'svalue
field.abstract void
insert_Value
(Serializable v, TypeCode t) Inserts the givenjava.io.Serializable
object into thisAny
object'svalue
field.abstract void
insert_wchar
(char c) Inserts the givenchar
into thisAny
object'svalue
field.abstract void
Inserts the givenString
object into thisAny
object'svalue
field.abstract void
read_value
(InputStream is, TypeCode t) Reads off (unmarshals) the value of anAny
object from the given input stream using the given typecode.abstract TypeCode
type()
Returns type information for the element contained in thisAny
object.abstract void
Sets thisAny
object'stype
field to the givenTypeCode
object and clears its value.abstract void
Writes out the value of thisAny
object to the given output stream.
-
Constructor Details
-
Any
public Any()
-
-
Method Details
-
equal
Checks for equality between thisAny
object and the givenAny
object. TwoAny
objects are equal if both their values and type codes are equal.- Parameters:
a
- theAny
object to test for equality- Returns:
true
if theAny
objects are equal;false
otherwise- See Also:
-
type
Returns type information for the element contained in thisAny
object.- Returns:
- the
TypeCode
object containing type information about the value contained in thisAny
object
-
type
Sets thisAny
object'stype
field to the givenTypeCode
object and clears its value.Note that using this method to set the type code wipes out the value if there is one. The method is provided primarily so that the type may be set properly for IDL
out
parameters. Generally, setting the type is done by theinsert_X
methods, which will set the type to X if it is not already set to X.- Parameters:
t
- theTypeCode
object giving information for the value in thisAny
object
-
read_value
Reads off (unmarshals) the value of anAny
object from the given input stream using the given typecode.- Parameters:
is
- theorg.omg.CORBA.portable.InputStream
object from which to read the value contained in thisAny
objectt
- aTypeCode
object containing type information about the value to be read- Throws:
MARSHAL
- when the givenTypeCode
object is not consistent with the value that was contained in the input stream
-
write_value
Writes out the value of thisAny
object to the given output stream. If bothtypecode
andvalue
need to be written, usecreate_output_stream()
to create anOutputStream
, then usewrite_any
on theOutputStream
.If this method is called on an
Any
object that has not had a value inserted into itsvalue
field, it will throw the exceptionjava.lang.NullPointerException
.- Parameters:
os
- theorg.omg.CORBA.portable.OutputStream
object into which to marshal the value of thisAny
object
-
create_output_stream
Creates an output stream into which thisAny
object's value can be marshalled.- Returns:
- the newly-created
OutputStream
-
create_input_stream
Creates an input stream from which thisAny
object's value can be unmarshalled.- Returns:
- the newly-created
InputStream
-
extract_short
Extracts theshort
in thisAny
object'svalue
field.- Returns:
- the
short
stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than ashort
or thevalue
field has not yet been set
-
insert_short
public abstract void insert_short(short s) Inserts the givenshort
into thisAny
object'svalue
field.- Parameters:
s
- theshort
to insert into thisAny
object
-
extract_long
Extracts theint
in thisAny
object'svalue
field.- Returns:
- the
int
stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than anint
or thevalue
field has not yet been set
-
insert_long
public abstract void insert_long(int l) Inserts the givenint
into thisAny
object'svalue
field.- Parameters:
l
- theint
to insert into thisAny
object
-
extract_longlong
Extracts thelong
in thisAny
object'svalue
field.- Returns:
- the
long
stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than along
or thevalue
field has not yet been set
-
insert_longlong
public abstract void insert_longlong(long l) Inserts the givenlong
into thisAny
object'svalue
field.- Parameters:
l
- thelong
to insert into thisAny
object
-
extract_ushort
Extracts theshort
in thisAny
object'svalue
field.- Returns:
- the
short
stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than ashort
or thevalue
field has not yet been set
-
insert_ushort
public abstract void insert_ushort(short s) Inserts the givenshort
into thisAny
object'svalue
field.- Parameters:
s
- theshort
to insert into thisAny
object
-
extract_ulong
Extracts theint
in thisAny
object'svalue
field.- Returns:
- the
int
stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than anint
or thevalue
field has not yet been set
-
insert_ulong
public abstract void insert_ulong(int l) Inserts the givenint
into thisAny
object'svalue
field.- Parameters:
l
- theint
to insert into thisAny
object
-
extract_ulonglong
Extracts thelong
in thisAny
object'svalue
field.- Returns:
- the
long
stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than along
or thevalue
field has not yet been set
-
insert_ulonglong
public abstract void insert_ulonglong(long l) Inserts the givenlong
into thisAny
object'svalue
field.- Parameters:
l
- thelong
to insert into thisAny
object
-
extract_float
Extracts thefloat
in thisAny
object'svalue
field.- Returns:
- the
float
stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than afloat
or thevalue
field has not yet been set
-
insert_float
public abstract void insert_float(float f) Inserts the givenfloat
into thisAny
object'svalue
field.- Parameters:
f
- thefloat
to insert into thisAny
object
-
extract_double
Extracts thedouble
in thisAny
object'svalue
field.- Returns:
- the
double
stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than adouble
or thevalue
field has not yet been set
-
insert_double
public abstract void insert_double(double d) Inserts the givendouble
into thisAny
object'svalue
field.- Parameters:
d
- thedouble
to insert into thisAny
object
-
extract_boolean
Extracts theboolean
in thisAny
object'svalue
field.- Returns:
- the
boolean
stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than aboolean
or thevalue
field has not yet been set
-
insert_boolean
public abstract void insert_boolean(boolean b) Inserts the givenboolean
into thisAny
object'svalue
field.- Parameters:
b
- theboolean
to insert into thisAny
object
-
extract_char
Extracts thechar
in thisAny
object'svalue
field.- Returns:
- the
char
stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than achar
or thevalue
field has not yet been set
-
insert_char
Inserts the givenchar
into thisAny
object'svalue
field.- Parameters:
c
- thechar
to insert into thisAny
object- Throws:
DATA_CONVERSION
- if there is a data conversion error
-
extract_wchar
Extracts thechar
in thisAny
object'svalue
field.- Returns:
- the
char
stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than achar
or thevalue
field has not yet been set
-
insert_wchar
public abstract void insert_wchar(char c) Inserts the givenchar
into thisAny
object'svalue
field.- Parameters:
c
- thechar
to insert into thisAny
object
-
extract_octet
Extracts thebyte
in thisAny
object'svalue
field.- Returns:
- the
byte
stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than abyte
or thevalue
field has not yet been set
-
insert_octet
public abstract void insert_octet(byte b) Inserts the givenbyte
into thisAny
object'svalue
field.- Parameters:
b
- thebyte
to insert into thisAny
object
-
extract_any
Extracts theAny
object in thisAny
object'svalue
field.- Returns:
- the
Any
object stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than anAny
object or thevalue
field has not yet been set
-
insert_any
Inserts the givenAny
object into thisAny
object'svalue
field.- Parameters:
a
- theAny
object to insert into thisAny
object
-
extract_Object
Extracts theorg.omg.CORBA.Object
in thisAny
object'svalue
field.- Returns:
- the
org.omg.CORBA.Object
stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than anorg.omg.CORBA.Object
or thevalue
field has not yet been set
-
insert_Object
Inserts the givenorg.omg.CORBA.Object
object into thisAny
object'svalue
field.- Parameters:
o
- theorg.omg.CORBA.Object
object to insert into thisAny
object
-
extract_Value
Extracts thejava.io.Serializable
object in thisAny
object'svalue
field.- Returns:
- the
java.io.Serializable
object stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than ajava.io.Serializable
object or thevalue
field has not yet been set
-
insert_Value
Inserts the givenjava.io.Serializable
object into thisAny
object'svalue
field.- Parameters:
v
- thejava.io.Serializable
object to insert into thisAny
object
-
insert_Value
Inserts the givenjava.io.Serializable
object into thisAny
object'svalue
field.- Parameters:
v
- thejava.io.Serializable
object to insert into thisAny
objectt
- theTypeCode
object that is to be inserted into thisAny
object'stype
field and that describes thejava.io.Serializable
object being inserted- Throws:
MARSHAL
- if the ORB has a problem marshalling or unmarshalling parameters
-
insert_Object
Inserts the givenorg.omg.CORBA.Object
object into thisAny
object'svalue
field.- Parameters:
o
- theorg.omg.CORBA.Object
instance to insert into thisAny
objectt
- theTypeCode
object that is to be inserted into thisAny
object and that describes theObject
being inserted- Throws:
BAD_OPERATION
- if this method is invalid for thisAny
objectBAD_PARAM
-
extract_string
Extracts theString
object in thisAny
object'svalue
field.- Returns:
- the
String
object stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than aString
object or thevalue
field has not yet been set
-
insert_string
Inserts the givenString
object into thisAny
object'svalue
field.- Parameters:
s
- theString
object to insert into thisAny
object- Throws:
DATA_CONVERSION
- if there is a data conversion errorMARSHAL
- if the ORB has a problem marshalling or unmarshalling parameters
-
extract_wstring
Extracts theString
object in thisAny
object'svalue
field.- Returns:
- the
String
object stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than aString
object or thevalue
field has not yet been set
-
insert_wstring
Inserts the givenString
object into thisAny
object'svalue
field.- Parameters:
s
- theString
object to insert into thisAny
object- Throws:
MARSHAL
- if the ORB has a problem marshalling or unmarshalling parameters
-
extract_TypeCode
Extracts theTypeCode
object in thisAny
object'svalue
field.- Returns:
- the
TypeCode
object stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than aTypeCode
object or thevalue
field has not yet been set
-
insert_TypeCode
Inserts the givenTypeCode
object into thisAny
object'svalue
field.- Parameters:
t
- theTypeCode
object to insert into thisAny
object
-
extract_Principal
Deprecated.Deprecated by CORBA 2.2.Extracts thePrincipal
object in thisAny
object'svalue
field. Note that the classPrincipal
has been deprecated.- Returns:
- the
Principal
object stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than aPrincipal
object or thevalue
field has not yet been set- See Also:
-
insert_Principal
Deprecated.Deprecated by CORBA 2.2.Inserts the givenPrincipal
object into thisAny
object'svalue
field. Note that the classPrincipal
has been deprecated.- Parameters:
p
- thePrincipal
object to insert into thisAny
object- See Also:
-
extract_Streamable
Extracts aStreamable
from thisAny
object'svalue
field. This method allows the extraction of non-primitive IDL types.- Returns:
- the
Streamable
stored in theAny
object. - Throws:
BAD_INV_ORDER
- if the caller has invoked operations in the wrong order- See Also:
-
insert_Streamable
Inserts the givenStreamable
object into thisAny
object'svalue
field. This method allows the insertion of non-primitive IDL types.- Parameters:
s
- theStreamable
object to insert into thisAny
object; may be a non-primitive IDL type- See Also:
-
extract_fixed
Extracts thejava.math.BigDecimal
object in thisAny
object'svalue
field.- Returns:
- the
java.math.BigDecimal
object stored in thisAny
object - Throws:
BAD_OPERATION
- if thisAny
object contains something other than ajava.math.BigDecimal
object or thevalue
field has not yet been set- See Also:
-
insert_fixed
Throws anorg.omg.CORBA.NO_IMPLEMENT
exception.Inserts the given
java.math.BigDecimal
object into thisAny
object'svalue
field.- Parameters:
value
- thejava.math.BigDecimal
object to insert into thisAny
object- See Also:
-
insert_fixed
Throws anorg.omg.CORBA.NO_IMPLEMENT
exception.Inserts the given
java.math.BigDecimal
object into thisAny
object'svalue
field.- Parameters:
value
- thejava.math.BigDecimal
object to insert into thisAny
objecttype
- theTypeCode
object that is to be inserted into thisAny
object'stype
field and that describes thejava.math.BigDecimal
object being inserted- Throws:
BAD_INV_ORDER
- if this method is invoked improperly- See Also:
-