com.caucho.burlap.io
Class BurlapInput

java.lang.Object
  extended by com.caucho.hessian.io.AbstractHessianInput
      extended by com.caucho.burlap.io.AbstractBurlapInput
          extended by 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
protected  java.lang.StringBuffer _entityBuffer
           
protected  java.util.Calendar _localCalendar
           
protected  int _peek
           
protected  java.util.ArrayList _refs
           
protected  java.lang.StringBuffer _sbuf
           
protected  SerializerFactory _serializerFactory
           
protected  java.util.Calendar _utcCalendar
           
static int TAG_BASE64
           
static int TAG_BASE64_END
           
static int TAG_BOOLEAN
           
static int TAG_BOOLEAN_END
           
static int TAG_CALL
           
static int TAG_CALL_END
           
static int TAG_DATE
           
static int TAG_DATE_END
           
static int TAG_DOUBLE
           
static int TAG_DOUBLE_END
           
static int TAG_EOF
           
static int TAG_FAULT
           
static int TAG_FAULT_END
           
static int TAG_HEADER
           
static int TAG_HEADER_END
           
static int TAG_INT
           
static int TAG_INT_END
           
static int TAG_LENGTH
           
static int TAG_LENGTH_END
           
static int TAG_LIST
           
static int TAG_LIST_END
           
static int TAG_LONG
           
static int TAG_LONG_END
           
static int TAG_MAP
           
static int TAG_MAP_END
           
static int TAG_METHOD
           
static int TAG_METHOD_END
           
static int TAG_NULL
           
static int TAG_NULL_END
           
static int TAG_REF
           
static int TAG_REF_END
           
static int TAG_REMOTE
           
static int TAG_REMOTE_END
           
static int TAG_REPLY
           
static int TAG_REPLY_END
           
static int TAG_STRING
           
static int TAG_STRING_END
           
static int TAG_TYPE
           
static int TAG_TYPE_END
           
static int TAG_XML
           
static int TAG_XML_END
           
 
Constructor Summary
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
 int addRef(java.lang.Object ref)
          Adds a list/map reference.
 void completeCall()
          Completes reading the call
 void completeReply()
          Completes reading the call
protected  java.io.IOException error(java.lang.String message)
           
protected  java.io.IOException expectBeginTag(java.lang.String expect, java.lang.String tag)
           
protected  java.io.IOException expectedChar(java.lang.String expect, int ch)
           
protected  java.io.IOException expectedTag(java.lang.String expect, int tag)
           
 void expectTag(int expectTag)
           
 java.io.InputStream getInputStream()
           
 java.lang.String getMethod()
          Returns the calls method
 java.io.Reader getReader()
          Starts reading a string.
 java.lang.Throwable getReplyFault()
          Returns any reply fault.
 SerializerFactory getSerializerFactory()
          Gets the serializer factory.
 void init(java.io.InputStream is)
          Initialize the burlap stream with the underlying input stream.
 boolean isEnd()
          Returns true if this is the end of a list or a map.
protected  boolean isWhitespace(int ch)
           
protected  byte[] parseBytes()
          Parses a byte array.
protected  java.io.ByteArrayOutputStream parseBytes(java.io.ByteArrayOutputStream bos)
          Parses a byte array.
protected  long parseDate()
          Parses a date value from the stream.
protected  long parseDate(java.util.Calendar calendar)
          Parses a date value from the stream.
protected  java.lang.String parseString()
           
protected  java.lang.StringBuffer parseString(java.lang.StringBuffer sbuf)
          Parses a string value from the stream.
protected  int parseTag()
          Parses a tag.
 boolean readBoolean()
          Reads a boolean
 byte readByte()
          Reads a byte
 byte[] readBytes()
          Reads a byte array
 int readCall()
          Starts reading the call
 double readDouble()
          Reads a double
 void readEnd()
          Reads the end byte.
 float readFloat()
          Reads a float
 java.lang.String readHeader()
          Reads a header, returning null if there are no headers.
 java.io.InputStream readInputStream()
          Starts reading a byte array using an input stream.
 int readInt()
          Reads an integer
 int readLength()
          Reads a length
 void readListEnd()
          Reads the end of the map
 int readListStart()
          Reads the start of a list.
 long readLocalDate()
          Reads a date.
 long readLong()
          Reads a long
 void readMapEnd()
          Reads the end of the map
 int readMapStart()
          Reads the start of a map.
 java.lang.String readMethod()
          Reads the method
 org.w3c.dom.Node readNode()
          Reads an XML node.
 void readNull()
          Reads a null
 java.lang.Object readObject()
          Reads an arbitrary object from the input stream when the type is unknown.
 java.lang.Object readObject(java.lang.Class cl)
          Reads an object from the input stream with an expected type.
 java.lang.Object readRef()
          Reads a reference.
 java.lang.Object readRemote()
          Reads a remote object.
 java.lang.Object readReply(java.lang.Class expectedClass)
          Reads a reply as an object.
 short readShort()
          Reads a short
 java.lang.String readString()
          Reads a string
 java.lang.String readType()
          Parses a type from the stream.
 long readUTCDate()
          Reads a date.
 java.lang.Object resolveRemote(java.lang.String type, java.lang.String url)
          Resolves a remote object.
 void setRef(int i, java.lang.Object ref)
          Adds a list/map reference.
 void setSerializerFactory(SerializerFactory factory)
          Sets the serializer factory.
protected  int skipWhitespace()
           
 void startCall()
          Starts reading the call
 void startReply()
          Starts reading the reply
protected static java.lang.String tagName(int tag)
           
 
Methods inherited from class com.caucho.hessian.io.AbstractHessianInput
close, getRemoteResolver, readMethodArgLength, readToOutputStream, resetReferences, setRemoteResolver, skipOptionalCall, startReplyBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Constructor Detail

BurlapInput

public BurlapInput()
Creates an uninitialized Burlap input stream.


BurlapInput

public BurlapInput(java.io.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:
setSerializerFactory in class AbstractHessianInput

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:
init in class AbstractHessianInput

getMethod

public java.lang.String getMethod()
Returns the calls method

Specified by:
getMethod in class AbstractHessianInput

getReplyFault

public java.lang.Throwable getReplyFault()
Returns any reply fault.


startCall

public void startCall()
               throws java.io.IOException
Starts reading the call
 <burlap:call>
 <method>method</method>
 

Specified by:
startCall in class AbstractHessianInput
Throws:
java.io.IOException

readCall

public int readCall()
             throws java.io.IOException
Starts reading the call

A successful completion will have a single value:

 <burlap:call>
 

Specified by:
readCall in class AbstractHessianInput
Throws:
java.io.IOException

readMethod

public java.lang.String readMethod()
                            throws java.io.IOException
Reads the method
 <method>method</method>
 

Specified by:
readMethod in class AbstractHessianInput
Throws:
java.io.IOException

completeCall

public void completeCall()
                  throws java.io.IOException
Completes reading the call

A successful completion will have a single value:

 </burlap:call>
 

Specified by:
completeCall in class AbstractHessianInput
Throws:
java.io.IOException

readReply

public java.lang.Object readReply(java.lang.Class expectedClass)
                           throws java.lang.Throwable
Reads a reply as an object. If the reply has a fault, throws the exception.

Specified by:
readReply in class AbstractHessianInput
Throws:
java.lang.Throwable

startReply

public void startReply()
                throws java.lang.Throwable
Starts reading the reply

A successful completion will have a single value:

 <burlap:reply>
 <value>
 

Specified by:
startReply in class AbstractHessianInput
Throws:
java.lang.Throwable

completeReply

public void completeReply()
                   throws java.io.IOException
Completes reading the call

A successful completion will have a single value:

 </burlap:reply>
 

Specified by:
completeReply in class AbstractHessianInput
Throws:
java.io.IOException

readHeader

public java.lang.String readHeader()
                            throws java.io.IOException
Reads a header, returning null if there are no headers.
 <header>value</header>
 

Specified by:
readHeader in class AbstractHessianInput
Throws:
java.io.IOException

readNull

public void readNull()
              throws java.io.IOException
Reads a null
 <null></null>
 

Specified by:
readNull in class AbstractHessianInput
Throws:
java.io.IOException

readBoolean

public boolean readBoolean()
                    throws java.io.IOException
Reads a boolean
 <boolean>0</boolean>
 <boolean>1</boolean>
 

Specified by:
readBoolean in class AbstractHessianInput
Throws:
java.io.IOException

readByte

public byte readByte()
              throws java.io.IOException
Reads a byte
 <int>value</int>
 

Throws:
java.io.IOException

readShort

public short readShort()
                throws java.io.IOException
Reads a short
 <int>value</int>
 

Throws:
java.io.IOException

readInt

public int readInt()
            throws java.io.IOException
Reads an integer
 <int>value</int>
 

Specified by:
readInt in class AbstractHessianInput
Throws:
java.io.IOException

readLong

public long readLong()
              throws java.io.IOException
Reads a long
 <long>value</long>
 

Specified by:
readLong in class AbstractHessianInput
Throws:
java.io.IOException

readFloat

public float readFloat()
                throws java.io.IOException
Reads a float
 <double>value</double>
 

Throws:
java.io.IOException

readDouble

public double readDouble()
                  throws java.io.IOException
Reads a double
 <double>value</double>
 

Specified by:
readDouble in class AbstractHessianInput
Throws:
java.io.IOException

readUTCDate

public long readUTCDate()
                 throws java.io.IOException
Reads a date.
 <date>ISO-8609 date</date>
 

Specified by:
readUTCDate in class AbstractHessianInput
Throws:
java.io.IOException

readLocalDate

public long readLocalDate()
                   throws java.io.IOException
Reads a date.
 <date>ISO-8609 date</date>
 

Throws:
java.io.IOException

readString

public java.lang.String readString()
                            throws java.io.IOException
Reads a string
 <string>value</string>
 

Specified by:
readString in class AbstractHessianInput
Throws:
java.io.IOException

readNode

public org.w3c.dom.Node readNode()
                          throws java.io.IOException
Reads an XML node.
 &xml;xml string</xml>
 

Overrides:
readNode in class AbstractHessianInput
Throws:
java.io.IOException

readBytes

public byte[] readBytes()
                 throws java.io.IOException
Reads a byte array
 <base64>...</base64>
 

Specified by:
readBytes in class AbstractHessianInput
Throws:
java.io.IOException

readLength

public int readLength()
               throws java.io.IOException
Reads a length
 <length>value</length>
 

Specified by:
readLength in class AbstractHessianInput
Throws:
java.io.IOException

readObject

public java.lang.Object readObject(java.lang.Class cl)
                            throws java.io.IOException
Reads an object from the input stream with an expected type.

Specified by:
readObject in class AbstractHessianInput
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.IOException
Reads an arbitrary object from the input stream when the type is unknown.

Specified by:
readObject in class AbstractHessianInput
Throws:
java.io.IOException

readRemote

public java.lang.Object readRemote()
                            throws java.io.IOException
Reads a remote object.

Specified by:
readRemote in class AbstractHessianInput
Throws:
java.io.IOException

readRef

public java.lang.Object readRef()
                         throws java.io.IOException
Reads a reference.

Specified by:
readRef in class AbstractHessianInput
Throws:
java.io.IOException

readListStart

public int readListStart()
                  throws java.io.IOException
Reads the start of a list.

Specified by:
readListStart in class AbstractHessianInput
Throws:
java.io.IOException

readMapStart

public int readMapStart()
                 throws java.io.IOException
Reads the start of a map.

Specified by:
readMapStart in class AbstractHessianInput
Throws:
java.io.IOException

isEnd

public boolean isEnd()
              throws java.io.IOException
Returns true if this is the end of a list or a map.

Specified by:
isEnd in class AbstractHessianInput
Throws:
java.io.IOException

readEnd

public void readEnd()
             throws java.io.IOException
Reads the end byte.

Specified by:
readEnd in class AbstractHessianInput
Throws:
java.io.IOException

readMapEnd

public void readMapEnd()
                throws java.io.IOException
Reads the end of the map

Specified by:
readMapEnd in class AbstractHessianInput
Throws:
java.io.IOException

readListEnd

public void readListEnd()
                 throws java.io.IOException
Reads the end of the map

Specified by:
readListEnd in class AbstractHessianInput
Throws:
java.io.IOException

addRef

public int addRef(java.lang.Object ref)
Adds a list/map reference.

Specified by:
addRef in class AbstractHessianInput

setRef

public void setRef(int i,
                   java.lang.Object ref)
Adds a list/map reference.

Specified by:
setRef in class AbstractHessianInput

resolveRemote

public java.lang.Object resolveRemote(java.lang.String type,
                                      java.lang.String url)
                               throws java.io.IOException
Resolves a remote object.

Throws:
java.io.IOException

readType

public java.lang.String readType()
                          throws java.io.IOException
Parses a type from the stream.
 <type>type</type>
 

Specified by:
readType in class AbstractHessianInput
Throws:
java.io.IOException

parseDate

protected long parseDate()
                  throws java.io.IOException
Parses a date value from the stream.

Throws:
java.io.IOException

parseDate

protected long parseDate(java.util.Calendar calendar)
                  throws java.io.IOException
Parses 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.IOException
Parses 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.IOException
Parses a byte array.

Throws:
java.io.IOException

parseBytes

protected java.io.ByteArrayOutputStream parseBytes(java.io.ByteArrayOutputStream bos)
                                            throws java.io.IOException
Parses 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.IOException
Parses 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: 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 class AbstractHessianInput

readInputStream

public java.io.InputStream readInputStream()
Description copied from class: AbstractHessianInput
Starts 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:
readInputStream in class AbstractHessianInput

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)