Any.java revision 157
157N/A * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 157N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 157N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 157N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 157N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Serves as a container for any data that can be 0N/A * described in IDL or for any IDL primitive type. 0N/A * An <code>Any</code> object is used as a component of a 0N/A * <code>NamedValue</code> object, which provides information about 0N/A * arguments or return values in requests, and which is used to define 0N/A * An <code>Any</code> object consists of two parts: 0N/A * <LI>a <code>TypeCode</code> object describing the type of the data 0N/A * value contained in the <code>Any</code> object. For example, 0N/A * a <code>TypeCode</code> object for an array contains 0N/A * a field for the length of the array and a field for 0N/A * the type of elements in the array. (Note that in this case, the 0N/A * second field of the <code>TypeCode</code> object is itself a 0N/A * <code>TypeCode</code> object.) 0N/A * <a name="anyOps"</a> 0N/A * A large part of the <code>Any</code> class consists of pairs of methods 0N/A * for inserting values into and extracting values from an 0N/A * <code>Any</code> object. 0N/A * For a given primitive type X, these methods are: 0N/A * <dt><code><bold> void insert_X(X x)</bold></code> 0N/A * <dd> This method allows the insertion of 0N/A * an instance <code>x</code> of primitive type <code>X</code> 0N/A * into the <code>value</code> field of the <code>Any</code> object. 0N/A * Note that the method 0N/A * <code>insert_X</code> also resets the <code>Any</code> object's 0N/A * <code>type</code> field if necessary. 0N/A * <dt> <code><bold>X extract_X()</bold></code> 0N/A * <dd> This method allows the extraction of an instance of 0N/A * type <code>X</code> from the <code>Any</code> object. 0N/A * This method throws the exception <code>BAD_OPERATION</code> under two conditions: 0N/A * <LI> the type of the element contained in the <code>Any</code> object is not 0N/A * <LI> the method <code>extract_X</code> is called before 0N/A * the <code>value</code> field of the <code>Any</code> object 0N/A * There are distinct method pairs for each 0N/A * primitive IDL data type (<code>insert_long</code> and <code>extract_long</code>, 0N/A * <code>insert_string</code> and <code>extract_string</code>, and so on).<BR> 0N/A * The class <code>Any</code> also has methods for 0N/A * getting and setting the type code, 0N/A * for testing two <code>Any</code> objects for equality, 0N/A * and for reading an <code>Any</code> object from a stream or 0N/A * writing it to a stream. 0N/A * Checks for equality between this <code>Any</code> object and the 0N/A * given <code>Any</code> object. Two <code>Any</code> objects are 0N/A * equal if both their values and type codes are equal. 0N/A * @param a the <code>Any</code> object to test for equality 0N/A * @return <code>true</code> if the <code>Any</code> objects are equal; 0N/A * <code>false</code> otherwise 0N/A * comments for unimplemented features</a> 0N/A * Returns type information for the element contained in this 0N/A * <code>Any</code> object. 0N/A * @return the <code>TypeCode</code> object containing type information 0N/A * about the value contained in this <code>Any</code> object 0N/A * Sets this <code>Any</code> object's <code>type</code> field 0N/A * to the given <code>TypeCode</code> object and clears its value. 0N/A * Note that using this method to set the type code wipes out the 0N/A * value if there is one. The method 0N/A * is provided primarily so that the type may be set properly for 0N/A * IDL <code>out</code> parameters. Generally, setting the type 0N/A * is done by the <code>insert_X</code> methods, which will set the type 0N/A * to X if it is not already set to X. 0N/A * @param t the <code>TypeCode</code> object giving 0N/A * information for the value in 0N/A * this <code>Any</code> object 0N/A /////////////////////////////////////////////////////////////////////////// 0N/A * Reads off (unmarshals) the value of an <code>Any</code> object from 0N/A * the given input stream using the given typecode. 0N/A * @param is the <code>org.omg.CORBA.portable.InputStream</code> 0N/A * object from which to read 0N/A * the value contained in this <code>Any</code> object 0N/A * @param t a <code>TypeCode</code> object containing type information 0N/A * about the value to be read 0N/A * @exception MARSHAL when the given <code>TypeCode</code> object is 0N/A * not consistent with the value that was contained 0N/A * in the input stream 0N/A * Writes out the value of this <code>Any</code> object 0N/A * to the given output stream. If both <code>typecode</code> 0N/A * and <code>value</code> need to be written, use 0N/A * <code>create_output_stream()</code> to create an <code>OutputStream</code>, 0N/A * then use <code>write_any</code> on the <code>OutputStream</code>. 0N/A * If this method is called on an <code>Any</code> object that has not 0N/A * had a value inserted into its <code>value</code> field, it will throw 0N/A * the exception <code>java.lang.NullPointerException</code>. 0N/A * @param os the <code>org.omg.CORBA.portable.OutputStream</code> 0N/A * object into which to marshal the value 0N/A * of this <code>Any</code> object 0N/A * Creates an output stream into which this <code>Any</code> object's 0N/A * value can be marshalled. 0N/A * @return the newly-created <code>OutputStream</code> 0N/A * Creates an input stream from which this <code>Any</code> object's value 0N/A * can be unmarshalled. 0N/A * @return the newly-created <code>InputStream</code> 0N/A /////////////////////////////////////////////////////////////////////////// 0N/A * Extracts the <code>short</code> in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>short</code> stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>short</code> or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>short</code> 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param s the <code>short</code> to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>int</code> in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>int</code> stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than an <code>int</code> or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>int</code> 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param l the <code>int</code> to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>long</code> in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>long</code> stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>long</code> or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>long</code> 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param l the <code>long</code> to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>short</code> in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>short</code> stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>short</code> or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>short</code> 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param s the <code>short</code> to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>int</code> in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>int</code> stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than an <code>int</code> or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>int</code> 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param l the <code>int</code> to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>long</code> in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>long</code> stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>long</code> or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>long</code> 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param l the <code>long</code> to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>float</code> in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>float</code> stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>float</code> or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>float</code> 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param f the <code>float</code> to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>double</code> in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>double</code> stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>double</code> or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>double</code> 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param d the <code>double</code> to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>boolean</code> in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>boolean</code> stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>boolean</code> or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>boolean</code> 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param b the <code>boolean</code> to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>char</code> in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>char</code> stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>char</code> or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>char</code> 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param c the <code>char</code> to insert into this 0N/A * <code>Any</code> object 0N/A * @exception DATA_CONVERSION if there is a data conversion 0N/A * Extracts the <code>char</code> in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>char</code> stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>char</code> or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>char</code> 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param c the <code>char</code> to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>byte</code> in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>byte</code> stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>byte</code> or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>byte</code> 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param b the <code>byte</code> to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>Any</code> object in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>Any</code> object stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than an <code>Any</code> object or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>Any</code> object 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param a the <code>Any</code> object to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>org.omg.CORBA.Object</code> in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>org.omg.CORBA.Object</code> stored in 0N/A * this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than an 0N/A * <code>org.omg.CORBA.Object</code> or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>org.omg.CORBA.Object</code> object 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param o the <code>org.omg.CORBA.Object</code> object to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>java.io.Serializable</code> object in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>java.io.Serializable</code> object stored in 0N/A * this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>java.io.Serializable</code> 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>java.io.Serializable</code> object 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param v the <code>java.io.Serializable</code> object to insert into this 0N/A * <code>Any</code> object 0N/A * Inserts the given <code>java.io.Serializable</code> object 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param v the <code>java.io.Serializable</code> object to insert into this 0N/A * <code>Any</code> object 0N/A * @param t the <code>TypeCode</code> object that is to be inserted into 0N/A * this <code>Any</code> object's <code>type</code> field 0N/A * and that describes the <code>java.io.Serializable</code> 0N/A * object being inserted 0N/A * @throws MARSHAL if the ORB has a problem marshalling or 0N/A * unmarshalling parameters 0N/A * Inserts the given <code>org.omg.CORBA.Object</code> object 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param o the <code>org.omg.CORBA.Object</code> instance to insert into this 0N/A * <code>Any</code> object 0N/A * @param t the <code>TypeCode</code> object that is to be inserted into 0N/A * this <code>Any</code> object and that describes 0N/A * the <code>Object</code> being inserted 0N/A * @exception BAD_OPERATION if this method is invalid for this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>String</code> object in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>String</code> object stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>String</code> object or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>String</code> object 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param s the <code>String</code> object to insert into this 0N/A * <code>Any</code> object 0N/A * @exception DATA_CONVERSION if there is a data conversion error 0N/A * @exception MARSHAL if the ORB has a problem marshalling or 0N/A * unmarshalling parameters 0N/A * Extracts the <code>String</code> object in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>String</code> object stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>String</code> object or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>String</code> object 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param s the <code>String</code> object to insert into this 0N/A * <code>Any</code> object 0N/A * @exception MARSHAL if the ORB has a problem marshalling or 0N/A * unmarshalling parameters 0N/A * Extracts the <code>TypeCode</code> object in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>TypeCode</code> object stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a <code>TypeCode</code> object or the 0N/A * <code>value</code> field has not yet been set 0N/A * Inserts the given <code>TypeCode</code> object 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param t the <code>TypeCode</code> object to insert into this 0N/A * <code>Any</code> object 0N/A * Extracts the <code>Principal</code> object in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * Note that the class <code>Principal</code> has been deprecated. 0N/A * @return the <code>Principal</code> object stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a 0N/A * <code>Principal</code> object or the 0N/A * <code>value</code> field has not yet been set 0N/A * comments for unimplemented features</a> 0N/A * @deprecated Deprecated by CORBA 2.2. 0N/A * Inserts the given <code>Principal</code> object 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * Note that the class <code>Principal</code> has been deprecated. 0N/A * @param p the <code>Principal</code> object to insert into this 0N/A * <code>Any</code> object 0N/A * comments for unimplemented features</a> 0N/A * @deprecated Deprecated by CORBA 2.2. 0N/A /////////////////////////////////////////////////////////////////////////// 0N/A * Extracts a <code>Streamable</code> from this <code>Any</code> object's 0N/A * <code>value</code> field. This method allows the extraction of 0N/A * non-primitive IDL types. 0N/A * @return the <code>Streamable</code> stored in the <code>Any</code> object. 0N/A * @throws BAD_INV_ORDER if the caller has invoked operations in the wrong order 0N/A * comments for unimplemented features</a> 0N/A * Inserts the given <code>Streamable</code> object 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * This method allows the insertion of non-primitive IDL types. 0N/A * @param s the <code>Streamable</code> object to insert into this 0N/A * <code>Any</code> object; may be a non-primitive 0N/A * comments for unimplemented features</a> 0N/A * Extracts the <code>java.math.BigDecimal</code> object in this 0N/A * <code>Any</code> object's <code>value</code> field. 0N/A * @return the <code>java.math.BigDecimal</code> object 0N/A * stored in this <code>Any</code> object 0N/A * @exception BAD_OPERATION if this <code>Any</code> object 0N/A * contains something other than a 0N/A * <code>java.math.BigDecimal</code> object or the 0N/A * <code>value</code> field has not yet been set 0N/A * comments for unimplemented features</a> 0N/A * <code>org.omg.CORBA.NO_IMPLEMENT</code></a> exception. 0N/A * Inserts the given <code>java.math.BigDecimal</code> object 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param value the <code>java.math.BigDecimal</code> object 0N/A * to insert into this <code>Any</code> object 0N/A * comments for unimplemented features</a> 0N/A * <code>org.omg.CORBA.NO_IMPLEMENT</code></a> exception. 0N/A * Inserts the given <code>java.math.BigDecimal</code> object 0N/A * into this <code>Any</code> object's <code>value</code> field. 0N/A * @param value the <code>java.math.BigDecimal</code> object 0N/A * to insert into this <code>Any</code> object 0N/A * @param type the <code>TypeCode</code> object that is to be inserted into 0N/A * this <code>Any</code> object's <code>type</code> field 0N/A * and that describes the <code>java.math.BigDecimal</code> 0N/A * object being inserted 0N/A * @throws org.omg.CORBA.BAD_INV_ORDER if this method is invoked improperly 0N/A * comments for unimplemented features</a>