|
The Any.java Java example source code
/*
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.omg.CORBA;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
import org.omg.CORBA.portable.IDLEntity;
/**
* Serves as a container for any data that can be
* described in IDL or for any IDL primitive type.
* An <code>Any object is used as a component of a
* <code>NamedValue object, which provides information about
* arguments or return values in requests, and which is used to define
* name/value pairs in <code>Context objects.
<p>
*
* An <code>Any object consists of two parts:
* <OL>
* <LI>a data value
* <LI>a TypeCode object describing the type of the data
* value contained in the <code>Any object. For example,
* a <code>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 <code>TypeCode object is itself a
* <code>TypeCode object.)
* </OL>
*
* <P>
* <a name="anyOps" class consists of pairs of methods
* for inserting values into and extracting values from an
* <code>Any object.
* <P>
* For a given primitive type X, these methods are:
* <dl>
* <dt> void insert_X(X x)
* <dd> This method allows the insertion of
* an instance <code>x of primitive type X
* into the <code>value field of the Any object.
* Note that the method
* <code>insert_X also resets the Any object's
* <code>type field if necessary.
* <dt> X extract_X()
* <dd> This method allows the extraction of an instance of
* type <code>X from the Any object.
* <BR>
* <P>
* This method throws the exception <code>BAD_OPERATION under two conditions:
* <OL>
* <LI> the type of the element contained in the Any object is not
* <code>X
* <LI> the method extract_X is called before
* the <code>value field of the Any object
* has been set
* </OL>
* </dl>
* <P>
* There are distinct method pairs for each
* primitive IDL data type (<code>insert_long and extract_long ,
* <code>insert_string and extract_string , and so on).
* <P>
* The class <code>Any also has methods for
* getting and setting the type code,
* for testing two <code>Any objects for equality,
* and for reading an <code>Any object from a stream or
* writing it to a stream.
* <BR>
* @since JDK1.2
*/
abstract public class Any implements IDLEntity {
/**
* Checks for equality between this <code>Any object and the
* given <code>Any object. Two Any objects are
* equal if both their values and type codes are equal.
*
* @param a the <code>Any object to test for equality
* @return <code>true if the Any objects are equal;
* <code>false otherwise
* @see <a href="package-summary.html#unimpl">CORBA package
* comments for unimplemented features</a>
*/
abstract public boolean equal(Any a);
/**
* Returns type information for the element contained in this
* <code>Any object.
*
* @return the <code>TypeCode object containing type information
* about the value contained in this <code>Any object
*/
abstract public TypeCode type();
/**
* Sets this <code>Any object's type field
* to the given <code>TypeCode object and clears its value.
* <P>
* 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 <code>out parameters. Generally, setting the type
* is done by the <code>insert_X methods, which will set the type
* to X if it is not already set to X.
*
* @param t the <code>TypeCode object giving
* information for the value in
* this <code>Any object
*/
abstract public void type(TypeCode t);
///////////////////////////////////////////////////////////////////////////
// marshalling/unmarshalling routines
/**
* Reads off (unmarshals) the value of an <code>Any object from
* the given input stream using the given typecode.
*
* @param is the <code>org.omg.CORBA.portable.InputStream
* object from which to read
* the value contained in this <code>Any object
*
* @param t a <code>TypeCode object containing type information
* about the value to be read
*
* @exception MARSHAL when the given <code>TypeCode object is
* not consistent with the value that was contained
* in the input stream
*/
abstract public void read_value(InputStream is, TypeCode t)
throws MARSHAL;
/**
* Writes out the value of this <code>Any object
* to the given output stream. If both <code>typecode
* and <code>value need to be written, use
* <code>create_output_stream() to create an OutputStream ,
* then use <code>write_any on the OutputStream .
* <P>
* If this method is called on an <code>Any object that has not
* had a value inserted into its <code>value field, it will throw
* the exception <code>java.lang.NullPointerException.
*
* @param os the <code>org.omg.CORBA.portable.OutputStream
* object into which to marshal the value
* of this <code>Any object
*
*/
abstract public void write_value(OutputStream os);
/**
* Creates an output stream into which this <code>Any object's
* value can be marshalled.
*
* @return the newly-created <code>OutputStream
*/
abstract public OutputStream create_output_stream();
/**
* Creates an input stream from which this <code>Any object's value
* can be unmarshalled.
*
* @return the newly-created <code>InputStream
*/
abstract public InputStream create_input_stream();
///////////////////////////////////////////////////////////////////////////
// basic insertion/extraction methods
/**
* Extracts the <code>short in this
* <code>Any object's value field.
*
* @return the <code>short stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>short or the
* <code>value field has not yet been set
*/
abstract public short extract_short() throws BAD_OPERATION;
/**
* Inserts the given <code>short
* into this <code>Any object's value field.
*
* @param s the <code>short to insert into this
* <code>Any object
*/
abstract public void insert_short(short s);
/**
* Extracts the <code>int in this
* <code>Any object's value field.
*
* @return the <code>int stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than an <code>int or the
* <code>value field has not yet been set
*/
abstract public int extract_long() throws BAD_OPERATION;
/**
* Inserts the given <code>int
* into this <code>Any object's value field.
*
* @param l the <code>int to insert into this
* <code>Any object
*/
abstract public void insert_long(int l);
/**
* Extracts the <code>long in this
* <code>Any object's value field.
*
* @return the <code>long stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>long or the
* <code>value field has not yet been set
*/
abstract public long extract_longlong() throws BAD_OPERATION;
/**
* Inserts the given <code>long
* into this <code>Any object's value field.
*
* @param l the <code>long to insert into this
* <code>Any object
*/
abstract public void insert_longlong(long l);
/**
* Extracts the <code>short in this
* <code>Any object's value field.
*
* @return the <code>short stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>short or the
* <code>value field has not yet been set
*/
abstract public short extract_ushort() throws BAD_OPERATION;
/**
* Inserts the given <code>short
* into this <code>Any object's value field.
*
* @param s the <code>short to insert into this
* <code>Any object
*/
abstract public void insert_ushort(short s);
/**
* Extracts the <code>int in this
* <code>Any object's value field.
*
* @return the <code>int stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than an <code>int or the
* <code>value field has not yet been set
*/
abstract public int extract_ulong() throws BAD_OPERATION;
/**
* Inserts the given <code>int
* into this <code>Any object's value field.
*
* @param l the <code>int to insert into this
* <code>Any object
*/
abstract public void insert_ulong(int l);
/**
* Extracts the <code>long in this
* <code>Any object's value field.
*
* @return the <code>long stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>long or the
* <code>value field has not yet been set
*/
abstract public long extract_ulonglong() throws BAD_OPERATION;
/**
* Inserts the given <code>long
* into this <code>Any object's value field.
*
* @param l the <code>long to insert into this
* <code>Any object
*/
abstract public void insert_ulonglong(long l);
/**
* Extracts the <code>float in this
* <code>Any object's value field.
*
* @return the <code>float stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>float or the
* <code>value field has not yet been set
*/
abstract public float extract_float() throws BAD_OPERATION;
/**
* Inserts the given <code>float
* into this <code>Any object's value field.
*
* @param f the <code>float to insert into this
* <code>Any object
*/
abstract public void insert_float(float f);
/**
* Extracts the <code>double in this
* <code>Any object's value field.
*
* @return the <code>double stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>double or the
* <code>value field has not yet been set
*/
abstract public double extract_double() throws BAD_OPERATION;
/**
* Inserts the given <code>double
* into this <code>Any object's value field.
*
* @param d the <code>double to insert into this
* <code>Any object
*/
abstract public void insert_double(double d);
/**
* Extracts the <code>boolean in this
* <code>Any object's value field.
*
* @return the <code>boolean stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>boolean or the
* <code>value field has not yet been set
*/
abstract public boolean extract_boolean() throws BAD_OPERATION;
/**
* Inserts the given <code>boolean
* into this <code>Any object's value field.
*
* @param b the <code>boolean to insert into this
* <code>Any object
*/
abstract public void insert_boolean(boolean b);
/**
* Extracts the <code>char in this
* <code>Any object's value field.
*
* @return the <code>char stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>char or the
* <code>value field has not yet been set
*/
abstract public char extract_char() throws BAD_OPERATION;
/**
* Inserts the given <code>char
* into this <code>Any object's value field.
*
* @param c the <code>char to insert into this
* <code>Any object
* @exception DATA_CONVERSION if there is a data conversion
* error
*/
abstract public void insert_char(char c) throws DATA_CONVERSION;
/**
* Extracts the <code>char in this
* <code>Any object's value field.
*
* @return the <code>char stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>char or the
* <code>value field has not yet been set
*/
abstract public char extract_wchar() throws BAD_OPERATION;
/**
* Inserts the given <code>char
* into this <code>Any object's value field.
*
* @param c the <code>char to insert into this
* <code>Any object
*/
abstract public void insert_wchar(char c);
/**
* Extracts the <code>byte in this
* <code>Any object's value field.
*
* @return the <code>byte stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>byte or the
* <code>value field has not yet been set
*/
abstract public byte extract_octet() throws BAD_OPERATION;
/**
* Inserts the given <code>byte
* into this <code>Any object's value field.
*
* @param b the <code>byte to insert into this
* <code>Any object
*/
abstract public void insert_octet(byte b);
/**
* Extracts the <code>Any object in this
* <code>Any object's value field.
*
* @return the <code>Any object stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than an <code>Any object or the
* <code>value field has not yet been set
*/
abstract public Any extract_any() throws BAD_OPERATION;
/**
* Inserts the given <code>Any object
* into this <code>Any object's value field.
*
* @param a the <code>Any object to insert into this
* <code>Any object
*/
abstract public void insert_any(Any a);
/**
* Extracts the <code>org.omg.CORBA.Object in this
* <code>Any object's value field.
*
* @return the <code>org.omg.CORBA.Object stored in
* this <code>Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than an
* <code>org.omg.CORBA.Object or the
* <code>value field has not yet been set
*/
abstract public org.omg.CORBA.Object extract_Object() throws BAD_OPERATION;
/**
* Inserts the given <code>org.omg.CORBA.Object object
* into this <code>Any object's value field.
*
* @param o the <code>org.omg.CORBA.Object object to insert into this
* <code>Any object
*/
abstract public void insert_Object(org.omg.CORBA.Object o);
/**
* Extracts the <code>java.io.Serializable object in this
* <code>Any object's value field.
*
* @return the <code>java.io.Serializable object stored in
* this <code>Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>java.io.Serializable
* object or the
* <code>value field has not yet been set
*/
abstract public java.io.Serializable extract_Value() throws BAD_OPERATION ;
/**
* Inserts the given <code>java.io.Serializable object
* into this <code>Any object's value field.
*
* @param v the <code>java.io.Serializable object to insert into this
* <code>Any object
*/
abstract public void insert_Value(java.io.Serializable v) ;
/**
* Inserts the given <code>java.io.Serializable object
* into this <code>Any object's value field.
*
* @param v the <code>java.io.Serializable object to insert into this
* <code>Any object
* @param t the <code>TypeCode object that is to be inserted into
* this <code>Any object's type field
* and that describes the <code>java.io.Serializable
* object being inserted
* @throws MARSHAL if the ORB has a problem marshalling or
* unmarshalling parameters
*/
abstract public void insert_Value(java.io.Serializable v, TypeCode t)
throws MARSHAL ;
/**
* Inserts the given <code>org.omg.CORBA.Object object
* into this <code>Any object's value field.
*
* @param o the <code>org.omg.CORBA.Object instance to insert into this
* <code>Any object
* @param t the <code>TypeCode object that is to be inserted into
* this <code>Any object and that describes
* the <code>Object being inserted
* @exception BAD_OPERATION if this method is invalid for this
* <code>Any object
*
*/
abstract public void insert_Object(org.omg.CORBA.Object o, TypeCode t)
throws BAD_PARAM;
/**
* Extracts the <code>String object in this
* <code>Any object's value field.
*
* @return the <code>String object stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>String object or the
* <code>value field has not yet been set
*/
abstract public String extract_string() throws BAD_OPERATION;
/**
* Inserts the given <code>String object
* into this <code>Any object's value field.
*
* @param s the <code>String object to insert into this
* <code>Any object
* @exception DATA_CONVERSION if there is a data conversion error
* @exception MARSHAL if the ORB has a problem marshalling or
* unmarshalling parameters
*/
abstract public void insert_string(String s) throws DATA_CONVERSION, MARSHAL;
/**
* Extracts the <code>String object in this
* <code>Any object's value field.
*
* @return the <code>String object stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>String object or the
* <code>value field has not yet been set
*/
abstract public String extract_wstring() throws BAD_OPERATION;
/**
* Inserts the given <code>String object
* into this <code>Any object's value field.
*
* @param s the <code>String object to insert into this
* <code>Any object
* @exception MARSHAL if the ORB has a problem marshalling or
* unmarshalling parameters
*/
abstract public void insert_wstring(String s) throws MARSHAL;
/**
* Extracts the <code>TypeCode object in this
* <code>Any object's value field.
*
* @return the <code>TypeCode object stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a <code>TypeCode object or the
* <code>value field has not yet been set
*/
abstract public TypeCode extract_TypeCode() throws BAD_OPERATION;
/**
* Inserts the given <code>TypeCode object
* into this <code>Any object's value field.
*
* @param t the <code>TypeCode object to insert into this
* <code>Any object
*/
abstract public void insert_TypeCode(TypeCode t);
/**
* Extracts the <code>Principal object in this
* <code>Any object's value field.
* Note that the class <code>Principal has been deprecated.
*
* @return the <code>Principal object stored in this Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a
* <code>Principal object or the
* <code>value field has not yet been set
* @see <a href="package-summary.html#unimpl">CORBA package
* comments for unimplemented features</a>
* @deprecated Deprecated by CORBA 2.2.
*/
@Deprecated
public Principal extract_Principal() throws BAD_OPERATION {
throw new org.omg.CORBA.NO_IMPLEMENT() ;
}
/**
* Inserts the given <code>Principal object
* into this <code>Any object's value field.
* Note that the class <code>Principal has been deprecated.
*
* @param p the <code>Principal object to insert into this
* <code>Any object
* @see <a href="package-summary.html#unimpl">CORBA package
* comments for unimplemented features</a>
* @deprecated Deprecated by CORBA 2.2.
*/
@Deprecated
public void insert_Principal(Principal p) {
throw new org.omg.CORBA.NO_IMPLEMENT() ;
}
///////////////////////////////////////////////////////////////////////////
// insertion/extraction of streamables
/**
* Extracts a <code>Streamable from this Any object's
* <code>value field. This method allows the extraction of
* non-primitive IDL types.
*
* @return the <code>Streamable stored in the Any object.
* @throws BAD_INV_ORDER if the caller has invoked operations in the wrong order
* @see <a href="package-summary.html#unimpl">CORBA package
* comments for unimplemented features</a>
*/
public org.omg.CORBA.portable.Streamable extract_Streamable()
throws org.omg.CORBA.BAD_INV_ORDER {
throw new org.omg.CORBA.NO_IMPLEMENT() ;
}
/**
* Inserts the given <code>Streamable object
* into this <code>Any object's value field.
* This method allows the insertion of non-primitive IDL types.
*
* @param s the <code>Streamable object to insert into this
* <code>Any object; may be a non-primitive
* IDL type
* @see <a href="package-summary.html#unimpl">CORBA package
* comments for unimplemented features</a>
*/
public void insert_Streamable(Streamable s) {
throw new org.omg.CORBA.NO_IMPLEMENT() ;
}
/**
* Extracts the <code>java.math.BigDecimal object in this
* <code>Any object's value field.
*
* @return the <code>java.math.BigDecimal object
* stored in this <code>Any object
* @exception BAD_OPERATION if this <code>Any object
* contains something other than a
* <code>java.math.BigDecimal object or the
* <code>value field has not yet been set
* @see <a href="package-summary.html#unimpl">CORBA package
* comments for unimplemented features</a>
*/
public java.math.BigDecimal extract_fixed() {
throw new org.omg.CORBA.NO_IMPLEMENT();
}
/**
* Throws an <a href="package-summary.html#NO_IMPLEMENT">
* <code>org.omg.CORBA.NO_IMPLEMENT exception.
* <P>
* Inserts the given <code>java.math.BigDecimal object
* into this <code>Any object's value field.
*
* @param value the <code>java.math.BigDecimal object
* to insert into this <code>Any object
* @see <a href="package-summary.html#unimpl">CORBA package
* comments for unimplemented features</a>
*/
public void insert_fixed(java.math.BigDecimal value) {
throw new org.omg.CORBA.NO_IMPLEMENT();
}
/**
* Throws an <a href="package-summary.html#NO_IMPLEMENT">
* <code>org.omg.CORBA.NO_IMPLEMENT exception.
* <P>
* Inserts the given <code>java.math.BigDecimal object
* into this <code>Any object's value field.
*
* @param value the <code>java.math.BigDecimal object
* to insert into this <code>Any object
* @param type the <code>TypeCode object that is to be inserted into
* this <code>Any object's type field
* and that describes the <code>java.math.BigDecimal
* object being inserted
* @throws org.omg.CORBA.BAD_INV_ORDER if this method is invoked improperly
* @see <a href="package-summary.html#unimpl">CORBA package
* comments for unimplemented features</a>
*/
public void insert_fixed(java.math.BigDecimal value, org.omg.CORBA.TypeCode type)
throws org.omg.CORBA.BAD_INV_ORDER
{
throw new org.omg.CORBA.NO_IMPLEMENT();
}
}
Other Java examples (source code examples)
Here is a short list of links related to this Java Any.java source code file:
|