Package org.jboss.marshalling.serial
Class BlockUnmarshaller
- java.lang.Object
-
- org.jboss.marshalling.serial.BlockUnmarshaller
-
- All Implemented Interfaces:
java.io.Closeable,java.io.DataInput,java.io.ObjectInput,java.io.ObjectStreamConstants,java.lang.AutoCloseable,ByteInput,ExtendedObjectStreamConstants,Unmarshaller
public final class BlockUnmarshaller extends java.lang.Object implements Unmarshaller, ExtendedObjectStreamConstants
-
-
Field Summary
Fields Modifier and Type Field Description private intremainingprivate SerialUnmarshallerserialUnmarshaller-
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
-
-
Constructor Summary
Constructors Constructor Description BlockUnmarshaller(SerialUnmarshaller serialUnmarshaller)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()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.private java.io.StreamCorruptedExceptionbadLeadByte(int leadByte)voidclearClassCache()Discard the class cache.voidclearInstanceCache()Discard the instance cache.voidclose()(package private) voidendOfStream()voidfinish()Finish unmarshalling from a stream.(package private) booleaninBlock()intread()Reads the next byte of data from the input stream.intread(byte[] b)Read some bytes from the input stream into the given array.intread(byte[] b, int off, int len)Read some bytes from the input stream into the given array.(package private) voidreadBlockHeader(int leadByte)booleanreadBoolean()bytereadByte()charreadChar()doublereadDouble()floatreadFloat()voidreadFully(byte[] b)voidreadFully(byte[] b, int off, int len)intreadInt()java.lang.StringreadLine()longreadLong()java.lang.ObjectreadObject()private java.lang.ObjectreadObject(boolean unshared)<T> TreadObject(java.lang.Class<T> type)Read and return an object, cast to a specific type.java.lang.ObjectreadObjectUnshared()Read and return an unshared object.<T> TreadObjectUnshared(java.lang.Class<T> type)Read and return an unshared object, cast to a specific type.shortreadShort()(package private) voidreadToEndBlockData()intreadUnsignedByte()intreadUnsignedShort()java.lang.StringreadUTF()(package private) intremaining()longskip(long n)Skips over and discards up tonbytes of data from this input stream.intskipBytes(int n)voidstart(ByteInput newInput)Begin unmarshalling from a stream.(package private) voidunblock()private static java.io.InvalidObjectExceptionwrongType(java.lang.ClassCastException e, java.lang.Class<?> expected, java.lang.Class<?> actual)
-
-
-
Field Detail
-
serialUnmarshaller
private final SerialUnmarshaller serialUnmarshaller
-
remaining
private int remaining
-
-
Constructor Detail
-
BlockUnmarshaller
BlockUnmarshaller(SerialUnmarshaller serialUnmarshaller)
-
-
Method Detail
-
inBlock
boolean inBlock()
-
remaining
int remaining()
-
endOfStream
void endOfStream()
-
unblock
void unblock()
-
readBlockHeader
void readBlockHeader(int leadByte) throws java.io.IOException- Throws:
java.io.IOException
-
readToEndBlockData
void readToEndBlockData() throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
badLeadByte
private java.io.StreamCorruptedException badLeadByte(int leadByte)
-
readObjectUnshared
public java.lang.Object readObjectUnshared() throws java.lang.ClassNotFoundException, java.io.IOExceptionDescription copied from interface:UnmarshallerRead and return an unshared object.- Specified by:
readObjectUnsharedin interfaceUnmarshaller- Returns:
- an unshared object
- Throws:
java.lang.ClassNotFoundException- if the class of a serialized object cannot be foundjava.io.IOException- if an error occurs
-
readObject
public java.lang.Object readObject() throws java.lang.ClassNotFoundException, java.io.IOException- Specified by:
readObjectin interfacejava.io.ObjectInput- Throws:
java.lang.ClassNotFoundExceptionjava.io.IOException
-
readObject
private java.lang.Object readObject(boolean unshared) throws java.lang.ClassNotFoundException, java.io.IOException- Throws:
java.lang.ClassNotFoundExceptionjava.io.IOException
-
read
public int read() throws java.io.IOExceptionDescription copied from interface:ByteInputReads 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.
-
read
public int read(byte[] b) throws java.io.IOExceptionDescription copied from interface:ByteInputRead 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.
-
read
public int read(byte[] b, int off, int len) throws java.io.IOExceptionDescription copied from interface:ByteInputRead 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:
readin interfaceByteInput- Specified by:
readin interfacejava.io.ObjectInput- 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:
java.io.IOException- if an error occurs
-
skip
public long skip(long n) throws java.io.IOExceptionDescription copied from interface:ByteInputSkips over and discards up tonbytes of data from this input stream. If the end of stream is reached, this method returns0in order to be consistent withInputStream.skip(long).
-
available
public int available() throws java.io.IOExceptionDescription copied from interface:ByteInputReturns 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.
-
readFully
public void readFully(byte[] b) throws java.io.IOException- Specified by:
readFullyin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readFully
public void readFully(byte[] b, int off, int len) throws java.io.IOException- Specified by:
readFullyin interfacejava.io.DataInput- Throws:
java.io.IOException
-
skipBytes
public int skipBytes(int n) throws java.io.IOException- Specified by:
skipBytesin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readBoolean
public boolean readBoolean() throws java.io.IOException- Specified by:
readBooleanin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readByte
public byte readByte() throws java.io.IOException- Specified by:
readBytein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUnsignedByte
public int readUnsignedByte() throws java.io.IOException- Specified by:
readUnsignedBytein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readShort
public short readShort() throws java.io.IOException- Specified by:
readShortin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUnsignedShort
public int readUnsignedShort() throws java.io.IOException- Specified by:
readUnsignedShortin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readChar
public char readChar() throws java.io.IOException- Specified by:
readCharin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readInt
public int readInt() throws java.io.IOException- Specified by:
readIntin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readLong
public long readLong() throws java.io.IOException- Specified by:
readLongin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readFloat
public float readFloat() throws java.io.IOException- Specified by:
readFloatin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readDouble
public double readDouble() throws java.io.IOException- Specified by:
readDoublein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readLine
public java.lang.String readLine() throws java.io.IOException- Specified by:
readLinein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUTF
public java.lang.String readUTF() throws java.io.IOException- Specified by:
readUTFin interfacejava.io.DataInput- Throws:
java.io.IOException
-
clearInstanceCache
public void clearInstanceCache() throws java.io.IOExceptionDescription copied from interface:UnmarshallerDiscard the instance cache.- Specified by:
clearInstanceCachein interfaceUnmarshaller- Throws:
java.io.IOException- if an error occurs
-
clearClassCache
public void clearClassCache() throws java.io.IOExceptionDescription copied from interface:UnmarshallerDiscard the class cache. Implicitly also discards the instance cache.- Specified by:
clearClassCachein interfaceUnmarshaller- Throws:
java.io.IOException- if an error occurs
-
start
public void start(ByteInput newInput) throws java.io.IOException
Description copied from interface:UnmarshallerBegin unmarshalling from a stream.- Specified by:
startin interfaceUnmarshaller- Parameters:
newInput- the new stream- Throws:
java.io.IOException- if an error occurs during setup, such as an invalid header
-
finish
public void finish() throws java.io.IOExceptionDescription copied from interface:UnmarshallerFinish unmarshalling from a stream. Any transient class or instance cache is discarded.- Specified by:
finishin interfaceUnmarshaller- Throws:
java.io.IOException- if an error occurs
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfacejava.io.ObjectInput- Throws:
java.io.IOException
-
readObject
public <T> T readObject(java.lang.Class<T> type) throws java.lang.ClassNotFoundException, java.io.IOExceptionDescription copied from interface:UnmarshallerRead and return an object, cast to a specific type.- Specified by:
readObjectin interfaceUnmarshaller- Type Parameters:
T- the object type- Parameters:
type- the object class- Returns:
- the object read from the stream
- Throws:
java.lang.ClassNotFoundException- if the class of a serialized object cannot be foundjava.io.InvalidObjectException- if the object is not of the expected typejava.io.IOException- if an error occurs
-
readObjectUnshared
public <T> T readObjectUnshared(java.lang.Class<T> type) throws java.lang.ClassNotFoundException, java.io.IOExceptionDescription copied from interface:UnmarshallerRead and return an unshared object, cast to a specific type.- Specified by:
readObjectUnsharedin interfaceUnmarshaller- Type Parameters:
T- the object type- Parameters:
type- the object class- Returns:
- an unshared object
- Throws:
java.lang.ClassNotFoundException- if the class of a serialized object cannot be foundjava.io.InvalidObjectException- if the object is not of the expected typejava.io.IOException- if an error occurs
-
wrongType
private static java.io.InvalidObjectException wrongType(java.lang.ClassCastException e, java.lang.Class<?> expected, java.lang.Class<?> actual)
-
-