Package com.caucho.hessian.io
Class Hessian2Input
java.lang.Object
com.caucho.hessian.io.AbstractHessianInput
com.caucho.hessian.io.Hessian2Input
- All Implemented Interfaces:
Hessian2Constants
- Direct Known Subclasses:
HessianSerializerInput
Input stream for Hessian requests.
HessianInput is unbuffered, so any client needs to provide its own buffering.
InputStream is = ...; // from http connection HessianInput in = new HessianInput(is); String value; in.startReply(); // read reply header value = in.readString(); // read string value in.completeReply(); // read reply footer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ArrayList<com.caucho.hessian.io.Hessian2Input.ObjectDefinition>
protected SerializerFactory
protected SerializerFactory
Fields inherited from interface com.caucho.hessian.io.Hessian2Constants
BC_BINARY, BC_BINARY_CHUNK, BC_BINARY_DIRECT, BC_BINARY_SHORT, BC_CLASS_DEF, BC_DATE, BC_DATE_MINUTE, BC_DOUBLE, BC_DOUBLE_BYTE, BC_DOUBLE_MILL, BC_DOUBLE_ONE, BC_DOUBLE_SHORT, BC_DOUBLE_ZERO, BC_END, BC_FALSE, BC_INT, BC_INT_BYTE_ZERO, BC_INT_SHORT_ZERO, BC_INT_ZERO, BC_LIST_DIRECT, BC_LIST_DIRECT_UNTYPED, BC_LIST_FIXED, BC_LIST_FIXED_UNTYPED, BC_LIST_VARIABLE, BC_LIST_VARIABLE_UNTYPED, BC_LONG, BC_LONG_BYTE_ZERO, BC_LONG_INT, BC_LONG_SHORT_ZERO, BC_LONG_ZERO, BC_MAP, BC_MAP_UNTYPED, BC_NULL, BC_OBJECT, BC_OBJECT_DEF, BC_OBJECT_DIRECT, BC_REF, BC_STRING, BC_STRING_CHUNK, BC_STRING_DIRECT, BC_STRING_SHORT, BC_TRUE, BINARY_DIRECT_MAX, BINARY_SHORT_MAX, INT_BYTE_MAX, INT_BYTE_MIN, INT_DIRECT_MAX, INT_DIRECT_MIN, INT_SHORT_MAX, INT_SHORT_MIN, LIST_DIRECT_MAX, LONG_BYTE_MAX, LONG_BYTE_MIN, LONG_DIRECT_MAX, LONG_DIRECT_MIN, LONG_SHORT_MAX, LONG_SHORT_MIN, OBJECT_DIRECT_MAX, P_PACKET, P_PACKET_CHUNK, P_PACKET_DIRECT, P_PACKET_SHORT, PACKET_DIRECT_MAX, PACKET_SHORT_MAX, STRING_DIRECT_MAX, STRING_SHORT_MAX
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new Hessian input stream, initialized with an underlying input stream. -
Method Summary
Modifier and TypeMethodDescriptionint
Adds a list/map reference.void
close()
protected String
codeName
(int ch) void
Completes reading the callvoid
Completes reading the envelopevoid
Completes reading the messagevoid
Completes reading the callvoid
Completes reading the callprotected IOException
protected IOException
protected final SerializerFactory
Gets the serializer factory.void
free()
Returns the calls methodStarts reading a string.Returns any reply fault.Gets the serializer factory.void
init
(InputStream is) Initialize the Hessian stream with the underlying input stream.void
boolean
boolean
isEnd()
Returns true if this is the end of a list or a map.final int
read()
Normally, shouldn't be called externally, but needed for QA, e.g.Object[]
boolean
Reads a booleanint
readByte()
Reads a byte from the stream.byte[]
Reads a byte arrayint
readBytes
(byte[] buffer, int offset, int length) Reads a byte array from the stream.int
readCall()
Starts reading the callint
readChar()
Reads a byte from the stream.double
Reads a doublevoid
readEnd()
Reads the end byte.int
Starts reading the envelopefloat
Reads a floatReads a header, returning null if there are no headers.Reads bytes based on an input stream.final int
readInt()
Reads an integerint
Parses the length for an arrayvoid
Reads the end byte.int
Reads the start of a list.long
readLong()
Reads a longvoid
Reads the end byte.int
Reads the start of a list.Starts reading the callint
Returns the number of method argumentsvoid
readNull()
Reads a nullReads an arbitrary object from the input stream when the type is unknown.readObject
(Class cl) Reads an object from the input stream with an expected type.readRef()
Reads a reference.Reads a remote object.Reads a reply as an object.short
Reads a shortReads a stringint
readString
(char[] buffer, int offset, int length) Reads a byte array from the stream.readType()
Parses a type from the stream.long
Reads a date.void
reset()
void
void
Resets the references for streaming.resolveRemote
(String type, String url) Resolves a remote object.void
setCloseStreamOnClose
(boolean isClose) void
Adds a list/map reference.void
setSerializerFactory
(SerializerFactory factory) Sets the serializer factory.void
Starts reading the call, including the headers.int
Starts reading a packetvoid
Starts reading the replyprotected void
unread()
Methods inherited from class com.caucho.hessian.io.AbstractHessianInput
getRemoteResolver, readNode, readToOutputStream, setRemoteResolver, skipOptionalCall, startReplyBody
-
Field Details
-
_defaultSerializerFactory
-
_serializerFactory
-
_refs
-
_classDefs
-
_types
-
-
Constructor Details
-
Hessian2Input
public Hessian2Input() -
Hessian2Input
Creates a new Hessian input stream, initialized with an underlying input stream.- Parameters:
is
- the underlying input stream.
-
-
Method Details
-
setSerializerFactory
Sets the serializer factory.- Overrides:
setSerializerFactory
in classAbstractHessianInput
-
getSerializerFactory
Gets the serializer factory. -
findSerializerFactory
Gets the serializer factory. -
setCloseStreamOnClose
public void setCloseStreamOnClose(boolean isClose) -
isCloseStreamOnClose
public boolean isCloseStreamOnClose() -
getMethod
Returns the calls method- Specified by:
getMethod
in classAbstractHessianInput
-
getReplyFault
Returns any reply fault. -
init
Description copied from class:AbstractHessianInput
Initialize the Hessian stream with the underlying input stream.- Overrides:
init
in classAbstractHessianInput
-
initPacket
-
readCall
Starts reading the callc major minor
- Specified by:
readCall
in classAbstractHessianInput
- Throws:
IOException
-
readEnvelope
Starts reading the envelopeE major minor
- Throws:
IOException
-
completeEnvelope
Completes reading the envelopeA successful completion will have a single value:
Z
- Throws:
IOException
-
readMethod
Starts reading the callA successful completion will have a single value:
string
- Specified by:
readMethod
in classAbstractHessianInput
- Throws:
IOException
-
readMethodArgLength
Returns the number of method argumentsint
- Overrides:
readMethodArgLength
in classAbstractHessianInput
- Returns:
- -1 for a variable length (hessian 1.0)
- Throws:
IOException
-
startCall
Starts reading the call, including the headers.The call expects the following protocol data
c major minor m b16 b8 method
- Specified by:
startCall
in classAbstractHessianInput
- Throws:
IOException
-
readArguments
- Throws:
IOException
-
completeCall
Completes reading the callA successful completion will have a single value:
- Specified by:
completeCall
in classAbstractHessianInput
- Throws:
IOException
-
readReply
Reads a reply as an object. If the reply has a fault, throws the exception.- Specified by:
readReply
in classAbstractHessianInput
- Throws:
Throwable
-
startReply
Starts reading the replyA successful completion will have a single value:
r
- Specified by:
startReply
in classAbstractHessianInput
- Throws:
Throwable
-
completeReply
Completes reading the callA successful completion will have a single value:
z
- Specified by:
completeReply
in classAbstractHessianInput
- Throws:
IOException
-
completeValueReply
Completes reading the callA successful completion will have a single value:
z
- Throws:
IOException
-
readHeader
Reads a header, returning null if there are no headers.H b16 b8 value
- Specified by:
readHeader
in classAbstractHessianInput
- Throws:
IOException
-
startMessage
Starts reading a packetp major minor
- Throws:
IOException
-
completeMessage
Completes reading the messageA successful completion will have a single value:
z
- Throws:
IOException
-
readNull
Reads a nullN
- Specified by:
readNull
in classAbstractHessianInput
- Throws:
IOException
-
readBoolean
Reads a booleanT F
- Specified by:
readBoolean
in classAbstractHessianInput
- Throws:
IOException
-
readShort
Reads a shortI b32 b24 b16 b8
- Throws:
IOException
-
readInt
Reads an integerI b32 b24 b16 b8
- Specified by:
readInt
in classAbstractHessianInput
- Throws:
IOException
-
readLong
Reads a longL b64 b56 b48 b40 b32 b24 b16 b8
- Specified by:
readLong
in classAbstractHessianInput
- Throws:
IOException
-
readFloat
Reads a floatD b64 b56 b48 b40 b32 b24 b16 b8
- Throws:
IOException
-
readDouble
Reads a doubleD b64 b56 b48 b40 b32 b24 b16 b8
- Specified by:
readDouble
in classAbstractHessianInput
- Throws:
IOException
-
readUTCDate
Reads a date.T b64 b56 b48 b40 b32 b24 b16 b8
- Specified by:
readUTCDate
in classAbstractHessianInput
- Throws:
IOException
-
readChar
Reads a byte from the stream.- Throws:
IOException
-
readString
Reads a byte array from the stream.- Throws:
IOException
-
readString
Reads a stringS b16 b8 string value
- Specified by:
readString
in classAbstractHessianInput
- Throws:
IOException
-
readBytes
Reads a byte arrayB b16 b8 data value
- Specified by:
readBytes
in classAbstractHessianInput
- Throws:
IOException
-
readByte
Reads a byte from the stream.- Throws:
IOException
-
readBytes
Reads a byte array from the stream.- Throws:
IOException
-
readObject
Reads an object from the input stream with an expected type.- Specified by:
readObject
in classAbstractHessianInput
- Parameters:
cl
- the expected class if the protocol doesn't supply it.- Throws:
IOException
-
readObject
Reads an arbitrary object from the input stream when the type is unknown.- Specified by:
readObject
in classAbstractHessianInput
- Throws:
IOException
-
readRemote
Reads a remote object.- Specified by:
readRemote
in classAbstractHessianInput
- Throws:
IOException
-
readRef
Reads a reference.- Specified by:
readRef
in classAbstractHessianInput
- Throws:
IOException
-
readListStart
Reads the start of a list.- Specified by:
readListStart
in classAbstractHessianInput
- Throws:
IOException
-
readMapStart
Reads the start of a list.- Specified by:
readMapStart
in classAbstractHessianInput
- Throws:
IOException
-
isEnd
Returns true if this is the end of a list or a map.- Specified by:
isEnd
in classAbstractHessianInput
- Throws:
IOException
-
readEnd
Reads the end byte.- Specified by:
readEnd
in classAbstractHessianInput
- Throws:
IOException
-
readMapEnd
Reads the end byte.- Specified by:
readMapEnd
in classAbstractHessianInput
- Throws:
IOException
-
readListEnd
Reads the end byte.- Specified by:
readListEnd
in classAbstractHessianInput
- Throws:
IOException
-
addRef
Adds a list/map reference.- Specified by:
addRef
in classAbstractHessianInput
-
setRef
Adds a list/map reference.- Specified by:
setRef
in classAbstractHessianInput
-
resetReferences
public void resetReferences()Resets the references for streaming.- Overrides:
resetReferences
in classAbstractHessianInput
-
reset
public void reset() -
resetBuffer
public void resetBuffer() -
readStreamingObject
- Throws:
IOException
-
resolveRemote
Resolves a remote object.- Throws:
IOException
-
readType
Parses a type from the stream.type ::= string type ::= int
- Specified by:
readType
in classAbstractHessianInput
- Throws:
IOException
-
readLength
Parses the length for an arrayl b32 b24 b16 b8
- Specified by:
readLength
in classAbstractHessianInput
- Throws:
IOException
-
readInputStream
Reads bytes based on an input stream.- Specified by:
readInputStream
in classAbstractHessianInput
- Throws:
IOException
-
read
Normally, shouldn't be called externally, but needed for QA, e.g. ejb/3b01.- Throws:
IOException
-
unread
protected void unread() -
getReader
Description copied from class:AbstractHessianInput
Starts reading a string. All the characters must be read before calling the next method. The actual characters will be read with the reader's read() or read(char [], int, int).s b16 b8 non-final string chunk S b16 b8 final string chunk
- Specified by:
getReader
in classAbstractHessianInput
-
expect
- Throws:
IOException
-
codeName
-
error
-
free
public void free() -
close
- Overrides:
close
in classAbstractHessianInput
- Throws:
IOException
-