gnu.CORBA.CDR

Class Vio

Known Direct Subclasses:
UnknownExceptionCtxHandler

public abstract class Vio
extends Object

A specialised class for reading and writing the value types.

Field Summary

static boolean
USE_CHUNKING
If true, wrap value type data into chunks.
static WStringValueHelper
m_StringValueHelper
The String value helper (one instance is sufficient).
static int
vf_CHUNKING
The value tag flag, indicating the presence of chunking.
static int
vf_CODEBASE
The value tag flag, indicating that the codebase URL is present in the value tag record.
static int
vf_ID
The value tag flag, indicating that a single repository id is present in the value tag record.
static int
vf_MULTIPLE_IDS
The value tag flag, indicating, that there are multiple repository ids present in the record.
static int
vt_INDIRECTION
The indirection tag value.
static int
vt_NULL
This tag value means that the value object being transferred is equal to null.
static int
vt_VALUE_TAG
The first field in the value record.

Method Summary

static BoxedValueHelper
getHelper(Class<T> x, Object ids)
Get the helper that could write the given object, or null if no pre-defined helper available for this object.
static BoxedValueHelper
getHelper(Class<T> x, String id)
Get the helper that could write the given object, or null if no pre-defined helper available for this object.
static Object
instantiateAnyWay(Class<T> clazz)
Instantiate an instance of this class anyway; also in the case when it has no parameterless or any other constructor.
static Serializable
read(InputStream input)
Read the value base from the given input stream.
static Serializable
read(InputStream input, Class<T> value_class)
Read the value base from the given input stream when the value base class is available.
static Object
read(InputStream input, Object value_instance, BoxedValueHelper helper)
Read the value base from the given input stream when the unitialised instance is available.
static Serializable
read(InputStream input, String repository_id)
Read the value base from the given input stream.
static Serializable
read(InputStream input, BoxedValueHelper helper)
Read using provided boxed value helper.
static int
readNestedValue(int value_tag, InputStream input, BufferedCdrOutput output, int level)
Read the chunked nested value from the given input stream, transferring the contents to the given output stream.
static Serializable
readValue(InputStream input, int position, Object value, BoxedValueHelper helper, String id, String[] ids, String codebase)
Read the value (the header must be behind).
static void
write(OutputStream output, Serializable value)
Write the value base into the given stream.
static void
write(OutputStream output, Serializable value, Class<T> substitute)
Write the value base into the given stream, stating that it is an instance of the given class.
static void
write(OutputStream output, Serializable value, String id)
Write value when its repository Id is explicitly given.
static void
write(OutputStream output, Serializable value, String[] multiple_ids)
Write the value base into the given stream, supplementing it with an array of the provided repository ids plus the repository id, derived from the passed value.
static void
write(OutputStream output, Serializable value, BoxedValueHelper helper)
Write standard value type header, followed by contents, produced by the boxed value helper.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

USE_CHUNKING

public static boolean USE_CHUNKING
If true, wrap value type data into chunks. This decrease the performance, and is not required for interoperability with jdk 1.5, but is left in the implementation as the optional mode for solving possible interoperability problems with non-Sun CORBA implementations. The current implementation would accept both single chunk or multiple chunks, but will always send a single chunk (if true) or unchunked data (if false).

m_StringValueHelper

public static final WStringValueHelper m_StringValueHelper
The String value helper (one instance is sufficient).

vf_CHUNKING

public static final int vf_CHUNKING
The value tag flag, indicating the presence of chunking. Each chunk is preceeded by a positive int, indicating the number of bytes in the chunk. A sequence of chunks is terminated by a non positive int.
Field Value:
8

vf_CODEBASE

public static final int vf_CODEBASE
The value tag flag, indicating that the codebase URL is present in the value tag record.
Field Value:
1

vf_ID

public static final int vf_ID
The value tag flag, indicating that a single repository id is present in the value tag record.
Field Value:
2

vf_MULTIPLE_IDS

public static final int vf_MULTIPLE_IDS
The value tag flag, indicating, that there are multiple repository ids present in the record. If this flag is set, the flag vf_ID must also be set, resulting the value of the least significant byte 0x6.
Field Value:
4

vt_INDIRECTION

public static final int vt_INDIRECTION
The indirection tag value. Such tag must be followed by the CORBA long, indicating the offset in the CORBA message, where the indirected information is present. This offset is assumed zero at the position where the mentioned CORBA long starts and can refer both forward (positive values) and backward (negative values).
Field Value:
-1

vt_NULL

public static final int vt_NULL
This tag value means that the value object being transferred is equal to null.
Field Value:
0

vt_VALUE_TAG

public static final int vt_VALUE_TAG
The first field in the value record. The last octet may contain additional flags (vf_CODEBASE, vf_ID and vf_MULTIPLE_IDS). The tag value is different for the indirections (vt_INDIRECTION) and nulls (vt_NULL).
Field Value:
2147483392

Method Details

getHelper

public static BoxedValueHelper getHelper(Class<T> x,
                                         Object ids)
Get the helper that could write the given object, or null if no pre-defined helper available for this object.

getHelper

public static BoxedValueHelper getHelper(Class<T> x,
                                         String id)
Get the helper that could write the given object, or null if no pre-defined helper available for this object.

instantiateAnyWay

public static Object instantiateAnyWay(Class<T> clazz)
            throws Exception
Instantiate an instance of this class anyway; also in the case when it has no parameterless or any other constructor. The fields will be assigned while reading the class from the stream.
Parameters:
clazz - a class for that the instance should be instantiated.

read

public static Serializable read(InputStream input)
Read the value base from the given input stream. Determines the required class from the repository id. This includes operations that are not required when an unitialised instance or at least class of the value type is known. Hence it may be faster to use the alternative methods, read(InputStream, Class) or read(InputStream, Serializable).
Parameters:
input - a stream to read from.
Returns:
the loaded value.
Throws:
MARSHAL - if the reading has failed due any reason.

read

public static Serializable read(InputStream input,
                                Class<T> value_class)
Read the value base from the given input stream when the value base class is available. Hence there is no need to guess it from the repository id.
Parameters:
input - a stream to read from.
value_class - the class of the value being read.
Returns:
the loaded value.
Throws:
MARSHAL - if the reading has failed due any reason.

read

public static Object read(InputStream input,
                          Object value_instance,
                          BoxedValueHelper helper)
Read the value base from the given input stream when the unitialised instance is available. Hence there is no need to guess the class from the repository id and then to instantiate an instance.
Parameters:
input - a stream to read from.
value_instance - an pre-created instance of the value. If the helper is not null, this parameter is ignored an should be null.
helper - a helper to create an instance and read the object- specific part of the record. If the value_instance is used instead, this parameter should be null.
Returns:
the loaded value.
Throws:
MARSHAL - if the reading has failed due any reason.

read

public static Serializable read(InputStream input,
                                String repository_id)
Read the value base from the given input stream. Determines the required class from the repository id. This includes operations that are not required when an unitialised instance or at least class of the value type is known. Hence it may be faster to use the alternative methods, read(InputStream, Class) or read(InputStream, Serializable).
Parameters:
input - a stream to read from.
repository_id - a repository id of the object being read, may be null.
Returns:
the loaded value.
Throws:
MARSHAL - if the reading has failed due any reason.

read

public static Serializable read(InputStream input,
                                BoxedValueHelper helper)
Read using provided boxed value helper. This method expects the full value type header, followed by contents, that are delegated to the provided helper. It handles null.
Parameters:
input - the stream to read from.
helper - the helper that reads the type-specific part of the content.
Returns:
the value, created by the helper, or null if the header indicates that null was previously written.

readNestedValue

public static int readNestedValue(int value_tag,
                                  InputStream input,
                                  BufferedCdrOutput output,
                                  int level)
            throws IOException
Read the chunked nested value from the given input stream, transferring the contents to the given output stream.
Parameters:
value_tag - the value tag of the value being read.
input - the input stream from where the remainder of the nested value must be read.
output - the output stream where the unchunked nested value must be copied.
Returns:
the tag that ended the nested value.

readValue

public static Serializable readValue(InputStream input,
                                     int position,
                                     Object value,
                                     BoxedValueHelper helper,
                                     String id,
                                     String[] ids,
                                     String codebase)
Read the value (the header must be behind).

write

public static void write(OutputStream output,
                         Serializable value)
Write the value base into the given stream.
Parameters:
output - a stream to write to.
value - a value type object, must be either Streamable or CustomMarshal.
Throws:
MARSHAL - if the writing failed due any reason.

write

public static void write(OutputStream output,
                         Serializable value,
                         Class<T> substitute)
Write the value base into the given stream, stating that it is an instance of the given class.
Parameters:
output - a stream to write to.
value - a value to write.
Throws:
MARSHAL - if the writing failed due any reason.

write

public static void write(OutputStream output,
                         Serializable value,
                         String id)
Write value when its repository Id is explicitly given. Only this Id is written, the type of value is not taken into consideration.
Parameters:
output - an output stream to write into.
value - a value to write.
id - a value repository id.

write

public static void write(OutputStream output,
                         Serializable value,
                         String[] multiple_ids)
Write the value base into the given stream, supplementing it with an array of the provided repository ids plus the repository id, derived from the passed value.
Parameters:
output - a stream to write to.
value - a value to write.
Throws:
MARSHAL - if the writing failed due any reason.

write

public static void write(OutputStream output,
                         Serializable value,
                         BoxedValueHelper helper)
Write standard value type header, followed by contents, produced by the boxed value helper.
Parameters:
output - the stream to write to.
value - the value to write, can be null.
helper - the helper that writes the value content if it is not null (must be provided for this method).

Vio.java -- Value type IO operations. Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath 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 for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.