286N/A<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
286N/A Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. 286N/A DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 286N/A This code is free software; you can redistribute it and/or modify it 286N/A under the terms of the GNU General Public License version 2 only, as 286N/A published by the Free Software Foundation. Sun designates this 286N/A particular file as subject to the "Classpath" exception as provided 286N/A by Sun in the LICENSE file that accompanied this code. 286N/A This code is distributed in the hope that it will be useful, but WITHOUT 286N/A ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 286N/A FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 286N/A version 2 for more details (a copy is included in the LICENSE file that 286N/A accompanied this code). 286N/A You should have received a copy of the GNU General Public License version 286N/A 2 along with this work; if not, write to the Free Software Foundation, 286N/A Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 286N/A Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 286N/A<
P>Provides classes and interfaces that enable traversal of the data value
286N/A associated with an <
code>any</
code> at
286N/Aruntime, and extraction of the primitive constituents of the data value.
286N/A<
P>An <
code>any</
code> can be passed to a program that doesn't have any static information
286N/Afor the type of the <
code>any</
code> (code generated for the type by an IDL compiler has not
286N/Abeen compiled with the object implementation). As a result, the object receiving the
286N/A<
code>any</
code> does not have a portable method of using it.
286N/A<
P><
code>DynAny</
code>s enable traversal of the data value associated with an
286N/A<
code>any</
code> at runtime, and extraction of the primitive constituents of the data value.
286N/AThis is especially helpful for writing powerful generic servers (bridges, event channels
286N/Asupporting filtering). Similarly, this facility enables the construction of an
286N/A<
code>any</
code> at runtime, without having static knowledge of its type. This is especially
286N/Ahelpful for writing generic clients (bridges, browsers, debuggers, user interface tools).
286N/A<
P><
code>Any</
code> values can be dynamically interpreted (traversed) and constructed through
286N/A<
tt>DynAny</
tt> objects. A <
tt>DynAny</
tt> object is associated with a data
286N/Avalue which corresponds to a copy of the value inserted into an <
tt>Any</
tt>. A
286N/A<
tt>DynAny</
tt> object may be viewed as an ordered collection of component
286N/A<
tt>DynAny</
tt>s. For <
tt>DynAny</
tt>s representing a basic type, such as <
code>long</
code>,
286N/Aor a type without components, such as an empty exception, the ordered collection of
286N/A<
P>Each <
tt>DynAny</
tt> object maintains the notion of a current position into its collection
286N/Aof component <
tt>DynAny</
tt>s. The current position is identified by an index value that runs
286N/Afrom 0 to n-1, where <
em>n</
em> is the number of components. The special index value -1
286N/Aindicates a current position that points nowhere.
286N/A For values that cannot have a current position (such as an empty exception),
286N/A the index value is fixed at -1.
286N/A If a <
code>DynAny</
code> is initialized with a value that has components, the index is
286N/A After creation of an uninitialized <
code>DynAny</
code> (that is, a <
code>DynAny</
code> that
286N/Ahas no value but a <
code>TypeCode</
code>
286N/A that permits components), the current position depends on the type of value represented by
286N/A the <
code>DynAny</
code>. (The current position is set to 0 or -1, depending on whether the
286N/A gets default values for its components.)
286N/A <
P>The iteration operations <
code>rewind</
code>, <
code>seek</
code>, and <
code>next</
code>
286N/Acan be used to change the current position
286N/A and the <
code>current_component</
code> operation returns the component at the current
286N/A The <
code>component_count</
code> operation returns the number of components of a
286N/A Collectively, these operations enable iteration over the components of a
286N/A<
code>DynAny</
code>, for example,
286N/A to (recursively) examine its contents.
286N/A <
P>A constructed <
code>DynAny</
code> object is a <
code>DynAny</
code> object associated with
286N/A There is a different interface, inheriting from the <
code>DynAny</
code> interface,
286N/A each kind of constructed type in IDL (fixed, enum, struct, sequence, union, array,
286N/A exception, and value type). A constructed <
code>DynAny</
code> object exports operations
286N/Athat enable the creation of new <
code>DynAny</
code> objects,
286N/A each of them associated with a component of the constructed data value.
286N/A As an example, a <
code>DynStruct</
code> is associated with a <
code>struct</
code> value. This
286N/Ameans that the <
code>DynStruct</
code>
286N/A may be seen as owning an ordered collection of components, one for each structure member.
286N/A The <
code>DynStruct</
code> object exports operations that enable the creation of new
286N/A<
code>DynAny</
code> objects,
286N/A each of them associated with a member of the <
code>struct</
code>.
286N/A <
P>If a <
code>DynAny</
code> object has been obtained from another (constructed)
286N/A<
code>DynAny</
code> object,
286N/A such as a <
code>DynAny</
code> representing a structure member that was created from a
286N/A the member <
code>DynAny</
code> is logically contained in the <
code>DynStruct</
code>.
286N/A Calling an <
code>insert</
code> or <
code>get</
code> operation leaves the current position
286N/A Destroying a top-level <
code>DynAny</
code> object (one that was not obtained as a component
286N/Aof another <
code>DynAny</
code>)
286N/A also destroys any component <
code>DynAny</
code> objects obtained from it.
286N/A Destroying a non-top level <
code>DynAny</
code> object does nothing.
286N/A Invoking operations on a destroyed top-level <
code>DynAny</
code> or any of its descendants
286N/Araises OBJECT_NOT_EXIST.
286N/A If the programmer wants to destroy a <
code>DynAny</
code> object but still wants to
286N/Amanipulate some component
286N/A of the data value associated with it, then he or she should first create a
286N/A<
code>DynAny</
code> for the component
286N/A and, after that, make a copy of the created <
code>DynAny</
code> object.
286N/A <
P>The behavior of <
code>DynAny</
code> objects has been defined in order to enable efficient
286N/A in terms of allocated memory space and speed of access. <
code>DynAny</
code> objects are
286N/A for traversing values extracted from <
code>any</
code>s or constructing values of
286N/A<
code>any</
code>s at runtime.
286N/A Their use for other purposes is not recommended.
286N/A <
H2>Handling DynAny objects</
H2>
286N/A <
P><
code>Insert</
code> and <
code>get</
code> operations are necessary to handle basic
286N/A<
code>DynAny</
code> objects
286N/A but are also helpful to handle constructed <
code>DynAny</
code> objects.
286N/A Inserting a basic data type value into a constructed <
code>DynAny</
code> object
286N/A implies initializing the current component of the constructed data value
286N/A associated with the <
code>DynAny</
code> object. For example, invoking
286N/A<
code>insert_boolean</
code> on a
286N/A <
code>DynStruct</
code> implies inserting a <
code>boolean</
code> data value at the current
286N/A of the associated <
code>struct</
code> data value.
286N/A A type is consistent for inserting or extracting a value if its <
code>TypeCode</
code> is
286N/A the <
code>TypeCode</
code> contained in the <
code>DynAny</
code> or, if the
286N/A<
code>DynAny</
code> has components, is equivalent to the <
code>TypeCode</
code>
286N/A of the <
code>DynAny</
code> at the current position.
286N/A <
P>Basic operations include:
286N/A <
LI>insert_boolean, get_boolean
286N/A <
LI>insert_char, get_char
286N/A <
LI>insert_short, get_short
286N/A <
LI>insert_ushort, get_ushort
286N/A <
LI>insert_long, get_long
286N/A <
LI>insert_ulong, get_ulong
286N/A <
LI>insert_double, get_double
286N/A <
LI>insert_string, get_string
286N/A <
LI>insert_reference, get_reference
286N/A <
LI>insert_typecode, get_typecode
286N/A <
LI>insert_longlong, get_longlong
286N/A <
LI>insert_ulonglong, get_ulonglong
286N/A <
LI>insert_longdouble, get_longdouble
286N/A <
LI>insert_wchar, get_wchar
286N/A <
LI>insert_wstring, get_wstring
286N/A <
LI>insert_any, get_any
286N/A <
LI>insert_dyn_any, get_dyn_any
286N/A <
LI>insert_val, get_val
286N/A <
LI>insert_octet, get_octet
286N/A <
LI>insert_float, get_float
286N/A <
LI>get_members_as_dyn_any
286N/A <
LI>get_elements_as_dyn_any
286N/A <
LI>get_boxed_value_as_dyn_any
286N/A <
P><
code>DynAny</
code> and <
code>DynAnyFactory</
code> objects are intended to be local to
286N/Athe process in which they are
286N/A created and used. This means that references to <
code>DynAny</
code> and
286N/A<
code>DynAnyFactory</
code> objects cannot be exported
286N/A If any attempt is made to do so, the offending operation will raise a MARSHAL system
286N/A Since their interfaces are specified in IDL, <
code>DynAny</
code> objects export operations
286N/Aexported through the <
code>Object</
code>
286N/A interface may raise the standard NO_IMPLEMENT exception.
286N/A An attempt to use a <
code>DynAny</
code> object with the DII may raise the NO_IMPLEMENT
286N/A<
H3>Package Specification</
H3>
286N/A<
P>For a precise list of supported sections of official specifications with which
286N/Athe Java[tm] Platform, Standard Edition 6 ORB complies, see <
A 286N/Asupport in Java[tm] SE 6</
A>.