Package org.jboss.marshalling.serial
Class BlockUnmarshaller
- java.lang.Object
-
- org.jboss.marshalling.serial.BlockUnmarshaller
-
- All Implemented Interfaces:
Closeable
,DataInput
,ObjectInput
,ObjectStreamConstants
,AutoCloseable
,ByteInput
,ExtendedObjectStreamConstants
,Unmarshaller
public final class BlockUnmarshaller extends Object implements Unmarshaller, ExtendedObjectStreamConstants
-
-
Field Summary
-
Fields inherited from interface org.jboss.marshalling.serial.ExtendedObjectStreamConstants
TC_CLASSTABLEDESC, TC_OBJECTTABLE
-
Fields inherited from interface java.io.ObjectStreamConstants
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, SERIAL_FILTER_PERMISSION, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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()
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()
String
readLine()
long
readLong()
Object
readObject()
<T> T
readObject(Class<T> type)
Read and return an object, cast to a specific type.Object
readObjectUnshared()
Read and return an unshared object.<T> T
readObjectUnshared(Class<T> type)
Read and return an unshared object, cast to a specific type.short
readShort()
int
readUnsignedByte()
int
readUnsignedShort()
String
readUTF()
long
skip(long n)
Skips over and discards up ton
bytes of data from this input stream.int
skipBytes(int n)
void
start(ByteInput newInput)
Begin unmarshalling from a stream.
-
-
-
Method Detail
-
readObjectUnshared
public Object readObjectUnshared() throws ClassNotFoundException, IOException
Description copied from interface:Unmarshaller
Read and return an unshared object.- Specified by:
readObjectUnshared
in interfaceUnmarshaller
- Returns:
- an unshared object
- Throws:
ClassNotFoundException
- if the class of a serialized object cannot be foundIOException
- if an error occurs
-
readObject
public Object readObject() throws ClassNotFoundException, IOException
- Specified by:
readObject
in interfaceObjectInput
- Throws:
ClassNotFoundException
IOException
-
read
public int read() throws IOException
Description copied from interface:ByteInput
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 interfaceByteInput
- Specified by:
read
in interfaceObjectInput
- 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
Description copied from interface:ByteInput
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 interfaceByteInput
- Specified by:
read
in interfaceObjectInput
- 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
Description copied from interface:ByteInput
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 interfaceByteInput
- Specified by:
read
in interfaceObjectInput
- Parameters:
b
- the destination arrayoff
- the offset into the array into which data should be readlen
- 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
Description copied from interface:ByteInput
Skips over and discards up ton
bytes of data from this input stream. If the end of stream is reached, this method returns0
in order to be consistent withInputStream.skip(long)
.- Specified by:
skip
in interfaceByteInput
- Specified by:
skip
in interfaceObjectInput
- 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
Description copied from interface:ByteInput
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 interfaceByteInput
- Specified by:
available
in interfaceObjectInput
- Returns:
- the number of bytes
- Throws:
IOException
- if an error occurs
-
readFully
public void readFully(byte[] b) throws IOException
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
readFully
public void readFully(byte[] b, int off, int len) throws IOException
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
skipBytes
public int skipBytes(int n) throws IOException
- Specified by:
skipBytes
in interfaceDataInput
- Throws:
IOException
-
readBoolean
public boolean readBoolean() throws IOException
- Specified by:
readBoolean
in interfaceDataInput
- Throws:
IOException
-
readByte
public byte readByte() throws IOException
- Specified by:
readByte
in interfaceDataInput
- Throws:
IOException
-
readUnsignedByte
public int readUnsignedByte() throws IOException
- Specified by:
readUnsignedByte
in interfaceDataInput
- Throws:
IOException
-
readShort
public short readShort() throws IOException
- Specified by:
readShort
in interfaceDataInput
- Throws:
IOException
-
readUnsignedShort
public int readUnsignedShort() throws IOException
- Specified by:
readUnsignedShort
in interfaceDataInput
- Throws:
IOException
-
readChar
public char readChar() throws IOException
- Specified by:
readChar
in interfaceDataInput
- Throws:
IOException
-
readInt
public int readInt() throws IOException
- Specified by:
readInt
in interfaceDataInput
- Throws:
IOException
-
readLong
public long readLong() throws IOException
- Specified by:
readLong
in interfaceDataInput
- Throws:
IOException
-
readFloat
public float readFloat() throws IOException
- Specified by:
readFloat
in interfaceDataInput
- Throws:
IOException
-
readDouble
public double readDouble() throws IOException
- Specified by:
readDouble
in interfaceDataInput
- Throws:
IOException
-
readLine
public String readLine() throws IOException
- Specified by:
readLine
in interfaceDataInput
- Throws:
IOException
-
readUTF
public String readUTF() throws IOException
- Specified by:
readUTF
in interfaceDataInput
- Throws:
IOException
-
clearInstanceCache
public void clearInstanceCache() throws IOException
Description copied from interface:Unmarshaller
Discard the instance cache.- Specified by:
clearInstanceCache
in interfaceUnmarshaller
- Throws:
IOException
- if an error occurs
-
clearClassCache
public void clearClassCache() throws IOException
Description copied from interface:Unmarshaller
Discard the class cache. Implicitly also discards the instance cache.- Specified by:
clearClassCache
in interfaceUnmarshaller
- Throws:
IOException
- if an error occurs
-
start
public void start(ByteInput newInput) throws IOException
Description copied from interface:Unmarshaller
Begin unmarshalling from a stream.- Specified by:
start
in interfaceUnmarshaller
- Parameters:
newInput
- the new stream- Throws:
IOException
- if an error occurs during setup, such as an invalid header
-
finish
public void finish() throws IOException
Description copied from interface:Unmarshaller
Finish unmarshalling from a stream. Any transient class or instance cache is discarded.- Specified by:
finish
in interfaceUnmarshaller
- Throws:
IOException
- if an error occurs
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceObjectInput
- Throws:
IOException
-
readObject
public <T> T readObject(Class<T> type) throws ClassNotFoundException, IOException
Description copied from interface:Unmarshaller
Read and return an object, cast to a specific type.- Specified by:
readObject
in interfaceUnmarshaller
- Type Parameters:
T
- the object type- Parameters:
type
- the object class- Returns:
- the object read from the stream
- Throws:
ClassNotFoundException
- if the class of a serialized object cannot be foundInvalidObjectException
- if the object is not of the expected typeIOException
- if an error occurs
-
readObjectUnshared
public <T> T readObjectUnshared(Class<T> type) throws ClassNotFoundException, IOException
Description copied from interface:Unmarshaller
Read and return an unshared object, cast to a specific type.- Specified by:
readObjectUnshared
in interfaceUnmarshaller
- Type Parameters:
T
- the object type- Parameters:
type
- the object class- Returns:
- an unshared object
- Throws:
ClassNotFoundException
- if the class of a serialized object cannot be foundInvalidObjectException
- if the object is not of the expected typeIOException
- if an error occurs
-
-