Top Description Fields Constructors Methods
org.jboss.marshalling

public final Class UnmarshallingObjectInputStream

extends ObjectInputStream
Class Inheritance
Imports
java.io.IOException, .ObjectInputValidation, .InputStream, .ObjectInputStream, .ObjectStreamClass

An object input stream which wraps an Unmarshaller, which may be used by legacy ObjectInputStream-based applications that wish to use the marshalling framework.

Field Summary

Modifier and TypeField and Description
private Unmarshaller

Constructor Summary

AccessConstructor and Description
public
UnmarshallingObjectInputStream(final Unmarshaller
the delegate unmarshaller
unmarshaller
,
final InputStream
the input stream to read from
stream
)

Construct a new instance which delegates to the given unmarshaller, reading from the given input.

public
UnmarshallingObjectInputStream(final Unmarshaller
the delegate unmarshaller
unmarshaller
,
final ByteInput
the input stream to read from
byteInput
)

Construct a new instance which delegates to the given unmarshaller, reading from the given input.

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.ObjectInputStream.available.

Implements java.io.ObjectInput.available.

Returns the number of bytes that can be read without blocking.
public void
public void
defaultReadObject()

Overrides java.io.ObjectInputStream.defaultReadObject.

May not be invoked in this context.
protected final boolean
enableResolveObject(final boolean
true for enabling use of resolveObject for every object being deserialized
enable
)

Overrides java.io.ObjectInputStream.enableResolveObject.

Enables the stream to do replacement of objects read from the stream.
public int
read()

Overrides java.io.ObjectInputStream.read.

Implements java.io.ObjectInput.read.

Reads a byte of data.
public int
read(final byte[]
the buffer into which the data is read
b
)

Overrides java.io.InputStream.read.

Implements java.io.ObjectInput.read.

Reads into an array of bytes.
public int
read(final byte[]
the buffer into which the data is read
b
,
final int
the start offset in the destination array buf
off
,
final int
the maximum number of bytes read
len
)

Overrides java.io.ObjectInputStream.read.

Implements java.io.ObjectInput.read.

Reads into an array of bytes.
public boolean
public byte
readByte()

Overrides java.io.ObjectInputStream.readByte.

Implements java.io.DataInput.readByte.

Reads an 8-bit byte.
public char
readChar()

Overrides java.io.ObjectInputStream.readChar.

Implements java.io.DataInput.readChar.

Reads a 16-bit char.
protected final ObjectStreamClass
readClassDescriptor()

Overrides java.io.ObjectInputStream.readClassDescriptor.

Read a class descriptor from the serialization stream.
public double
readDouble()

Overrides java.io.ObjectInputStream.readDouble.

Implements java.io.DataInput.readDouble.

Reads a 64-bit double.
public ObjectInputStream.GetField
readFields()

Overrides java.io.ObjectInputStream.readFields.

May not be invoked in this context.
public float
readFloat()

Overrides java.io.ObjectInputStream.readFloat.

Implements java.io.DataInput.readFloat.

Reads a 32-bit float.
public void
readFully(final byte[]
the buffer into which the data is read
b
)

Overrides java.io.ObjectInputStream.readFully.

Implements java.io.DataInput.readFully.

Reads bytes, blocking until all bytes are read.
public void
readFully(final byte[]
the buffer into which the data is read
b
,
final int
the start offset into the data array buf
off
,
final int
the maximum number of bytes to read
len
)

Overrides java.io.ObjectInputStream.readFully.

Implements java.io.DataInput.readFully.

Reads bytes, blocking until all bytes are read.
public int
readInt()

Overrides java.io.ObjectInputStream.readInt.

Implements java.io.DataInput.readInt.

Reads a 32-bit int.
public String
readLine()

Overrides java.io.ObjectInputStream.readLine.

Implements java.io.DataInput.readLine.

Deprecated
Reads in a line that has been terminated by a \n, \r, \r\n or EOF.
public long
readLong()

Overrides java.io.ObjectInputStream.readLong.

Implements java.io.DataInput.readLong.

Reads a 64-bit long.
protected Object
readObjectOverride()

Overrides java.io.ObjectInputStream.readObjectOverride.

This method is called by trusted subclasses of ObjectInputStream that constructed ObjectInputStream using the protected no-arg constructor.
public Object
public short
readShort()

Overrides java.io.ObjectInputStream.readShort.

Implements java.io.DataInput.readShort.

Reads a 16-bit short.
protected final void
readStreamHeader()

Overrides java.io.ObjectInputStream.readStreamHeader.

The readStreamHeader method is provided to allow subclasses to read and verify their own stream headers.
public Object
readUnshared()

Overrides java.io.ObjectInputStream.readUnshared.

Reads an "unshared" object from the ObjectInputStream.
public int
public int
public String
readUTF()

Overrides java.io.ObjectInputStream.readUTF.

Implements java.io.DataInput.readUTF.

Reads a String in modified UTF-8 format.
public void
registerValidation(final ObjectInputValidation
ignored
obj
,
final int
ignored
prio
)

Overrides java.io.ObjectInputStream.registerValidation.

May not be invoked in this context.
protected final Class<?>
resolveClass(final ObjectStreamClass
an instance of class ObjectStreamClass
desc
)

Overrides java.io.ObjectInputStream.resolveClass.

Load the local class equivalent of the specified stream class description.
protected final Object
resolveObject(final Object
object to be substituted
obj
)

Overrides java.io.ObjectInputStream.resolveObject.

This method will allow trusted subclasses of ObjectInputStream to substitute one object for another during deserialization.
protected final Class<?>
resolveProxyClass(final String[]
the list of interface names that were deserialized in the proxy class descriptor
interfaces
)

Overrides java.io.ObjectInputStream.resolveProxyClass.

Returns a proxy class that implements the interfaces named in a proxy class descriptor; subclasses may implement this method to read custom data from the stream along with the descriptors for dynamic proxy classes, allowing them to use an alternate loading mechanism for the interfaces and the proxy class.
public long
skip(final long
the number of bytes to be skipped
n
)

Overrides java.io.InputStream.skip.

Implements java.io.ObjectInput.skip.

Skips n bytes of input.
public int
skipBytes(final int
the number of bytes to be skipped
n
)

Overrides java.io.ObjectInputStream.skipBytes.

Implements java.io.DataInput.skipBytes.

Skips bytes.
Inherited from java.io.ObjectInputStream:
getObjectInputFilterreadObjectsetObjectInputFilter

Field Detail

unmarshallerback to summary
private Unmarshaller unmarshaller

Constructor Detail

UnmarshallingObjectInputStreamback to summary
public UnmarshallingObjectInputStream(final Unmarshaller unmarshaller, final InputStream stream) throws IOException, SecurityException

Construct a new instance which delegates to the given unmarshaller, reading from the given input. The unmarshaller will read from the input stream until it is closed.

Parameters
unmarshaller:Unmarshaller

the delegate unmarshaller

stream:InputStream

the input stream to read from

Exceptions
IOException:
if an I/O error occurs
SecurityException:
if the caller does not have permission to construct an instance of this class
UnmarshallingObjectInputStreamback to summary
public UnmarshallingObjectInputStream(final Unmarshaller unmarshaller, final ByteInput byteInput) throws IOException, SecurityException

Construct a new instance which delegates to the given unmarshaller, reading from the given input. The unmarshaller will read from the input stream until it is closed.

Parameters
unmarshaller:Unmarshaller

the delegate unmarshaller

byteInput:ByteInput

the input stream to read from

Exceptions
IOException:
if an I/O error occurs
SecurityException:
if the caller does not have permission to construct an instance of this class

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.ObjectInputStream.available.

Implements java.io.ObjectInput.available.

Doc from java.io.ObjectInputStream.available.

Returns the number of bytes that can be read without blocking.

Returns:int

the number of available bytes.

Exceptions
IOException:
if there are I/O errors while reading from the underlying InputStream
closeback to summary
public void close() throws IOException, IllegalStateException

Overrides java.io.ObjectInputStream.close.

Implements java.io.ObjectInput.close, java.io.Closeable.close.

Doc from java.io.ObjectInputStream.close.

Closes the input stream. Must be called to release any resources associated with the stream.

Exceptions
IOException:
If an I/O error has occurred.
defaultReadObjectback to summary
public void defaultReadObject() throws IllegalStateException

Overrides java.io.ObjectInputStream.defaultReadObject.

May not be invoked in this context.

Exceptions
IllegalStateException:
always
enableResolveObjectback to summary
protected final boolean enableResolveObject(final boolean enable) throws IllegalStateException

Overrides java.io.ObjectInputStream.enableResolveObject.

Doc from java.io.ObjectInputStream.enableResolveObject.

Enables the stream to do replacement of objects read from the stream. When enabled, the resolveObject method is called for every object being deserialized.

If object replacement is currently not enabled, and enable is true, and there is a security manager installed, this method first calls the security manager's checkPermission method with the SerializablePermission("enableSubstitution") permission to ensure that the caller is permitted to enable the stream to do replacement of objects read from the stream.

Parameters
enable:boolean

true for enabling use of resolveObject for every object being deserialized

Returns:boolean

the previous setting before this method was invoked

readback to summary
public int read() throws IOException

Overrides java.io.ObjectInputStream.read.

Implements java.io.ObjectInput.read.

Doc from java.io.ObjectInputStream.read.

Reads a byte of data. This method will block if no input is available.

Returns:int

the byte read, or -1 if the end of the stream is reached.

Exceptions
IOException:
If an I/O error has occurred.
readback to summary
public int read(final byte[] b) throws IOException

Overrides java.io.InputStream.read.

Implements java.io.ObjectInput.read.

Doc from java.io.ObjectInput.read.

Reads into an array of bytes. This method will block until some input is available.

Parameters
b:byte[]

the buffer into which the data is read

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Exceptions
IOException:
If an I/O error has occurred.
readback to summary
public int read(final byte[] b, final int off, final int len) throws IOException

Overrides java.io.ObjectInputStream.read.

Implements java.io.ObjectInput.read.

Doc from java.io.ObjectInputStream.read.

Reads into an array of bytes. This method will block until some input is available. Consider using java.io.DataInputStream.readFully to read exactly 'length' bytes.

Parameters
b:byte[]

the buffer into which the data is read

off:int

the start offset in the destination array buf

len:int

the maximum number of bytes read

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Exceptions
IOException:
If an I/O error has occurred.
readBooleanback to summary
public boolean readBoolean() throws IOException

Overrides java.io.ObjectInputStream.readBoolean.

Implements java.io.DataInput.readBoolean.

Doc from java.io.ObjectInputStream.readBoolean.

Reads in a boolean.

Returns:boolean

the boolean read.

Exceptions
IOException:
If other I/O error has occurred.
readByteback to summary
public byte readByte() throws IOException

Overrides java.io.ObjectInputStream.readByte.

Implements java.io.DataInput.readByte.

Doc from java.io.ObjectInputStream.readByte.

Reads an 8-bit byte.

Returns:byte

the 8-bit byte read.

Exceptions
IOException:
If other I/O error has occurred.
readCharback to summary
public char readChar() throws IOException

Overrides java.io.ObjectInputStream.readChar.

Implements java.io.DataInput.readChar.

Doc from java.io.ObjectInputStream.readChar.

Reads a 16-bit char.

Returns:char

the 16-bit char read.

Exceptions
IOException:
If other I/O error has occurred.
readClassDescriptorback to summary
protected final ObjectStreamClass readClassDescriptor() throws IllegalStateException

Overrides java.io.ObjectInputStream.readClassDescriptor.

Doc from java.io.ObjectInputStream.readClassDescriptor.

Read a class descriptor from the serialization stream. This method is called when the ObjectInputStream expects a class descriptor as the next item in the serialization stream. Subclasses of ObjectInputStream may override this method to read in class descriptors that have been written in non-standard formats (by subclasses of ObjectOutputStream which have overridden the writeClassDescriptor method). By default, this method reads class descriptors according to the format defined in the Object Serialization specification.

Returns:ObjectStreamClass

the class descriptor read

readDoubleback to summary
public double readDouble() throws IOException

Overrides java.io.ObjectInputStream.readDouble.

Implements java.io.DataInput.readDouble.

Doc from java.io.ObjectInputStream.readDouble.

Reads a 64-bit double.

Returns:double

the 64-bit double read.

Exceptions
IOException:
If other I/O error has occurred.
readFieldsback to summary
public ObjectInputStream.GetField readFields() throws IllegalStateException

Overrides java.io.ObjectInputStream.readFields.

May not be invoked in this context.

Returns:ObjectInputStream.GetField

Doc from java.io.ObjectInputStream.readFields.

the GetField object representing the persistent fields of the object being deserialized

Exceptions
IllegalStateException:
always
readFloatback to summary
public float readFloat() throws IOException

Overrides java.io.ObjectInputStream.readFloat.

Implements java.io.DataInput.readFloat.

Doc from java.io.ObjectInputStream.readFloat.

Reads a 32-bit float.

Returns:float

the 32-bit float read.

Exceptions
IOException:
If other I/O error has occurred.
readFullyback to summary
public void readFully(final byte[] b) throws IOException

Overrides java.io.ObjectInputStream.readFully.

Implements java.io.DataInput.readFully.

Doc from java.io.ObjectInputStream.readFully.

Reads bytes, blocking until all bytes are read.

Parameters
b:byte[]

the buffer into which the data is read

Exceptions
IOException:
If other I/O error has occurred.
readFullyback to summary
public void readFully(final byte[] b, final int off, final int len) throws IOException

Overrides java.io.ObjectInputStream.readFully.

Implements java.io.DataInput.readFully.

Doc from java.io.ObjectInputStream.readFully.

Reads bytes, blocking until all bytes are read.

Parameters
b:byte[]

the buffer into which the data is read

off:int

the start offset into the data array buf

len:int

the maximum number of bytes to read

Exceptions
IOException:
If other I/O error has occurred.
readIntback to summary
public int readInt() throws IOException

Overrides java.io.ObjectInputStream.readInt.

Implements java.io.DataInput.readInt.

Doc from java.io.ObjectInputStream.readInt.

Reads a 32-bit int.

Returns:int

the 32-bit integer read.

Exceptions
IOException:
If other I/O error has occurred.
readLineback to summary
public String readLine() throws IOException

Overrides java.io.ObjectInputStream.readLine.

Implements java.io.DataInput.readLine.

Doc from java.io.ObjectInputStream.readLine.

Deprecated

Reads in a line that has been terminated by a \n, \r, \r\n or EOF.

Returns:String

a String copy of the line.

Annotations
@Deprecated
Exceptions
IOException:
if there are I/O errors while reading from the underlying InputStream
readLongback to summary
public long readLong() throws IOException

Overrides java.io.ObjectInputStream.readLong.

Implements java.io.DataInput.readLong.

Doc from java.io.ObjectInputStream.readLong.

Reads a 64-bit long.

Returns:long

the read 64-bit long.

Exceptions
IOException:
If other I/O error has occurred.
readObjectOverrideback to summary
protected Object readObjectOverride() throws ClassNotFoundException, IOException

Overrides java.io.ObjectInputStream.readObjectOverride.

Doc from java.io.ObjectInputStream.readObjectOverride.

This method is called by trusted subclasses of ObjectInputStream that constructed ObjectInputStream using the protected no-arg constructor. The subclass is expected to provide an override method with the modifier "final".

Returns:Object

the Object read from the stream.

Exceptions
ClassNotFoundException:
Class definition of a serialized object cannot be found.
IOException:
if I/O errors occurred while reading from the underlying stream
readObjectUnsharedback to summary
public Object readObjectUnshared() throws ClassNotFoundException, IOException
readShortback to summary
public short readShort() throws IOException

Overrides java.io.ObjectInputStream.readShort.

Implements java.io.DataInput.readShort.

Doc from java.io.ObjectInputStream.readShort.

Reads a 16-bit short.

Returns:short

the 16-bit short read.

Exceptions
IOException:
If other I/O error has occurred.
readStreamHeaderback to summary
protected final void readStreamHeader() throws IllegalStateException

Overrides java.io.ObjectInputStream.readStreamHeader.

Doc from java.io.ObjectInputStream.readStreamHeader.

The readStreamHeader method is provided to allow subclasses to read and verify their own stream headers. It reads and verifies the magic number and version number.

readUnsharedback to summary
public Object readUnshared() throws IOException, ClassNotFoundException

Overrides java.io.ObjectInputStream.readUnshared.

Doc from java.io.ObjectInputStream.readUnshared.

Reads an "unshared" object from the ObjectInputStream. This method is identical to readObject, except that it prevents subsequent calls to readObject and readUnshared from returning additional references to the deserialized instance obtained via this call. Specifically:

  • If readUnshared is called to deserialize a back-reference (the stream representation of an object which has been written previously to the stream), an ObjectStreamException will be thrown.
  • If readUnshared returns successfully, then any subsequent attempts to deserialize back-references to the stream handle deserialized by readUnshared will cause an ObjectStreamException to be thrown.
Deserializing an object via readUnshared invalidates the stream handle associated with the returned object. Note that this in itself does not always guarantee that the reference returned by readUnshared is unique; the deserialized object may define a readResolve method which returns an object visible to other parties, or readUnshared may return a Class object or enum constant obtainable elsewhere in the stream or through external means. If the deserialized object defines a readResolve method and the invocation of that method returns an array, then readUnshared returns a shallow clone of that array; this guarantees that the returned array object is unique and cannot be obtained a second time from an invocation of readObject or readUnshared on the ObjectInputStream, even if the underlying data stream has been manipulated.

The deserialization filter, when not null, is invoked for each object (regular or class) read to reconstruct the root object. See setObjectInputFilter for details.

ObjectInputStream subclasses which override this method can only be constructed in security contexts possessing the "enableSubclassImplementation" SerializablePermission; any attempt to instantiate such a subclass without this permission will cause a SecurityException to be thrown.

Returns:Object

reference to deserialized object

Exceptions
IOException:
if an I/O error occurs during deserialization
ClassNotFoundException:
if class of an object to deserialize cannot be found
readUnsignedByteback to summary
public int readUnsignedByte() throws IOException

Overrides java.io.ObjectInputStream.readUnsignedByte.

Implements java.io.DataInput.readUnsignedByte.

Doc from java.io.ObjectInputStream.readUnsignedByte.

Reads an unsigned 8-bit byte.

Returns:int

the 8-bit byte read.

Exceptions
IOException:
If other I/O error has occurred.
readUnsignedShortback to summary
public int readUnsignedShort() throws IOException

Overrides java.io.ObjectInputStream.readUnsignedShort.

Implements java.io.DataInput.readUnsignedShort.

Doc from java.io.ObjectInputStream.readUnsignedShort.

Reads an unsigned 16-bit short.

Returns:int

the 16-bit short read.

Exceptions
IOException:
If other I/O error has occurred.
readUTFback to summary
public String readUTF() throws IOException

Overrides java.io.ObjectInputStream.readUTF.

Implements java.io.DataInput.readUTF.

Doc from java.io.ObjectInputStream.readUTF.

Reads a String in modified UTF-8 format.

Returns:String

the String.

Exceptions
IOException:
if there are I/O errors while reading from the underlying InputStream
registerValidationback to summary
public void registerValidation(final ObjectInputValidation obj, final int prio) throws IllegalStateException

Overrides java.io.ObjectInputStream.registerValidation.

May not be invoked in this context.

Parameters
obj:ObjectInputValidation

ignored

prio:int

ignored

Exceptions
IllegalStateException:
always
resolveClassback to summary
protected final Class<?> resolveClass(final ObjectStreamClass desc) throws IllegalStateException

Overrides java.io.ObjectInputStream.resolveClass.

Doc from java.io.ObjectInputStream.resolveClass.

Load the local class equivalent of the specified stream class description. Subclasses may implement this method to allow classes to be fetched from an alternate source.

The corresponding method in ObjectOutputStream is annotateClass. This method will be invoked only once for each unique class in the stream. This method can be implemented by subclasses to use an alternate loading mechanism but must return a Class object. Once returned, if the class is not an array class, its serialVersionUID is compared to the serialVersionUID of the serialized class, and if there is a mismatch, the deserialization fails and an InvalidClassException is thrown.

The default implementation of this method in ObjectInputStream returns the result of calling

Class.forName(desc.getName(), false, loader)
Class.forName(desc.getName(), false, loader)
where loader is the first class loader on the current thread's stack (starting from the currently executing method) that is neither the platform class loader nor its ancestor; otherwise, loader is the platform class loader. If this call results in a ClassNotFoundException and the name of the passed ObjectStreamClass instance is the Java language keyword for a primitive type or void, then the Class object representing that primitive type or void will be returned (e.g., an ObjectStreamClass with the name "int" will be resolved to Integer.TYPE). Otherwise, the ClassNotFoundException will be thrown to the caller of this method.
Parameters
desc:ObjectStreamClass

an instance of class ObjectStreamClass

Returns:Class<?>

a Class object corresponding to desc

resolveObjectback to summary
protected final Object resolveObject(final Object obj) throws IllegalStateException

Overrides java.io.ObjectInputStream.resolveObject.

Doc from java.io.ObjectInputStream.resolveObject.

This method will allow trusted subclasses of ObjectInputStream to substitute one object for another during deserialization. Replacing objects is disabled until enableResolveObject is called. The enableResolveObject method checks that the stream requesting to resolve object can be trusted. Every reference to serializable objects is passed to resolveObject. To ensure that the private state of objects is not unintentionally exposed only trusted streams may use resolveObject.

This method is called after an object has been read but before it is returned from readObject. The default resolveObject method just returns the same object.

When a subclass is replacing objects it must ensure that the substituted object is compatible with every field where the reference will be stored. Objects whose type is not a subclass of the type of the field or array element abort the deserialization by raising an exception and the object is not be stored.

This method is called only once when each object is first encountered. All subsequent references to the object will be redirected to the new object.

Parameters
obj:Object

object to be substituted

Returns:Object

the substituted object

resolveProxyClassback to summary
protected final Class<?> resolveProxyClass(final String[] interfaces) throws IllegalStateException

Overrides java.io.ObjectInputStream.resolveProxyClass.

Doc from java.io.ObjectInputStream.resolveProxyClass.

Returns a proxy class that implements the interfaces named in a proxy class descriptor; subclasses may implement this method to read custom data from the stream along with the descriptors for dynamic proxy classes, allowing them to use an alternate loading mechanism for the interfaces and the proxy class.

This method is called exactly once for each unique proxy class descriptor in the stream.

The corresponding method in ObjectOutputStream is annotateProxyClass. For a given subclass of ObjectInputStream that overrides this method, the annotateProxyClass method in the corresponding subclass of ObjectOutputStream must write any data or objects read by this method.

The default implementation of this method in ObjectInputStream returns the result of calling Proxy.getProxyClass with the list of Class objects for the interfaces that are named in the interfaces parameter. The Class object for each interface name i is the value returned by calling

Class.forName(i, false, loader)
Class.forName(i, false, loader)
where loader is the first class loader on the current thread's stack (starting from the currently executing method) that is neither the platform class loader nor its ancestor; otherwise, loader is the platform class loader. Unless any of the resolved interfaces are non-public, this same value of loader is also the class loader passed to Proxy.getProxyClass; if non-public interfaces are present, their class loader is passed instead (if more than one non-public interface class loader is encountered, an IllegalAccessError is thrown). If Proxy.getProxyClass throws an IllegalArgumentException, resolveProxyClass will throw a ClassNotFoundException containing the IllegalArgumentException.
Parameters
interfaces:String[]

the list of interface names that were deserialized in the proxy class descriptor

Returns:Class<?>

a proxy class for the specified interfaces

skipback to summary
public long skip(final long n) throws IOException

Overrides java.io.InputStream.skip.

Implements java.io.ObjectInput.skip.

Doc from java.io.ObjectInput.skip.

Skips n bytes of input.

Parameters
n:long

the number of bytes to be skipped

Returns:long

the actual number of bytes skipped.

Exceptions
IOException:
If an I/O error has occurred.
skipBytesback to summary
public int skipBytes(final int n) throws IOException

Overrides java.io.ObjectInputStream.skipBytes.

Implements java.io.DataInput.skipBytes.

Doc from java.io.ObjectInputStream.skipBytes.

Skips bytes.

Parameters
n:int

the number of bytes to be skipped

Returns:int

the actual number of bytes skipped.

Exceptions
IOException:
If an I/O error has occurred.