Package com.caucho.burlap.io
Class BurlapInput
- java.lang.Object
-
- com.caucho.hessian.io.AbstractHessianInput
-
- com.caucho.burlap.io.AbstractBurlapInput
-
- com.caucho.burlap.io.BurlapInput
-
public class BurlapInput extends AbstractBurlapInput
Input stream for Burlap requests.BurlapInput is unbuffered, so any client needs to provide its own buffering.
InputStream is = ...; // from http connection BurlapInput in = new BurlapInput(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 java.lang.StringBuffer_entityBufferprotected java.util.Calendar_localCalendarprotected int_peekprotected java.util.ArrayList_refsprotected java.lang.StringBuffer_sbufprotected SerializerFactory_serializerFactoryprotected java.util.Calendar_utcCalendarstatic intTAG_BASE64static intTAG_BASE64_ENDstatic intTAG_BOOLEANstatic intTAG_BOOLEAN_ENDstatic intTAG_CALLstatic intTAG_CALL_ENDstatic intTAG_DATEstatic intTAG_DATE_ENDstatic intTAG_DOUBLEstatic intTAG_DOUBLE_ENDstatic intTAG_EOFstatic intTAG_FAULTstatic intTAG_FAULT_ENDstatic intTAG_HEADERstatic intTAG_HEADER_ENDstatic intTAG_INTstatic intTAG_INT_ENDstatic intTAG_LENGTHstatic intTAG_LENGTH_ENDstatic intTAG_LISTstatic intTAG_LIST_ENDstatic intTAG_LONGstatic intTAG_LONG_ENDstatic intTAG_MAPstatic intTAG_MAP_ENDstatic intTAG_METHODstatic intTAG_METHOD_ENDstatic intTAG_NULLstatic intTAG_NULL_ENDstatic intTAG_REFstatic intTAG_REF_ENDstatic intTAG_REMOTEstatic intTAG_REMOTE_ENDstatic intTAG_REPLYstatic intTAG_REPLY_ENDstatic intTAG_STRINGstatic intTAG_STRING_ENDstatic intTAG_TYPEstatic intTAG_TYPE_ENDstatic intTAG_XMLstatic intTAG_XML_END
-
Constructor Summary
Constructors Constructor Description BurlapInput()Creates an uninitialized Burlap input stream.BurlapInput(java.io.InputStream is)Creates a new Burlap input stream, initialized with an underlying input stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddRef(java.lang.Object ref)Adds a list/map reference.voidcompleteCall()Completes reading the callvoidcompleteReply()Completes reading the callprotected java.io.IOExceptionerror(java.lang.String message)protected java.io.IOExceptionexpectBeginTag(java.lang.String expect, java.lang.String tag)protected java.io.IOExceptionexpectedChar(java.lang.String expect, int ch)protected java.io.IOExceptionexpectedTag(java.lang.String expect, int tag)voidexpectTag(int expectTag)java.io.InputStreamgetInputStream()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 burlap stream with the underlying input stream.booleanisEnd()Returns true if this is the end of a list or a map.protected booleanisWhitespace(int ch)protected byte[]parseBytes()Parses a byte array.protected java.io.ByteArrayOutputStreamparseBytes(java.io.ByteArrayOutputStream bos)Parses a byte array.protected longparseDate()Parses a date value from the stream.protected longparseDate(java.util.Calendar calendar)Parses a date value from the stream.protected java.lang.StringparseString()protected java.lang.StringBufferparseString(java.lang.StringBuffer sbuf)Parses a string value from the stream.protected intparseTag()Parses a tag.booleanreadBoolean()Reads a booleanbytereadByte()Reads a bytebyte[]readBytes()Reads a byte arrayintreadCall()Starts reading the calldoublereadDouble()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()Starts reading a byte array using an input stream.intreadInt()Reads an integerintreadLength()Reads a lengthvoidreadListEnd()Reads the end of the mapintreadListStart()Reads the start of a list.longreadLocalDate()Reads a date.longreadLong()Reads a longvoidreadMapEnd()Reads the end of the mapintreadMapStart()Reads the start of a map.java.lang.StringreadMethod()Reads the methodorg.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 stringjava.lang.StringreadType()Parses a type from the stream.longreadUTCDate()Reads a date.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.protected intskipWhitespace()voidstartCall()Starts reading the callvoidstartReply()Starts reading the replyprotected static java.lang.StringtagName(int tag)-
Methods inherited from class com.caucho.hessian.io.AbstractHessianInput
close, getRemoteResolver, readMethodArgLength, readToOutputStream, resetReferences, setRemoteResolver, skipOptionalCall, startReplyBody
-
-
-
-
Field Detail
-
TAG_EOF
public static final int TAG_EOF
- See Also:
- Constant Field Values
-
TAG_NULL
public static final int TAG_NULL
- See Also:
- Constant Field Values
-
TAG_BOOLEAN
public static final int TAG_BOOLEAN
- See Also:
- Constant Field Values
-
TAG_INT
public static final int TAG_INT
- See Also:
- Constant Field Values
-
TAG_LONG
public static final int TAG_LONG
- See Also:
- Constant Field Values
-
TAG_DOUBLE
public static final int TAG_DOUBLE
- See Also:
- Constant Field Values
-
TAG_DATE
public static final int TAG_DATE
- See Also:
- Constant Field Values
-
TAG_STRING
public static final int TAG_STRING
- See Also:
- Constant Field Values
-
TAG_XML
public static final int TAG_XML
- See Also:
- Constant Field Values
-
TAG_BASE64
public static final int TAG_BASE64
- See Also:
- Constant Field Values
-
TAG_MAP
public static final int TAG_MAP
- See Also:
- Constant Field Values
-
TAG_LIST
public static final int TAG_LIST
- See Also:
- Constant Field Values
-
TAG_TYPE
public static final int TAG_TYPE
- See Also:
- Constant Field Values
-
TAG_LENGTH
public static final int TAG_LENGTH
- See Also:
- Constant Field Values
-
TAG_REF
public static final int TAG_REF
- See Also:
- Constant Field Values
-
TAG_REMOTE
public static final int TAG_REMOTE
- See Also:
- Constant Field Values
-
TAG_CALL
public static final int TAG_CALL
- See Also:
- Constant Field Values
-
TAG_REPLY
public static final int TAG_REPLY
- See Also:
- Constant Field Values
-
TAG_FAULT
public static final int TAG_FAULT
- See Also:
- Constant Field Values
-
TAG_METHOD
public static final int TAG_METHOD
- See Also:
- Constant Field Values
-
TAG_HEADER
public static final int TAG_HEADER
- See Also:
- Constant Field Values
-
TAG_NULL_END
public static final int TAG_NULL_END
- See Also:
- Constant Field Values
-
TAG_BOOLEAN_END
public static final int TAG_BOOLEAN_END
- See Also:
- Constant Field Values
-
TAG_INT_END
public static final int TAG_INT_END
- See Also:
- Constant Field Values
-
TAG_LONG_END
public static final int TAG_LONG_END
- See Also:
- Constant Field Values
-
TAG_DOUBLE_END
public static final int TAG_DOUBLE_END
- See Also:
- Constant Field Values
-
TAG_DATE_END
public static final int TAG_DATE_END
- See Also:
- Constant Field Values
-
TAG_STRING_END
public static final int TAG_STRING_END
- See Also:
- Constant Field Values
-
TAG_XML_END
public static final int TAG_XML_END
- See Also:
- Constant Field Values
-
TAG_BASE64_END
public static final int TAG_BASE64_END
- See Also:
- Constant Field Values
-
TAG_MAP_END
public static final int TAG_MAP_END
- See Also:
- Constant Field Values
-
TAG_LIST_END
public static final int TAG_LIST_END
- See Also:
- Constant Field Values
-
TAG_TYPE_END
public static final int TAG_TYPE_END
- See Also:
- Constant Field Values
-
TAG_LENGTH_END
public static final int TAG_LENGTH_END
- See Also:
- Constant Field Values
-
TAG_REF_END
public static final int TAG_REF_END
- See Also:
- Constant Field Values
-
TAG_REMOTE_END
public static final int TAG_REMOTE_END
- See Also:
- Constant Field Values
-
TAG_CALL_END
public static final int TAG_CALL_END
- See Also:
- Constant Field Values
-
TAG_REPLY_END
public static final int TAG_REPLY_END
- See Also:
- Constant Field Values
-
TAG_FAULT_END
public static final int TAG_FAULT_END
- See Also:
- Constant Field Values
-
TAG_METHOD_END
public static final int TAG_METHOD_END
- See Also:
- Constant Field Values
-
TAG_HEADER_END
public static final int TAG_HEADER_END
- See Also:
- Constant Field Values
-
_serializerFactory
protected SerializerFactory _serializerFactory
-
_refs
protected java.util.ArrayList _refs
-
_peek
protected int _peek
-
_sbuf
protected java.lang.StringBuffer _sbuf
-
_entityBuffer
protected java.lang.StringBuffer _entityBuffer
-
_utcCalendar
protected java.util.Calendar _utcCalendar
-
_localCalendar
protected java.util.Calendar _localCalendar
-
-
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 burlap 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.
-
startCall
public void startCall() throws java.io.IOExceptionStarts reading the call<burlap:call> <method>method</method>
- Specified by:
startCallin classAbstractHessianInput- Throws:
java.io.IOException
-
readCall
public int readCall() throws java.io.IOExceptionStarts reading the callA successful completion will have a single value:
<burlap:call>
- Specified by:
readCallin classAbstractHessianInput- Throws:
java.io.IOException
-
readMethod
public java.lang.String readMethod() throws java.io.IOExceptionReads the method<method>method</method>
- Specified by:
readMethodin classAbstractHessianInput- Throws:
java.io.IOException
-
completeCall
public void completeCall() throws java.io.IOExceptionCompletes reading the callA successful completion will have a single value:
</burlap:call>
- 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:
<burlap:reply> <value>
- Specified by:
startReplyin classAbstractHessianInput- Throws:
java.lang.Throwable
-
completeReply
public void completeReply() throws java.io.IOExceptionCompletes reading the callA successful completion will have a single value:
</burlap:reply>
- Specified by:
completeReplyin classAbstractHessianInput- Throws:
java.io.IOException
-
readHeader
public java.lang.String readHeader() throws java.io.IOExceptionReads a header, returning null if there are no headers.<header>value</header>
- Specified by:
readHeaderin classAbstractHessianInput- Throws:
java.io.IOException
-
readNull
public void readNull() throws java.io.IOExceptionReads a null<null></null>
- Specified by:
readNullin classAbstractHessianInput- Throws:
java.io.IOException
-
readBoolean
public boolean readBoolean() throws java.io.IOExceptionReads a boolean<boolean>0</boolean> <boolean>1</boolean>
- Specified by:
readBooleanin classAbstractHessianInput- Throws:
java.io.IOException
-
readByte
public byte readByte() throws java.io.IOExceptionReads a byte<int>value</int>
- Throws:
java.io.IOException
-
readShort
public short readShort() throws java.io.IOExceptionReads a short<int>value</int>
- Throws:
java.io.IOException
-
readInt
public int readInt() throws java.io.IOExceptionReads an integer<int>value</int>
- Specified by:
readIntin classAbstractHessianInput- Throws:
java.io.IOException
-
readLong
public long readLong() throws java.io.IOExceptionReads a long<long>value</long>
- Specified by:
readLongin classAbstractHessianInput- Throws:
java.io.IOException
-
readFloat
public float readFloat() throws java.io.IOExceptionReads a float<double>value</double>
- Throws:
java.io.IOException
-
readDouble
public double readDouble() throws java.io.IOExceptionReads a double<double>value</double>
- Specified by:
readDoublein classAbstractHessianInput- Throws:
java.io.IOException
-
readUTCDate
public long readUTCDate() throws java.io.IOExceptionReads a date.<date>ISO-8609 date</date>
- Specified by:
readUTCDatein classAbstractHessianInput- Throws:
java.io.IOException
-
readLocalDate
public long readLocalDate() throws java.io.IOExceptionReads a date.<date>ISO-8609 date</date>
- Throws:
java.io.IOException
-
readString
public java.lang.String readString() throws java.io.IOExceptionReads a string<string>value</string>
- Specified by:
readStringin classAbstractHessianInput- Throws:
java.io.IOException
-
readNode
public org.w3c.dom.Node readNode() throws java.io.IOExceptionReads an XML node.&xml;xml string</xml>
- Overrides:
readNodein classAbstractHessianInput- Throws:
java.io.IOException
-
readBytes
public byte[] readBytes() throws java.io.IOExceptionReads a byte array<base64>...</base64>
- Specified by:
readBytesin classAbstractHessianInput- Throws:
java.io.IOException
-
readLength
public int readLength() throws java.io.IOExceptionReads a length<length>value</length>
- Specified by:
readLengthin classAbstractHessianInput- 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 map.- 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 of the map- Specified by:
readMapEndin classAbstractHessianInput- Throws:
java.io.IOException
-
readListEnd
public void readListEnd() throws java.io.IOExceptionReads the end of the map- 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
-
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.<type>type</type>
- Specified by:
readTypein classAbstractHessianInput- Throws:
java.io.IOException
-
parseDate
protected long parseDate() throws java.io.IOExceptionParses a date value from the stream.- Throws:
java.io.IOException
-
parseDate
protected long parseDate(java.util.Calendar calendar) throws java.io.IOExceptionParses a date value from the stream.- Throws:
java.io.IOException
-
parseString
protected java.lang.String parseString() throws java.io.IOException- Throws:
java.io.IOException
-
parseString
protected java.lang.StringBuffer parseString(java.lang.StringBuffer sbuf) throws java.io.IOExceptionParses a string value from the stream. The burlap object's string buffer is used for the result.- Throws:
java.io.IOException
-
parseBytes
protected byte[] parseBytes() throws java.io.IOExceptionParses a byte array.- Throws:
java.io.IOException
-
parseBytes
protected java.io.ByteArrayOutputStream parseBytes(java.io.ByteArrayOutputStream bos) throws java.io.IOExceptionParses a byte array.- Throws:
java.io.IOException
-
expectTag
public void expectTag(int expectTag) throws java.io.IOException- Throws:
java.io.IOException
-
parseTag
protected int parseTag() throws java.io.IOExceptionParses a tag. Returns true if it's a start tag.- Throws:
java.io.IOException
-
skipWhitespace
protected int skipWhitespace() throws java.io.IOException- Throws:
java.io.IOException
-
isWhitespace
protected boolean isWhitespace(int ch) throws java.io.IOException- Throws:
java.io.IOException
-
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
-
readInputStream
public java.io.InputStream readInputStream()
Description copied from class:AbstractHessianInputStarts reading a byte array using an input stream. All the bytes must be read before calling the following method.b b16 b8 non-final binary chunk B b16 b8 final binary chunk
- Specified by:
readInputStreamin classAbstractHessianInput
-
getInputStream
public java.io.InputStream getInputStream()
-
expectBeginTag
protected java.io.IOException expectBeginTag(java.lang.String expect, java.lang.String tag)
-
expectedChar
protected java.io.IOException expectedChar(java.lang.String expect, int ch)
-
expectedTag
protected java.io.IOException expectedTag(java.lang.String expect, int tag)
-
error
protected java.io.IOException error(java.lang.String message)
-
tagName
protected static java.lang.String tagName(int tag)
-
-