JBoss Marshalling 1.2.1.GA

org.jboss.marshalling
Class AbstractUnmarshaller

java.lang.Object
  extended by org.jboss.marshalling.AbstractUnmarshaller
All Implemented Interfaces:
Closeable, DataInput, ObjectInput, ByteInput, Unmarshaller

public abstract class AbstractUnmarshaller
extends Object
implements Unmarshaller

An abstract implementation of the Unmarshaller interface. Most of the write methods delegate directly to the current data output.


Field Summary
protected  ByteInput byteInput
          The current byte input.
protected  ClassExternalizerFactory classExternalizerFactory
          The configured class externalizer factory.
protected  ClassResolver classResolver
          The configured class resolver.
protected  ClassTable classTable
          The configured class table.
protected  int configuredVersion
          The configured version.
protected  Creator creator
          The configured object creator.
protected  ExceptionListener exceptionListener
          The configured exception listener.
protected  ObjectResolver objectResolver
          The configured object resolver.
protected  ObjectTable objectTable
          The configured object table.
protected  StreamHeader streamHeader
          The configured stream header.
 
Constructor Summary
protected AbstractUnmarshaller(AbstractMarshallerFactory marshallerFactory, MarshallingConfiguration configuration)
          Construct a new unmarshaller instance.
 
Method Summary
 int available()
          Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.
protected abstract  Object doReadObject(boolean unshared)
          Implementation of the actual object-reading method.
protected  void doStart()
          Perform any unmarshaller-specific start activity.
 void finish()
          Finish unmarshalling from a stream.
 int read()
          Reads the next byte of data from the input stream.
 int read(byte[] b)
          Read some bytes from the input stream into the given array.
 int read(byte[] b, int off, int len)
          Read some bytes from the input stream into the given array.
 boolean readBoolean()
          
 byte readByte()
          
 char readChar()
          
 double readDouble()
          
 float readFloat()
          
 void readFully(byte[] b)
          
 void readFully(byte[] b, int off, int len)
          
 int readInt()
          
protected  int readIntDirect()
           
 String readLine()
          
 long readLong()
           
protected  long readLongDirect()
          
 Object readObject()
          
 Object readObjectUnshared()
          Read and return an unshared object.
 short readShort()
          
 int readUnsignedByte()
          
protected  int readUnsignedByteDirect()
           
 int readUnsignedShort()
          
 String readUTF()
          
 long skip(long n)
          Skips over and discards up to n bytes of data from this input stream.
 int skipBytes(int n)
          
 void start(ByteInput byteInput)
          Begin unmarshalling from a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.marshalling.Unmarshaller
clearClassCache, clearInstanceCache
 
Methods inherited from interface java.io.ObjectInput
close
 
Methods inherited from interface java.io.Closeable
close
 

Field Detail

classExternalizerFactory

protected final ClassExternalizerFactory classExternalizerFactory
The configured class externalizer factory.


streamHeader

protected final StreamHeader streamHeader
The configured stream header.


classResolver

protected final ClassResolver classResolver
The configured class resolver.


objectResolver

protected final ObjectResolver objectResolver
The configured object resolver.


creator

protected final Creator creator
The configured object creator.


classTable

protected final ClassTable classTable
The configured class table.


objectTable

protected final ObjectTable objectTable
The configured object table.


exceptionListener

protected final ExceptionListener exceptionListener
The configured exception listener.


configuredVersion

protected final int configuredVersion
The configured version.


byteInput

protected ByteInput byteInput
The current byte input.

Constructor Detail

AbstractUnmarshaller

protected AbstractUnmarshaller(AbstractMarshallerFactory marshallerFactory,
                               MarshallingConfiguration configuration)
Construct a new unmarshaller instance.

Parameters:
marshallerFactory - the marshaller factory
configuration -
Method Detail

readObject

public final Object readObject()
                        throws ClassNotFoundException,
                               IOException

Specified by:
readObject in interface ObjectInput
Throws:
ClassNotFoundException
IOException

readObjectUnshared

public final Object readObjectUnshared()
                                throws ClassNotFoundException,
                                       IOException
Read and return an unshared object.

Specified by:
readObjectUnshared in interface Unmarshaller
Returns:
an unshared object
Throws:
IOException - if an error occurs
ClassNotFoundException

doReadObject

protected abstract Object doReadObject(boolean unshared)
                                throws ClassNotFoundException,
                                       IOException
Implementation of the actual object-reading method.

Parameters:
unshared - true if the instance should be unshared, false if it is shared
Returns:
the object to read
Throws:
ClassNotFoundException - if the class for the object could not be loaded
IOException - if an I/O error occurs

read

public int read()
         throws IOException
Reads the next byte of data from the input stream. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Specified by:
read in interface ObjectInput
Specified by:
read in interface ByteInput
Returns:
the next byte, or -1 if the end of stream has been reached
Throws:
IOException - if an error occurs

read

public int read(byte[] b)
         throws IOException
Read some bytes from the input stream into the given array. Returns the number of bytes actually read (possibly zero), or -1 if the end of stream has been reached.

Specified by:
read in interface ObjectInput
Specified by:
read in interface ByteInput
Parameters:
b - the destination array
Returns:
the number of bytes read (possibly zero), or -1 if the end of stream has been reached
Throws:
IOException - if an error occurs

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Read some bytes from the input stream into the given array. Returns the number of bytes actually read (possibly zero), or -1 if the end of stream has been reached.

Specified by:
read in interface ObjectInput
Specified by:
read in interface ByteInput
Parameters:
b - the destination array
off - the offset into the array into which data should be read
len - the number of bytes to attempt to fill in the destination array
Returns:
the number of bytes read (possibly zero), or -1 if the end of stream has been reached
Throws:
IOException - if an error occurs

skip

public long skip(long n)
          throws IOException
Skips over and discards up to n bytes of data from this input stream. If the end of stream is reached, this method returns 0 in order to be consistent with InputStream.skip(long).

Specified by:
skip in interface ObjectInput
Specified by:
skip in interface ByteInput
Parameters:
n - the number of bytes to attempt to skip
Returns:
the number of bytes skipped
Throws:
IOException - if an error occurs

available

public int available()
              throws IOException
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.

Specified by:
available in interface ObjectInput
Specified by:
available in interface ByteInput
Returns:
the number of bytes
Throws:
IOException - if an error occurs

readFully

public void readFully(byte[] b)
               throws IOException

Specified by:
readFully in interface DataInput
Throws:
IOException

readFully

public void readFully(byte[] b,
                      int off,
                      int len)
               throws IOException

Specified by:
readFully in interface DataInput
Throws:
IOException

skipBytes

public int skipBytes(int n)
              throws IOException

Specified by:
skipBytes in interface DataInput
Throws:
IOException

readBoolean

public boolean readBoolean()
                    throws IOException

Specified by:
readBoolean in interface DataInput
Throws:
IOException

readByte

public byte readByte()
              throws IOException

Specified by:
readByte in interface DataInput
Throws:
IOException

readUnsignedByte

public int readUnsignedByte()
                     throws IOException

Specified by:
readUnsignedByte in interface DataInput
Throws:
IOException

readShort

public short readShort()
                throws IOException

Specified by:
readShort in interface DataInput
Throws:
IOException

readUnsignedShort

public int readUnsignedShort()
                      throws IOException

Specified by:
readUnsignedShort in interface DataInput
Throws:
IOException

readUnsignedByteDirect

protected int readUnsignedByteDirect()
                              throws IOException
Throws:
IOException

readChar

public char readChar()
              throws IOException

Specified by:
readChar in interface DataInput
Throws:
IOException

readInt

public int readInt()
            throws IOException

Specified by:
readInt in interface DataInput
Throws:
IOException

readLong

public long readLong()
              throws IOException
Specified by:
readLong in interface DataInput
Throws:
IOException

readLongDirect

protected long readLongDirect()
                       throws IOException

Throws:
IOException

readFloat

public float readFloat()
                throws IOException

Specified by:
readFloat in interface DataInput
Throws:
IOException

readIntDirect

protected int readIntDirect()
                     throws IOException
Throws:
IOException

readDouble

public double readDouble()
                  throws IOException

Specified by:
readDouble in interface DataInput
Throws:
IOException

readLine

public String readLine()
                throws IOException

Specified by:
readLine in interface DataInput
Throws:
IOException

readUTF

public String readUTF()
               throws IOException

Specified by:
readUTF in interface DataInput
Throws:
IOException

start

public void start(ByteInput byteInput)
           throws IOException
Begin unmarshalling from a stream.

Specified by:
start in interface Unmarshaller
Parameters:
byteInput - the new stream
Throws:
IOException - if an error occurs during setup, such as an invalid header

finish

public void finish()
            throws IOException
Finish unmarshalling from a stream. Any transient class or instance cache is discarded.

Specified by:
finish in interface Unmarshaller
Throws:
IOException - if an error occurs

doStart

protected void doStart()
                throws IOException
Perform any unmarshaller-specific start activity. This implementation simply reads the stream header.

Throws:
IOException - if I/O exception occurs

JBoss Marshalling 1.2.1.GA

Copyright © 2010 JBoss, a division of Red Hat, Inc.