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 StringBuffer_entityBufferprotected Calendar_localCalendarprotected int_peekprotected ArrayList_refsprotected StringBuffer_sbufprotected SerializerFactory_serializerFactoryprotected 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(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(Object ref)Adds a list/map reference.voidcompleteCall()Completes reading the callvoidcompleteReply()Completes reading the callprotected IOExceptionerror(String message)protected IOExceptionexpectBeginTag(String expect, String tag)protected IOExceptionexpectedChar(String expect, int ch)protected IOExceptionexpectedTag(String expect, int tag)voidexpectTag(int expectTag)InputStreamgetInputStream()StringgetMethod()Returns the calls methodReadergetReader()Starts reading a string.ThrowablegetReplyFault()Returns any reply fault.SerializerFactorygetSerializerFactory()Gets the serializer factory.voidinit(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 ByteArrayOutputStreamparseBytes(ByteArrayOutputStream bos)Parses a byte array.protected longparseDate()Parses a date value from the stream.protected longparseDate(Calendar calendar)Parses a date value from the stream.protected StringparseString()protected StringBufferparseString(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 floatStringreadHeader()Reads a header, returning null if there are no headers.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.StringreadMethod()Reads the methodNodereadNode()Reads an XML node.voidreadNull()Reads a nullObjectreadObject()Reads an arbitrary object from the input stream when the type is unknown.ObjectreadObject(Class cl)Reads an object from the input stream with an expected type.ObjectreadRef()Reads a reference.ObjectreadRemote()Reads a remote object.ObjectreadReply(Class expectedClass)Reads a reply as an object.shortreadShort()Reads a shortStringreadString()Reads a stringStringreadType()Parses a type from the stream.longreadUTCDate()Reads a date.ObjectresolveRemote(String type, String url)Resolves a remote object.voidsetRef(int i, 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 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 ArrayList _refs
-
_peek
protected int _peek
-
_sbuf
protected StringBuffer _sbuf
-
_entityBuffer
protected StringBuffer _entityBuffer
-
_utcCalendar
protected Calendar _utcCalendar
-
_localCalendar
protected Calendar _localCalendar
-
-
Constructor Detail
-
BurlapInput
public BurlapInput()
Creates an uninitialized Burlap input stream.
-
BurlapInput
public BurlapInput(InputStream is)
Creates a new Burlap input stream, initialized with an underlying input stream.- Parameters:
is- the underlying input stream.
-
-
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(InputStream is)
Initialize the burlap stream with the underlying input stream.- Overrides:
initin classAbstractHessianInput
-
getMethod
public String getMethod()
Returns the calls method- Specified by:
getMethodin classAbstractHessianInput
-
getReplyFault
public Throwable getReplyFault()
Returns any reply fault.
-
startCall
public void startCall() throws IOExceptionStarts reading the call<burlap:call> <method>method</method>
- Specified by:
startCallin classAbstractHessianInput- Throws:
IOException
-
readCall
public int readCall() throws IOExceptionStarts reading the callA successful completion will have a single value:
<burlap:call>
- Specified by:
readCallin classAbstractHessianInput- Throws:
IOException
-
readMethod
public String readMethod() throws IOException
Reads the method<method>method</method>
- Specified by:
readMethodin classAbstractHessianInput- Throws:
IOException
-
completeCall
public void completeCall() throws IOExceptionCompletes reading the callA successful completion will have a single value:
</burlap:call>
- Specified by:
completeCallin classAbstractHessianInput- Throws:
IOException
-
readReply
public Object readReply(Class expectedClass) throws Throwable
Reads a reply as an object. If the reply has a fault, throws the exception.- Specified by:
readReplyin classAbstractHessianInput- Throws:
Throwable
-
startReply
public void startReply() throws ThrowableStarts reading the replyA successful completion will have a single value:
<burlap:reply> <value>
- Specified by:
startReplyin classAbstractHessianInput- Throws:
Throwable
-
completeReply
public void completeReply() throws IOExceptionCompletes reading the callA successful completion will have a single value:
</burlap:reply>
- Specified by:
completeReplyin classAbstractHessianInput- Throws:
IOException
-
readHeader
public String readHeader() throws IOException
Reads a header, returning null if there are no headers.<header>value</header>
- Specified by:
readHeaderin classAbstractHessianInput- Throws:
IOException
-
readNull
public void readNull() throws IOExceptionReads a null<null></null>
- Specified by:
readNullin classAbstractHessianInput- Throws:
IOException
-
readBoolean
public boolean readBoolean() throws IOExceptionReads a boolean<boolean>0</boolean> <boolean>1</boolean>
- Specified by:
readBooleanin classAbstractHessianInput- Throws:
IOException
-
readByte
public byte readByte() throws IOExceptionReads a byte<int>value</int>
- Throws:
IOException
-
readShort
public short readShort() throws IOExceptionReads a short<int>value</int>
- Throws:
IOException
-
readInt
public int readInt() throws IOExceptionReads an integer<int>value</int>
- Specified by:
readIntin classAbstractHessianInput- Throws:
IOException
-
readLong
public long readLong() throws IOExceptionReads a long<long>value</long>
- Specified by:
readLongin classAbstractHessianInput- Throws:
IOException
-
readFloat
public float readFloat() throws IOExceptionReads a float<double>value</double>
- Throws:
IOException
-
readDouble
public double readDouble() throws IOExceptionReads a double<double>value</double>
- Specified by:
readDoublein classAbstractHessianInput- Throws:
IOException
-
readUTCDate
public long readUTCDate() throws IOExceptionReads a date.<date>ISO-8609 date</date>
- Specified by:
readUTCDatein classAbstractHessianInput- Throws:
IOException
-
readLocalDate
public long readLocalDate() throws IOExceptionReads a date.<date>ISO-8609 date</date>
- Throws:
IOException
-
readString
public String readString() throws IOException
Reads a string<string>value</string>
- Specified by:
readStringin classAbstractHessianInput- Throws:
IOException
-
readNode
public Node readNode() throws IOException
Reads an XML node.&xml;xml string</xml>
- Overrides:
readNodein classAbstractHessianInput- Throws:
IOException
-
readBytes
public byte[] readBytes() throws IOExceptionReads a byte array<base64>...</base64>
- Specified by:
readBytesin classAbstractHessianInput- Throws:
IOException
-
readLength
public int readLength() throws IOExceptionReads a length<length>value</length>
- Specified by:
readLengthin classAbstractHessianInput- Throws:
IOException
-
readObject
public Object readObject(Class cl) throws IOException
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
public Object readObject() throws IOException
Reads an arbitrary object from the input stream when the type is unknown.- Specified by:
readObjectin classAbstractHessianInput- Throws:
IOException
-
readRemote
public Object readRemote() throws IOException
Reads a remote object.- Specified by:
readRemotein classAbstractHessianInput- Throws:
IOException
-
readRef
public Object readRef() throws IOException
Reads a reference.- Specified by:
readRefin classAbstractHessianInput- Throws:
IOException
-
readListStart
public int readListStart() throws IOExceptionReads the start of a list.- Specified by:
readListStartin classAbstractHessianInput- Throws:
IOException
-
readMapStart
public int readMapStart() throws IOExceptionReads the start of a map.- Specified by:
readMapStartin classAbstractHessianInput- Throws:
IOException
-
isEnd
public boolean isEnd() throws IOExceptionReturns true if this is the end of a list or a map.- Specified by:
isEndin classAbstractHessianInput- Throws:
IOException
-
readEnd
public void readEnd() throws IOExceptionReads the end byte.- Specified by:
readEndin classAbstractHessianInput- Throws:
IOException
-
readMapEnd
public void readMapEnd() throws IOExceptionReads the end of the map- Specified by:
readMapEndin classAbstractHessianInput- Throws:
IOException
-
readListEnd
public void readListEnd() throws IOExceptionReads the end of the map- Specified by:
readListEndin classAbstractHessianInput- Throws:
IOException
-
addRef
public int addRef(Object ref)
Adds a list/map reference.- Specified by:
addRefin classAbstractHessianInput
-
setRef
public void setRef(int i, Object ref)Adds a list/map reference.- Specified by:
setRefin classAbstractHessianInput
-
resolveRemote
public Object resolveRemote(String type, String url) throws IOException
Resolves a remote object.- Throws:
IOException
-
readType
public String readType() throws IOException
Parses a type from the stream.<type>type</type>
- Specified by:
readTypein classAbstractHessianInput- Throws:
IOException
-
parseDate
protected long parseDate() throws IOExceptionParses a date value from the stream.- Throws:
IOException
-
parseDate
protected long parseDate(Calendar calendar) throws IOException
Parses a date value from the stream.- Throws:
IOException
-
parseString
protected String parseString() throws IOException
- Throws:
IOException
-
parseString
protected StringBuffer parseString(StringBuffer sbuf) throws IOException
Parses a string value from the stream. The burlap object's string buffer is used for the result.- Throws:
IOException
-
parseBytes
protected byte[] parseBytes() throws IOExceptionParses a byte array.- Throws:
IOException
-
parseBytes
protected ByteArrayOutputStream parseBytes(ByteArrayOutputStream bos) throws IOException
Parses a byte array.- Throws:
IOException
-
expectTag
public void expectTag(int expectTag) throws IOException- Throws:
IOException
-
parseTag
protected int parseTag() throws IOExceptionParses a tag. Returns true if it's a start tag.- Throws:
IOException
-
skipWhitespace
protected int skipWhitespace() throws IOException- Throws:
IOException
-
isWhitespace
protected boolean isWhitespace(int ch) throws IOException- Throws:
IOException
-
getReader
public 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 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 InputStream getInputStream()
-
expectBeginTag
protected IOException expectBeginTag(String expect, String tag)
-
expectedChar
protected IOException expectedChar(String expect, int ch)
-
expectedTag
protected IOException expectedTag(String expect, int tag)
-
error
protected IOException error(String message)
-
tagName
protected static String tagName(int tag)
-
-