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 SerializerFactoryprotected SerializerFactoryFields 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 TypeMethodDescriptionintAdds a list/map reference.voidclose()protected StringcodeName(int ch) voidCompletes reading the callvoidCompletes reading the envelopevoidCompletes reading the messagevoidCompletes reading the callvoidCompletes reading the callprotected IOExceptionprotected IOExceptionprotected final SerializerFactoryGets the serializer factory.voidfree()Returns the calls methodStarts reading a string.Returns any reply fault.Gets the serializer factory.voidinit(InputStream is) Initialize the Hessian stream with the underlying input stream.voidbooleanbooleanisEnd()Returns true if this is the end of a list or a map.final intread()Normally, shouldn't be called externally, but needed for QA, e.g.Object[]booleanReads a booleanintreadByte()Reads a byte from the stream.byte[]Reads a byte arrayintreadBytes(byte[] buffer, int offset, int length) Reads a byte array from the stream.intreadCall()Starts reading the callintreadChar()Reads a byte from the stream.doubleReads a doublevoidreadEnd()Reads the end byte.intStarts reading the envelopefloatReads a floatReads a header, returning null if there are no headers.Reads bytes based on an input stream.final intreadInt()Reads an integerintParses the length for an arrayvoidReads the end byte.intReads the start of a list.longreadLong()Reads a longvoidReads the end byte.intReads the start of a list.Starts reading the callintReturns the number of method argumentsvoidreadNull()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.shortReads a shortReads a stringintreadString(char[] buffer, int offset, int length) Reads a byte array from the stream.readType()Parses a type from the stream.longReads a date.voidreset()voidvoidResets the references for streaming.resolveRemote(String type, String url) Resolves a remote object.voidsetCloseStreamOnClose(boolean isClose) voidAdds a list/map reference.voidsetSerializerFactory(SerializerFactory factory) Sets the serializer factory.voidStarts reading the call, including the headers.intStarts reading a packetvoidStarts reading the replyprotected voidunread()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:
setSerializerFactoryin 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:
getMethodin classAbstractHessianInput
-
getReplyFault
Returns any reply fault. -
init
Description copied from class:AbstractHessianInputInitialize the Hessian stream with the underlying input stream.- Overrides:
initin classAbstractHessianInput
-
initPacket
-
readCall
Starts reading the callc major minor
- Specified by:
readCallin 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:
readMethodin classAbstractHessianInput- Throws:
IOException
-
readMethodArgLength
Returns the number of method argumentsint
- Overrides:
readMethodArgLengthin 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:
startCallin classAbstractHessianInput- Throws:
IOException
-
readArguments
- Throws:
IOException
-
completeCall
Completes reading the callA successful completion will have a single value:
- Specified by:
completeCallin classAbstractHessianInput- Throws:
IOException
-
readReply
Reads a reply as an object. If the reply has a fault, throws the exception.- Specified by:
readReplyin classAbstractHessianInput- Throws:
Throwable
-
startReply
Starts reading the replyA successful completion will have a single value:
r
- Specified by:
startReplyin classAbstractHessianInput- Throws:
Throwable
-
completeReply
Completes reading the callA successful completion will have a single value:
z
- Specified by:
completeReplyin 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:
readHeaderin 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:
readNullin classAbstractHessianInput- Throws:
IOException
-
readBoolean
Reads a booleanT F
- Specified by:
readBooleanin classAbstractHessianInput- Throws:
IOException
-
readShort
Reads a shortI b32 b24 b16 b8
- Throws:
IOException
-
readInt
Reads an integerI b32 b24 b16 b8
- Specified by:
readIntin classAbstractHessianInput- Throws:
IOException
-
readLong
Reads a longL b64 b56 b48 b40 b32 b24 b16 b8
- Specified by:
readLongin 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:
readDoublein classAbstractHessianInput- Throws:
IOException
-
readUTCDate
Reads a date.T b64 b56 b48 b40 b32 b24 b16 b8
- Specified by:
readUTCDatein 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:
readStringin classAbstractHessianInput- Throws:
IOException
-
readBytes
Reads a byte arrayB b16 b8 data value
- Specified by:
readBytesin 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:
readObjectin 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:
readObjectin classAbstractHessianInput- Throws:
IOException
-
readRemote
Reads a remote object.- Specified by:
readRemotein classAbstractHessianInput- Throws:
IOException
-
readRef
Reads a reference.- Specified by:
readRefin classAbstractHessianInput- Throws:
IOException
-
readListStart
Reads the start of a list.- Specified by:
readListStartin classAbstractHessianInput- Throws:
IOException
-
readMapStart
Reads the start of a list.- Specified by:
readMapStartin classAbstractHessianInput- Throws:
IOException
-
isEnd
Returns true if this is the end of a list or a map.- Specified by:
isEndin classAbstractHessianInput- Throws:
IOException
-
readEnd
Reads the end byte.- Specified by:
readEndin classAbstractHessianInput- Throws:
IOException
-
readMapEnd
Reads the end byte.- Specified by:
readMapEndin classAbstractHessianInput- Throws:
IOException
-
readListEnd
Reads the end byte.- Specified by:
readListEndin classAbstractHessianInput- Throws:
IOException
-
addRef
Adds a list/map reference.- Specified by:
addRefin classAbstractHessianInput
-
setRef
Adds a list/map reference.- Specified by:
setRefin classAbstractHessianInput
-
resetReferences
public void resetReferences()Resets the references for streaming.- Overrides:
resetReferencesin 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:
readTypein classAbstractHessianInput- Throws:
IOException
-
readLength
Parses the length for an arrayl b32 b24 b16 b8
- Specified by:
readLengthin classAbstractHessianInput- Throws:
IOException
-
readInputStream
Reads bytes based on an input stream.- Specified by:
readInputStreamin 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:AbstractHessianInputStarts 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:
getReaderin classAbstractHessianInput
-
expect
- Throws:
IOException
-
codeName
-
error
-
free
public void free() -
close
- Overrides:
closein classAbstractHessianInput- Throws:
IOException
-