Java Platform 1.2
Beta 4

Class org.omg.CORBA.Any

java.lang.Object
  |
  +--org.omg.CORBA.Any

public abstract class Any
extends Object
Serves as a container for any data that can be described in IDL or for any IDL primitive type. An 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:

  1. a data value
  2. a TypeCode object describing the type of the data value contained in the Any object. For example, a TypeCode 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 the TypeCode object is itself a TypeCode 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 type X into the value field of the Any object. Note that the method insert_X also resets the Any object's type field if necessary.
X extract_X()
This method allows the extraction of an instance of type X from the Any object.

This method throws the exception BAD_OPERATION under two conditions:

  1. the type of the element contained in the Any object is not X
  2. the method extract_X is called before the value field of the Any object has been set

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

Method Summary
abstract  InputStream create_input_stream()
          Creates an input stream from which this Any object's value can be unmarshalled.
abstract  OutputStream create_output_stream()
          Creates an output stream into which this Any object's value can be marshalled.
abstract  boolean equal(Any a)
          Checks for equality between this Any object and the given Any object.
abstract  Any extract_any()
           
abstract  boolean extract_boolean()
           
abstract  char extract_char()
           
abstract  double extract_double()
           
 Number extract_fixednum()
           
abstract  float extract_float()
           
abstract  int extract_long()
           
abstract  long extract_longlong()
           
abstract  Object extract_Object()
           
abstract  byte extract_octet()
           
abstract  Principal extract_Principal()
           
abstract  short extract_short()
           
abstract  String extract_string()
           
abstract  TypeCode extract_TypeCode()
           
abstract  int extract_ulong()
           
abstract  long extract_ulonglong()
           
abstract  short extract_ushort()
           
 Serializable extract_Value()
           
abstract  char extract_wchar()
           
abstract  String extract_wstring()
           
abstract  void insert_any(Any a)
           
abstract  void insert_boolean(boolean b)
           
abstract  void insert_char(char c)
           
abstract  void insert_double(double d)
           
 void insert_fixednum(Number n)
           
abstract  void insert_float(float f)
           
abstract  void insert_long(int l)
           
abstract  void insert_longlong(long l)
           
abstract  void insert_Object(Object o, TypeCode t)
           
abstract  void insert_Object(Object o)
           
abstract  void insert_octet(byte b)
           
abstract  void insert_Principal(Principal p)
           
abstract  void insert_short(short s)
           
abstract  void insert_Streamable(Streamable s)
          Inserts the given Streamable object into this Any object's value field.
abstract  void insert_string(String s)
           
abstract  void insert_TypeCode(TypeCode t)
           
abstract  void insert_ulong(int l)
           
abstract  void insert_ulonglong(long l)
           
abstract  void insert_ushort(short s)
           
 void insert_Value(Serializable v, TypeCode t)
           
 void insert_Value(Serializable v)
           
abstract  void insert_wchar(char c)
           
abstract  void insert_wstring(String s)
           
abstract  void read_value(InputStream is, TypeCode t)
          Reads off (unmarshals) the value of an Any object from the given input stream using the given typecode.
abstract  TypeCode type()
          Returns type information for the element contained in this Any object.
abstract  void type(TypeCode t)
          Sets this Any object's type field to the given TypeCode object and clears its value.
abstract  void write_value(OutputStream os)
          Writes out to the given output stream the typecode and value of this Any object.
 
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
 

Method Detail

type

public abstract TypeCode type()
Returns type information for the element contained in this Any object.
Returns:
the TypeCode object containing type information about the object contained in this Any.

type

public abstract void type(TypeCode t)
Sets this Any object's type field to the given TypeCode 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 the insert_X methods, which will set the type to X if it is not already set to X.

Parameters:
t - the TypeCode object giving information for the object in this Any object

equal

public abstract boolean equal(Any a)
Checks for equality between this Any object and the given Any object. Two Any objects are equal if both their values and type codes are equal.
Parameters:
a - the Any object to test for equality
Returns:
true if the Any objects are equal; false otherwise

read_value

public abstract void read_value(InputStream is,
                                TypeCode t)
                         throws MARSHAL
Reads off (unmarshals) the value of an Any object from the given input stream using the given typecode.
Parameters:
is - the org.omg.CORBA.portable.InputStream object from which to read the value contained in this Any object
t - a TypeCode object containing type information about the value to be read
Throws:
MARSHAL - when the given TypeCode object is not consistent with the value that was contained in the input stream

write_value

public abstract void write_value(OutputStream os)
                          throws MARSHAL
Writes out to the given output stream the typecode and value of this Any object.

If this method is called on an Any object that has not had a value inserted into its value field, it will throw the exception java.lang.NullPointerException.

Parameters:
os - the org.omg.CORBA.portable.OutputStream object into which to marshal the value and typecode of this Any object
Throws:
MARSHAL - when the typecode for this Any object is inconsistent with its value

create_output_stream

public abstract OutputStream create_output_stream()
Creates an output stream into which this Any object's value can be marshalled.
Returns:
the newly-created OutputStream

create_input_stream

public abstract InputStream create_input_stream()
Creates an input stream from which this Any object's value can be unmarshalled.
Returns:
the newly-created InputStream

insert_Streamable

public abstract void insert_Streamable(Streamable s)
Inserts the given Streamable object into this Any object's value field. This method allows the insertion of non-primitive IDL types.
Parameters:
s - the Streamable object to insert into this Any object

extract_short

public abstract short extract_short()
                             throws BAD_OPERATION

insert_short

public abstract void insert_short(short s)

extract_long

public abstract int extract_long()
                          throws BAD_OPERATION

insert_long

public abstract void insert_long(int l)

extract_longlong

public abstract long extract_longlong()
                               throws BAD_OPERATION

insert_longlong

public abstract void insert_longlong(long l)
                              throws BAD_OPERATION

extract_ushort

public abstract short extract_ushort()
                              throws BAD_OPERATION

insert_ushort

public abstract void insert_ushort(short s)

extract_ulong

public abstract int extract_ulong()
                           throws BAD_OPERATION

insert_ulong

public abstract void insert_ulong(int l)

extract_ulonglong

public abstract long extract_ulonglong()
                                throws BAD_OPERATION

insert_ulonglong

public abstract void insert_ulonglong(long l)

extract_float

public abstract float extract_float()
                             throws BAD_OPERATION

insert_float

public abstract void insert_float(float f)

extract_double

public abstract double extract_double()
                               throws BAD_OPERATION

insert_double

public abstract void insert_double(double d)

extract_boolean

public abstract boolean extract_boolean()
                                 throws BAD_OPERATION

insert_boolean

public abstract void insert_boolean(boolean b)

extract_char

public abstract char extract_char()
                           throws BAD_OPERATION

insert_char

public abstract void insert_char(char c)

extract_octet

public abstract byte extract_octet()
                            throws BAD_OPERATION

insert_octet

public abstract void insert_octet(byte b)

extract_wchar

public abstract char extract_wchar()
                            throws BAD_OPERATION

insert_wchar

public abstract void insert_wchar(char c)

extract_any

public abstract Any extract_any()
                         throws BAD_OPERATION

insert_any

public abstract void insert_any(Any a)

extract_string

public abstract String extract_string()
                               throws BAD_OPERATION

insert_string

public abstract void insert_string(String s)

extract_wstring

public abstract String extract_wstring()
                                throws BAD_OPERATION

insert_wstring

public abstract void insert_wstring(String s)

extract_Object

public abstract Object extract_Object()
                               throws BAD_OPERATION

insert_Object

public abstract void insert_Object(Object o)

insert_Object

public abstract void insert_Object(Object o,
                                   TypeCode t)

extract_TypeCode

public abstract TypeCode extract_TypeCode()
                                   throws BAD_OPERATION

insert_TypeCode

public abstract void insert_TypeCode(TypeCode t)

extract_Principal

public abstract Principal extract_Principal()
                                     throws BAD_OPERATION

insert_Principal

public abstract void insert_Principal(Principal p)

extract_fixednum

public Number extract_fixednum()

insert_fixednum

public void insert_fixednum(Number n)

extract_Value

public Serializable extract_Value()
                           throws BAD_OPERATION

insert_Value

public void insert_Value(Serializable v)

insert_Value

public void insert_Value(Serializable v,
                         TypeCode t)
                  throws MARSHAL

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.