Package com.caucho.hessian.io
Class HessianInput
- java.lang.Object
-
- com.caucho.hessian.io.AbstractHessianInput
-
- com.caucho.hessian.io.HessianInput
-
public class HessianInput extends AbstractHessianInput
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
Fields Modifier and Type Field Description protected int_peekprotected java.util.ArrayList_refsprotected SerializerFactory_serializerFactory
-
Constructor Summary
Constructors Constructor Description HessianInput()Creates an uninitialized Hessian input stream.HessianInput(java.io.InputStream is)Creates a new Hessian input stream, initialized with an underlying input stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddRef(java.lang.Object ref)Adds a list/map reference.voidclose()protected java.lang.StringcodeName(int ch)voidcompleteCall()Completes reading the callvoidcompleteReply()Completes reading the callvoidcompleteValueReply()Completes reading the callprotected java.io.IOExceptionerror(java.lang.String message)protected java.io.IOExceptionexpect(java.lang.String expect, int ch)java.lang.StringgetMethod()Returns the calls methodjava.io.ReadergetReader()Starts reading a string.java.lang.ThrowablegetReplyFault()Returns any reply fault.SerializerFactorygetSerializerFactory()Gets the serializer factory.voidinit(java.io.InputStream is)Initialize the hessian stream with the underlying input stream.booleanisEnd()Returns true if this is the end of a list or a map.booleanreadBoolean()Reads a booleanintreadByte()Reads a byte from the stream.byte[]readBytes()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.doublereadDouble()Reads a doublevoidreadEnd()Reads the end byte.floatreadFloat()Reads a floatjava.lang.StringreadHeader()Reads a header, returning null if there are no headers.java.io.InputStreamreadInputStream()Reads bytes based on an input stream.intreadInt()Reads an integerintreadLength()Parses the length for an arrayvoidreadListEnd()Reads the end byte.intreadListStart()Reads the start of a list.longreadLong()Reads a longvoidreadMapEnd()Reads the end byte.intreadMapStart()Reads the start of a list.java.lang.StringreadMethod()Starts reading the callorg.w3c.dom.NodereadNode()Reads an XML node.voidreadNull()Reads a nulljava.lang.ObjectreadObject()Reads an arbitrary object from the input stream when the type is unknown.java.lang.ObjectreadObject(java.lang.Class cl)Reads an object from the input stream with an expected type.java.lang.ObjectreadRef()Reads a reference.java.lang.ObjectreadRemote()Reads a remote object.java.lang.ObjectreadReply(java.lang.Class expectedClass)Reads a reply as an object.shortreadShort()Reads a shortjava.lang.StringreadString()Reads a stringintreadString(char[] buffer, int offset, int length)Reads a byte array from the stream.java.lang.StringreadType()Parses a type from the stream.longreadUTCDate()Reads a date.voidresetReferences()Resets the references for streaming.java.lang.ObjectresolveRemote(java.lang.String type, java.lang.String url)Resolves a remote object.voidsetRef(int i, java.lang.Object ref)Adds a list/map reference.voidsetSerializerFactory(SerializerFactory factory)Sets the serializer factory.voidskipOptionalCall()For backward compatibility with HessianSkeletonvoidstartCall()Starts reading the call, including the headers.voidstartReply()Starts reading the replyvoidstartReplyBody()Starts reading the body of the reply, i.e.-
Methods inherited from class com.caucho.hessian.io.AbstractHessianInput
getRemoteResolver, readMethodArgLength, readToOutputStream, setRemoteResolver
-
-
-
-
Field Detail
-
_serializerFactory
protected SerializerFactory _serializerFactory
-
_refs
protected java.util.ArrayList _refs
-
_peek
protected int _peek
-
-
Method Detail
-
setSerializerFactory
public void setSerializerFactory(SerializerFactory factory)
Sets the serializer factory.- Overrides:
setSerializerFactoryin classAbstractHessianInput
-
getSerializerFactory
public SerializerFactory getSerializerFactory()
Gets the serializer factory.
-
init
public void init(java.io.InputStream is)
Initialize the hessian stream with the underlying input stream.- Overrides:
initin classAbstractHessianInput
-
getMethod
public java.lang.String getMethod()
Returns the calls method- Specified by:
getMethodin classAbstractHessianInput
-
getReplyFault
public java.lang.Throwable getReplyFault()
Returns any reply fault.
-
readCall
public int readCall() throws java.io.IOExceptionStarts reading the callc major minor
- Specified by:
readCallin classAbstractHessianInput- Throws:
java.io.IOException
-
skipOptionalCall
public void skipOptionalCall() throws java.io.IOExceptionFor backward compatibility with HessianSkeleton- Overrides:
skipOptionalCallin classAbstractHessianInput- Throws:
java.io.IOException
-
readMethod
public java.lang.String readMethod() throws java.io.IOExceptionStarts reading the callA successful completion will have a single value:
m b16 b8 method
- Specified by:
readMethodin classAbstractHessianInput- Throws:
java.io.IOException
-
startCall
public void startCall() throws java.io.IOExceptionStarts 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:
java.io.IOException
-
completeCall
public void completeCall() throws java.io.IOExceptionCompletes reading the callA successful completion will have a single value:
z
- Specified by:
completeCallin classAbstractHessianInput- Throws:
java.io.IOException
-
readReply
public java.lang.Object readReply(java.lang.Class expectedClass) throws java.lang.ThrowableReads a reply as an object. If the reply has a fault, throws the exception.- Specified by:
readReplyin classAbstractHessianInput- Throws:
java.lang.Throwable
-
startReply
public void startReply() throws java.lang.ThrowableStarts reading the replyA successful completion will have a single value:
r
- Specified by:
startReplyin classAbstractHessianInput- Throws:
java.lang.Throwable
-
startReplyBody
public void startReplyBody() throws java.lang.ThrowableDescription copied from class:AbstractHessianInputStarts reading the body of the reply, i.e. after the 'r' has been parsed.- Overrides:
startReplyBodyin classAbstractHessianInput- Throws:
java.lang.Throwable
-
completeReply
public void completeReply() throws java.io.IOExceptionCompletes reading the callA successful completion will have a single value:
z
- Specified by:
completeReplyin classAbstractHessianInput- Throws:
java.io.IOException
-
completeValueReply
public void completeValueReply() throws java.io.IOExceptionCompletes reading the callA successful completion will have a single value:
z
- Throws:
java.io.IOException
-
readHeader
public java.lang.String readHeader() throws java.io.IOExceptionReads a header, returning null if there are no headers.H b16 b8 value
- Specified by:
readHeaderin classAbstractHessianInput- Throws:
java.io.IOException
-
readNull
public void readNull() throws java.io.IOExceptionReads a nullN
- Specified by:
readNullin classAbstractHessianInput- Throws:
java.io.IOException
-
readBoolean
public boolean readBoolean() throws java.io.IOExceptionReads a booleanT F
- Specified by:
readBooleanin classAbstractHessianInput- Throws:
java.io.IOException
-
readShort
public short readShort() throws java.io.IOExceptionReads a shortI b32 b24 b16 b8
- Throws:
java.io.IOException
-
readInt
public int readInt() throws java.io.IOExceptionReads an integerI b32 b24 b16 b8
- Specified by:
readIntin classAbstractHessianInput- Throws:
java.io.IOException
-
readLong
public long readLong() throws java.io.IOExceptionReads a longL b64 b56 b48 b40 b32 b24 b16 b8
- Specified by:
readLongin classAbstractHessianInput- Throws:
java.io.IOException
-
readFloat
public float readFloat() throws java.io.IOExceptionReads a floatD b64 b56 b48 b40 b32 b24 b16 b8
- Throws:
java.io.IOException
-
readDouble
public double readDouble() throws java.io.IOExceptionReads a doubleD b64 b56 b48 b40 b32 b24 b16 b8
- Specified by:
readDoublein classAbstractHessianInput- Throws:
java.io.IOException
-
readUTCDate
public long readUTCDate() throws java.io.IOExceptionReads a date.T b64 b56 b48 b40 b32 b24 b16 b8
- Specified by:
readUTCDatein classAbstractHessianInput- Throws:
java.io.IOException
-
readChar
public int readChar() throws java.io.IOExceptionReads a byte from the stream.- Throws:
java.io.IOException
-
readString
public int readString(char[] buffer, int offset, int length) throws java.io.IOExceptionReads a byte array from the stream.- Throws:
java.io.IOException
-
readString
public java.lang.String readString() throws java.io.IOExceptionReads a stringS b16 b8 string value
- Specified by:
readStringin classAbstractHessianInput- Throws:
java.io.IOException
-
readNode
public org.w3c.dom.Node readNode() throws java.io.IOExceptionReads an XML node.S b16 b8 string value
- Overrides:
readNodein classAbstractHessianInput- Throws:
java.io.IOException
-
readBytes
public byte[] readBytes() throws java.io.IOExceptionReads a byte arrayB b16 b8 data value
- Specified by:
readBytesin classAbstractHessianInput- Throws:
java.io.IOException
-
readByte
public int readByte() throws java.io.IOExceptionReads a byte from the stream.- Throws:
java.io.IOException
-
readBytes
public int readBytes(byte[] buffer, int offset, int length) throws java.io.IOExceptionReads a byte array from the stream.- Throws:
java.io.IOException
-
readObject
public java.lang.Object readObject(java.lang.Class cl) throws java.io.IOExceptionReads 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:
java.io.IOException
-
readObject
public java.lang.Object readObject() throws java.io.IOExceptionReads an arbitrary object from the input stream when the type is unknown.- Specified by:
readObjectin classAbstractHessianInput- Throws:
java.io.IOException
-
readRemote
public java.lang.Object readRemote() throws java.io.IOExceptionReads a remote object.- Specified by:
readRemotein classAbstractHessianInput- Throws:
java.io.IOException
-
readRef
public java.lang.Object readRef() throws java.io.IOExceptionReads a reference.- Specified by:
readRefin classAbstractHessianInput- Throws:
java.io.IOException
-
readListStart
public int readListStart() throws java.io.IOExceptionReads the start of a list.- Specified by:
readListStartin classAbstractHessianInput- Throws:
java.io.IOException
-
readMapStart
public int readMapStart() throws java.io.IOExceptionReads the start of a list.- Specified by:
readMapStartin classAbstractHessianInput- Throws:
java.io.IOException
-
isEnd
public boolean isEnd() throws java.io.IOExceptionReturns true if this is the end of a list or a map.- Specified by:
isEndin classAbstractHessianInput- Throws:
java.io.IOException
-
readEnd
public void readEnd() throws java.io.IOExceptionReads the end byte.- Specified by:
readEndin classAbstractHessianInput- Throws:
java.io.IOException
-
readMapEnd
public void readMapEnd() throws java.io.IOExceptionReads the end byte.- Specified by:
readMapEndin classAbstractHessianInput- Throws:
java.io.IOException
-
readListEnd
public void readListEnd() throws java.io.IOExceptionReads the end byte.- Specified by:
readListEndin classAbstractHessianInput- Throws:
java.io.IOException
-
addRef
public int addRef(java.lang.Object ref)
Adds a list/map reference.- Specified by:
addRefin classAbstractHessianInput
-
setRef
public void setRef(int i, java.lang.Object ref)Adds a list/map reference.- Specified by:
setRefin classAbstractHessianInput
-
resetReferences
public void resetReferences()
Resets the references for streaming.- Overrides:
resetReferencesin classAbstractHessianInput
-
resolveRemote
public java.lang.Object resolveRemote(java.lang.String type, java.lang.String url) throws java.io.IOExceptionResolves a remote object.- Throws:
java.io.IOException
-
readType
public java.lang.String readType() throws java.io.IOExceptionParses a type from the stream.t b16 b8
- Specified by:
readTypein classAbstractHessianInput- Throws:
java.io.IOException
-
readLength
public int readLength() throws java.io.IOExceptionParses the length for an arrayl b32 b24 b16 b8
- Specified by:
readLengthin classAbstractHessianInput- Throws:
java.io.IOException
-
readInputStream
public java.io.InputStream readInputStream() throws java.io.IOExceptionReads bytes based on an input stream.- Specified by:
readInputStreamin classAbstractHessianInput- Throws:
java.io.IOException
-
close
public void close()
- Overrides:
closein classAbstractHessianInput
-
getReader
public java.io.Reader 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
protected java.io.IOException expect(java.lang.String expect, int ch)
-
codeName
protected java.lang.String codeName(int ch)
-
error
protected java.io.IOException error(java.lang.String message)
-
-