org.jboss.marshalling.serialization.java
Class JavaSerializationUnmarshaller

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

public class JavaSerializationUnmarshaller
extends AbstractUnmarshaller

Version:
$Revision: 1.1 $

Copyright Sep 19, 2008

Author:
Ron Sigal

Field Summary
 
Fields inherited from class org.jboss.marshalling.AbstractUnmarshaller
byteInput, classExternalizerFactory, classResolver, classTable, configuredVersion, creator, externalizerFactory, objectResolver, objectTable, streamHeader
 
Constructor Summary
protected JavaSerializationUnmarshaller(AbstractMarshallerFactory marshallerFactory, MarshallingConfiguration configuration)
           
 
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.
 void clearClassCache()
          Discard the class cache.
 void clearInstanceCache()
          Discard the instance cache.
 void close()
           
protected  java.lang.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.
 java.io.InputStream getInputStream()
           
 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()
          
 java.lang.String readLine()
          Deprecated. 
 long readLong()
          
 short readShort()
          
 int readUnsignedByte()
          
 int readUnsignedShort()
          
 java.lang.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 org.jboss.marshalling.AbstractUnmarshaller
readIntDirect, readLongDirect, readObject, readObjectUnshared, readUnsignedByteDirect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaSerializationUnmarshaller

protected JavaSerializationUnmarshaller(AbstractMarshallerFactory marshallerFactory,
                                        MarshallingConfiguration configuration)
                                 throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getInputStream

public java.io.InputStream getInputStream()

clearClassCache

public void clearClassCache()
                     throws java.io.IOException
Description copied from interface: Unmarshaller
Discard the class cache. Implicitly also discards the instance cache.

Throws:
java.io.IOException - if an error occurs

clearInstanceCache

public void clearInstanceCache()
                        throws java.io.IOException
Description copied from interface: Unmarshaller
Discard the instance cache.

Throws:
java.io.IOException - if an error occurs

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

finish

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

Specified by:
finish in interface Unmarshaller
Overrides:
finish in class AbstractUnmarshaller
Throws:
java.io.IOException - if an error occurs

start

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

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

read

public int read()
         throws java.io.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 java.io.ObjectInput
Specified by:
read in interface ByteInput
Overrides:
read in class AbstractUnmarshaller
Returns:
the next byte, or -1 if the end of stream has been reached
Throws:
java.io.IOException - if an error occurs

read

public int read(byte[] b)
         throws java.io.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 java.io.ObjectInput
Specified by:
read in interface ByteInput
Overrides:
read in class AbstractUnmarshaller
Parameters:
b - the destination array
Returns:
the number of bytes read (possibly zero), or -1 if the end of stream has been reached
Throws:
java.io.IOException - if an error occurs

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.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 java.io.ObjectInput
Specified by:
read in interface ByteInput
Overrides:
read in class AbstractUnmarshaller
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:
java.io.IOException - if an error occurs

skip

public long skip(long n)
          throws java.io.IOException
Skips over and discards up to n bytes of data from this input stream.

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

available

public int available()
              throws java.io.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 java.io.ObjectInput
Specified by:
available in interface ByteInput
Overrides:
available in class AbstractUnmarshaller
Returns:
the number of bytes
Throws:
java.io.IOException - if an error occurs

readFully

public void readFully(byte[] b)
               throws java.io.IOException

Specified by:
readFully in interface java.io.DataInput
Overrides:
readFully in class AbstractUnmarshaller
Throws:
java.io.IOException

readFully

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

Specified by:
readFully in interface java.io.DataInput
Overrides:
readFully in class AbstractUnmarshaller
Throws:
java.io.IOException

skipBytes

public int skipBytes(int n)
              throws java.io.IOException

Specified by:
skipBytes in interface java.io.DataInput
Overrides:
skipBytes in class AbstractUnmarshaller
Throws:
java.io.IOException

readBoolean

public boolean readBoolean()
                    throws java.io.IOException

Specified by:
readBoolean in interface java.io.DataInput
Overrides:
readBoolean in class AbstractUnmarshaller
Throws:
java.io.IOException

readByte

public byte readByte()
              throws java.io.IOException

Specified by:
readByte in interface java.io.DataInput
Overrides:
readByte in class AbstractUnmarshaller
Throws:
java.io.IOException

readUnsignedByte

public int readUnsignedByte()
                     throws java.io.IOException

Specified by:
readUnsignedByte in interface java.io.DataInput
Overrides:
readUnsignedByte in class AbstractUnmarshaller
Throws:
java.io.IOException

readShort

public short readShort()
                throws java.io.IOException

Specified by:
readShort in interface java.io.DataInput
Overrides:
readShort in class AbstractUnmarshaller
Throws:
java.io.IOException

readUnsignedShort

public int readUnsignedShort()
                      throws java.io.IOException

Specified by:
readUnsignedShort in interface java.io.DataInput
Overrides:
readUnsignedShort in class AbstractUnmarshaller
Throws:
java.io.IOException

readChar

public char readChar()
              throws java.io.IOException

Specified by:
readChar in interface java.io.DataInput
Overrides:
readChar in class AbstractUnmarshaller
Throws:
java.io.IOException

readInt

public int readInt()
            throws java.io.IOException

Specified by:
readInt in interface java.io.DataInput
Overrides:
readInt in class AbstractUnmarshaller
Throws:
java.io.IOException

readLong

public long readLong()
              throws java.io.IOException

Specified by:
readLong in interface java.io.DataInput
Overrides:
readLong in class AbstractUnmarshaller
Throws:
java.io.IOException

readFloat

public float readFloat()
                throws java.io.IOException

Specified by:
readFloat in interface java.io.DataInput
Overrides:
readFloat in class AbstractUnmarshaller
Throws:
java.io.IOException

readDouble

public double readDouble()
                  throws java.io.IOException

Specified by:
readDouble in interface java.io.DataInput
Overrides:
readDouble in class AbstractUnmarshaller
Throws:
java.io.IOException

readLine

@Deprecated
public java.lang.String readLine()
                          throws java.io.IOException
Deprecated. 

Specified by:
readLine in interface java.io.DataInput
Overrides:
readLine in class AbstractUnmarshaller
Throws:
java.io.IOException

readUTF

public java.lang.String readUTF()
                         throws java.io.IOException

Specified by:
readUTF in interface java.io.DataInput
Overrides:
readUTF in class AbstractUnmarshaller
Throws:
java.io.IOException

doReadObject

protected java.lang.Object doReadObject(boolean unshared)
                                 throws java.lang.ClassNotFoundException,
                                        java.io.IOException
Description copied from class: AbstractUnmarshaller
Implementation of the actual object-reading method.

Specified by:
doReadObject in class AbstractUnmarshaller
Parameters:
unshared - true if the instance should be unshared, false if it is shared
Returns:
the object to read
Throws:
java.lang.ClassNotFoundException - if the class for the object could not be loaded
java.io.IOException - if an I/O error occurs

doStart

protected void doStart()
                throws java.io.IOException
Description copied from class: AbstractUnmarshaller
Perform any unmarshaller-specific start activity. This implementation simply reads the stream header.

Overrides:
doStart in class AbstractUnmarshaller
Throws:
java.io.IOException - if I/O exception occurs