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
TypeCodeobject describing the type of the data value contained in theAnyobject. For example, aTypeCodeobject 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 theTypeCodeobject is itself aTypeCodeobject.)
<a name="anyOps"
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
xof primitive typeXinto thevaluefield of theAnyobject. Note that the methodinsert_Xalso resets theAnyobject'stypefield if necessary. -
X extract_X() - This method allows the extraction of an instance of
type
Xfrom theAnyobject.
This method throws the exception
BAD_OPERATIONunder two conditions:- the type of the element contained in the
Anyobject is notX - the method
extract_Xis called before thevaluefield of theAnyobject 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
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract InputStreamCreates an input stream from which thisAnyobject's value can be unmarshalled.abstract OutputStreamCreates an output stream into which thisAnyobject's value can be marshalled.abstract booleanChecks for equality between thisAnyobject and the givenAnyobject.abstract AnyExtracts theAnyobject in thisAnyobject'svaluefield.abstract booleanExtracts thebooleanin thisAnyobject'svaluefield.abstract charExtracts thecharin thisAnyobject'svaluefield.abstract doubleExtracts thedoublein thisAnyobject'svaluefield.Extracts thejava.math.BigDecimalobject in thisAnyobject'svaluefield.abstract floatExtracts thefloatin thisAnyobject'svaluefield.abstract intExtracts theintin thisAnyobject'svaluefield.abstract longExtracts thelongin thisAnyobject'svaluefield.abstract ObjectExtracts theorg.omg.CORBA.Objectin thisAnyobject'svaluefield.abstract byteExtracts thebytein thisAnyobject'svaluefield.Deprecated.Deprecated by CORBA 2.2.abstract shortExtracts theshortin thisAnyobject'svaluefield.Extracts aStreamablefrom thisAnyobject'svaluefield.abstract StringExtracts theStringobject in thisAnyobject'svaluefield.abstract TypeCodeExtracts theTypeCodeobject in thisAnyobject'svaluefield.abstract intExtracts theintin thisAnyobject'svaluefield.abstract longExtracts thelongin thisAnyobject'svaluefield.abstract shortExtracts theshortin thisAnyobject'svaluefield.abstract SerializableExtracts thejava.io.Serializableobject in thisAnyobject'svaluefield.abstract charExtracts thecharin thisAnyobject'svaluefield.abstract StringExtracts theStringobject in thisAnyobject'svaluefield.abstract voidinsert_any(Any a) Inserts the givenAnyobject into thisAnyobject'svaluefield.abstract voidinsert_boolean(boolean b) Inserts the givenbooleaninto thisAnyobject'svaluefield.abstract voidinsert_char(char c) Inserts the givencharinto thisAnyobject'svaluefield.abstract voidinsert_double(double d) Inserts the givendoubleinto thisAnyobject'svaluefield.voidinsert_fixed(BigDecimal value) Throws anorg.omg.CORBA.NO_IMPLEMENTexception.voidinsert_fixed(BigDecimal value, TypeCode type) Throws anorg.omg.CORBA.NO_IMPLEMENTexception.abstract voidinsert_float(float f) Inserts the givenfloatinto thisAnyobject'svaluefield.abstract voidinsert_long(int l) Inserts the givenintinto thisAnyobject'svaluefield.abstract voidinsert_longlong(long l) Inserts the givenlonginto thisAnyobject'svaluefield.abstract voidInserts the givenorg.omg.CORBA.Objectobject into thisAnyobject'svaluefield.abstract voidinsert_Object(Object o, TypeCode t) Inserts the givenorg.omg.CORBA.Objectobject into thisAnyobject'svaluefield.abstract voidinsert_octet(byte b) Inserts the givenbyteinto thisAnyobject'svaluefield.voidDeprecated.Deprecated by CORBA 2.2.abstract voidinsert_short(short s) Inserts the givenshortinto thisAnyobject'svaluefield.voidInserts the givenStreamableobject into thisAnyobject'svaluefield.abstract voidInserts the givenStringobject into thisAnyobject'svaluefield.abstract voidInserts the givenTypeCodeobject into thisAnyobject'svaluefield.abstract voidinsert_ulong(int l) Inserts the givenintinto thisAnyobject'svaluefield.abstract voidinsert_ulonglong(long l) Inserts the givenlonginto thisAnyobject'svaluefield.abstract voidinsert_ushort(short s) Inserts the givenshortinto thisAnyobject'svaluefield.abstract voidInserts the givenjava.io.Serializableobject into thisAnyobject'svaluefield.abstract voidinsert_Value(Serializable v, TypeCode t) Inserts the givenjava.io.Serializableobject into thisAnyobject'svaluefield.abstract voidinsert_wchar(char c) Inserts the givencharinto thisAnyobject'svaluefield.abstract voidInserts the givenStringobject into thisAnyobject'svaluefield.abstract voidread_value(InputStream is, TypeCode t) Reads off (unmarshals) the value of anAnyobject from the given input stream using the given typecode.abstract TypeCodetype()Returns type information for the element contained in thisAnyobject.abstract voidSets thisAnyobject'stypefield to the givenTypeCodeobject and clears its value.abstract voidWrites out the value of thisAnyobject to the given output stream.
-
Constructor Details
-
Any
public Any()
-
-
Method Details
-
equal
Checks for equality between thisAnyobject and the givenAnyobject. TwoAnyobjects are equal if both their values and type codes are equal.- Parameters:
a- theAnyobject to test for equality- Returns:
trueif theAnyobjects are equal;falseotherwise- See Also:
-
type
Returns type information for the element contained in thisAnyobject.- Returns:
- the
TypeCodeobject containing type information about the value contained in thisAnyobject
-
type
Sets thisAnyobject'stypefield to the givenTypeCodeobject 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
outparameters. Generally, setting the type is done by theinsert_Xmethods, which will set the type to X if it is not already set to X.- Parameters:
t- theTypeCodeobject giving information for the value in thisAnyobject
-
read_value
Reads off (unmarshals) the value of anAnyobject from the given input stream using the given typecode.- Parameters:
is- theorg.omg.CORBA.portable.InputStreamobject from which to read the value contained in thisAnyobjectt- aTypeCodeobject containing type information about the value to be read- Throws:
MARSHAL- when the givenTypeCodeobject is not consistent with the value that was contained in the input stream
-
write_value
Writes out the value of thisAnyobject to the given output stream. If bothtypecodeandvalueneed to be written, usecreate_output_stream()to create anOutputStream, then usewrite_anyon theOutputStream.If this method is called on an
Anyobject that has not had a value inserted into itsvaluefield, it will throw the exceptionjava.lang.NullPointerException.- Parameters:
os- theorg.omg.CORBA.portable.OutputStreamobject into which to marshal the value of thisAnyobject
-
create_output_stream
Creates an output stream into which thisAnyobject's value can be marshalled.- Returns:
- the newly-created
OutputStream
-
create_input_stream
Creates an input stream from which thisAnyobject's value can be unmarshalled.- Returns:
- the newly-created
InputStream
-
extract_short
Extracts theshortin thisAnyobject'svaluefield.- Returns:
- the
shortstored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than ashortor thevaluefield has not yet been set
-
insert_short
public abstract void insert_short(short s) Inserts the givenshortinto thisAnyobject'svaluefield.- Parameters:
s- theshortto insert into thisAnyobject
-
extract_long
Extracts theintin thisAnyobject'svaluefield.- Returns:
- the
intstored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than anintor thevaluefield has not yet been set
-
insert_long
public abstract void insert_long(int l) Inserts the givenintinto thisAnyobject'svaluefield.- Parameters:
l- theintto insert into thisAnyobject
-
extract_longlong
Extracts thelongin thisAnyobject'svaluefield.- Returns:
- the
longstored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than alongor thevaluefield has not yet been set
-
insert_longlong
public abstract void insert_longlong(long l) Inserts the givenlonginto thisAnyobject'svaluefield.- Parameters:
l- thelongto insert into thisAnyobject
-
extract_ushort
Extracts theshortin thisAnyobject'svaluefield.- Returns:
- the
shortstored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than ashortor thevaluefield has not yet been set
-
insert_ushort
public abstract void insert_ushort(short s) Inserts the givenshortinto thisAnyobject'svaluefield.- Parameters:
s- theshortto insert into thisAnyobject
-
extract_ulong
Extracts theintin thisAnyobject'svaluefield.- Returns:
- the
intstored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than anintor thevaluefield has not yet been set
-
insert_ulong
public abstract void insert_ulong(int l) Inserts the givenintinto thisAnyobject'svaluefield.- Parameters:
l- theintto insert into thisAnyobject
-
extract_ulonglong
Extracts thelongin thisAnyobject'svaluefield.- Returns:
- the
longstored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than alongor thevaluefield has not yet been set
-
insert_ulonglong
public abstract void insert_ulonglong(long l) Inserts the givenlonginto thisAnyobject'svaluefield.- Parameters:
l- thelongto insert into thisAnyobject
-
extract_float
Extracts thefloatin thisAnyobject'svaluefield.- Returns:
- the
floatstored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than afloator thevaluefield has not yet been set
-
insert_float
public abstract void insert_float(float f) Inserts the givenfloatinto thisAnyobject'svaluefield.- Parameters:
f- thefloatto insert into thisAnyobject
-
extract_double
Extracts thedoublein thisAnyobject'svaluefield.- Returns:
- the
doublestored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than adoubleor thevaluefield has not yet been set
-
insert_double
public abstract void insert_double(double d) Inserts the givendoubleinto thisAnyobject'svaluefield.- Parameters:
d- thedoubleto insert into thisAnyobject
-
extract_boolean
Extracts thebooleanin thisAnyobject'svaluefield.- Returns:
- the
booleanstored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than abooleanor thevaluefield has not yet been set
-
insert_boolean
public abstract void insert_boolean(boolean b) Inserts the givenbooleaninto thisAnyobject'svaluefield.- Parameters:
b- thebooleanto insert into thisAnyobject
-
extract_char
Extracts thecharin thisAnyobject'svaluefield.- Returns:
- the
charstored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than acharor thevaluefield has not yet been set
-
insert_char
Inserts the givencharinto thisAnyobject'svaluefield.- Parameters:
c- thecharto insert into thisAnyobject- Throws:
DATA_CONVERSION- if there is a data conversion error
-
extract_wchar
Extracts thecharin thisAnyobject'svaluefield.- Returns:
- the
charstored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than acharor thevaluefield has not yet been set
-
insert_wchar
public abstract void insert_wchar(char c) Inserts the givencharinto thisAnyobject'svaluefield.- Parameters:
c- thecharto insert into thisAnyobject
-
extract_octet
Extracts thebytein thisAnyobject'svaluefield.- Returns:
- the
bytestored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than abyteor thevaluefield has not yet been set
-
insert_octet
public abstract void insert_octet(byte b) Inserts the givenbyteinto thisAnyobject'svaluefield.- Parameters:
b- thebyteto insert into thisAnyobject
-
extract_any
Extracts theAnyobject in thisAnyobject'svaluefield.- Returns:
- the
Anyobject stored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than anAnyobject or thevaluefield has not yet been set
-
insert_any
Inserts the givenAnyobject into thisAnyobject'svaluefield.- Parameters:
a- theAnyobject to insert into thisAnyobject
-
extract_Object
Extracts theorg.omg.CORBA.Objectin thisAnyobject'svaluefield.- Returns:
- the
org.omg.CORBA.Objectstored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than anorg.omg.CORBA.Objector thevaluefield has not yet been set
-
insert_Object
Inserts the givenorg.omg.CORBA.Objectobject into thisAnyobject'svaluefield.- Parameters:
o- theorg.omg.CORBA.Objectobject to insert into thisAnyobject
-
extract_Value
Extracts thejava.io.Serializableobject in thisAnyobject'svaluefield.- Returns:
- the
java.io.Serializableobject stored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than ajava.io.Serializableobject or thevaluefield has not yet been set
-
insert_Value
Inserts the givenjava.io.Serializableobject into thisAnyobject'svaluefield.- Parameters:
v- thejava.io.Serializableobject to insert into thisAnyobject
-
insert_Value
Inserts the givenjava.io.Serializableobject into thisAnyobject'svaluefield.- Parameters:
v- thejava.io.Serializableobject to insert into thisAnyobjectt- theTypeCodeobject that is to be inserted into thisAnyobject'stypefield and that describes thejava.io.Serializableobject being inserted- Throws:
MARSHAL- if the ORB has a problem marshalling or unmarshalling parameters
-
insert_Object
Inserts the givenorg.omg.CORBA.Objectobject into thisAnyobject'svaluefield.- Parameters:
o- theorg.omg.CORBA.Objectinstance to insert into thisAnyobjectt- theTypeCodeobject that is to be inserted into thisAnyobject and that describes theObjectbeing inserted- Throws:
BAD_OPERATION- if this method is invalid for thisAnyobjectBAD_PARAM
-
extract_string
Extracts theStringobject in thisAnyobject'svaluefield.- Returns:
- the
Stringobject stored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than aStringobject or thevaluefield has not yet been set
-
insert_string
Inserts the givenStringobject into thisAnyobject'svaluefield.- Parameters:
s- theStringobject to insert into thisAnyobject- Throws:
DATA_CONVERSION- if there is a data conversion errorMARSHAL- if the ORB has a problem marshalling or unmarshalling parameters
-
extract_wstring
Extracts theStringobject in thisAnyobject'svaluefield.- Returns:
- the
Stringobject stored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than aStringobject or thevaluefield has not yet been set
-
insert_wstring
Inserts the givenStringobject into thisAnyobject'svaluefield.- Parameters:
s- theStringobject to insert into thisAnyobject- Throws:
MARSHAL- if the ORB has a problem marshalling or unmarshalling parameters
-
extract_TypeCode
Extracts theTypeCodeobject in thisAnyobject'svaluefield.- Returns:
- the
TypeCodeobject stored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than aTypeCodeobject or thevaluefield has not yet been set
-
insert_TypeCode
Inserts the givenTypeCodeobject into thisAnyobject'svaluefield.- Parameters:
t- theTypeCodeobject to insert into thisAnyobject
-
extract_Principal
Deprecated.Deprecated by CORBA 2.2.Extracts thePrincipalobject in thisAnyobject'svaluefield. Note that the classPrincipalhas been deprecated.- Returns:
- the
Principalobject stored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than aPrincipalobject or thevaluefield has not yet been set- See Also:
-
insert_Principal
Deprecated.Deprecated by CORBA 2.2.Inserts the givenPrincipalobject into thisAnyobject'svaluefield. Note that the classPrincipalhas been deprecated.- Parameters:
p- thePrincipalobject to insert into thisAnyobject- See Also:
-
extract_Streamable
Extracts aStreamablefrom thisAnyobject'svaluefield. This method allows the extraction of non-primitive IDL types.- Returns:
- the
Streamablestored in theAnyobject. - Throws:
BAD_INV_ORDER- if the caller has invoked operations in the wrong order- See Also:
-
insert_Streamable
Inserts the givenStreamableobject into thisAnyobject'svaluefield. This method allows the insertion of non-primitive IDL types.- Parameters:
s- theStreamableobject to insert into thisAnyobject; may be a non-primitive IDL type- See Also:
-
extract_fixed
Extracts thejava.math.BigDecimalobject in thisAnyobject'svaluefield.- Returns:
- the
java.math.BigDecimalobject stored in thisAnyobject - Throws:
BAD_OPERATION- if thisAnyobject contains something other than ajava.math.BigDecimalobject or thevaluefield has not yet been set- See Also:
-
insert_fixed
Throws anorg.omg.CORBA.NO_IMPLEMENTexception.Inserts the given
java.math.BigDecimalobject into thisAnyobject'svaluefield.- Parameters:
value- thejava.math.BigDecimalobject to insert into thisAnyobject- See Also:
-
insert_fixed
Throws anorg.omg.CORBA.NO_IMPLEMENTexception.Inserts the given
java.math.BigDecimalobject into thisAnyobject'svaluefield.- Parameters:
value- thejava.math.BigDecimalobject to insert into thisAnyobjecttype- theTypeCodeobject that is to be inserted into thisAnyobject'stypefield and that describes thejava.math.BigDecimalobject being inserted- Throws:
BAD_INV_ORDER- if this method is invoked improperly- See Also:
-