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  StringBuffer _entityBuffer
           
protected  Calendar _localCalendar
           
protected  int _peek
           
protected  ArrayList _refs
           
protected  StringBuffer _sbuf
           
protected  SerializerFactory _serializerFactory
           
protected  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(InputStream is)
          Creates a new Burlap input stream, initialized with an underlying input stream.
 
Method Summary
 int addRef(Object ref)
          Adds a list/map reference.
 void completeCall()
          Completes reading the call A successful completion will have a single value: </burlap:call>
 void completeReply()
          Completes reading the call A successful completion will have a single value: </burlap:reply>
protected  IOException error(String message)
           
protected  IOException expectBeginTag(String expect, String tag)
           
protected  IOException expectedChar(String expect, int ch)
           
protected  IOException expectedTag(String expect, int tag)
           
 void expectTag(int expectTag)
           
 InputStream getInputStream()
           
 String getMethod()
          Returns the calls method
 Reader getReader()
          Starts reading a string.
 Throwable getReplyFault()
          Returns any reply fault.
 SerializerFactory getSerializerFactory()
          Gets the serializer factory.
 void init(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  ByteArrayOutputStream parseBytes(ByteArrayOutputStream bos)
          Parses a byte array.
protected  long parseDate()
          Parses a date value from the stream.
protected  long parseDate(Calendar calendar)
          Parses a date value from the stream.
protected  String parseString()
           
protected  StringBuffer parseString(StringBuffer sbuf)
          Parses a string value from the stream.
protected  int parseTag()
          Parses a tag.
 boolean readBoolean()
          Reads a boolean <boolean>0</boolean> <boolean>1</boolean>
 byte readByte()
          Reads a byte <int>value</int>
 byte[] readBytes()
          Reads a byte array <base64>...
 int readCall()
          Starts reading the call A successful completion will have a single value: <burlap:call>
 double readDouble()
          Reads a double <double>value</double>
 void readEnd()
          Reads the end byte.
 float readFloat()
          Reads a float <double>value</double>
 String readHeader()
          Reads a header, returning null if there are no headers.
 InputStream readInputStream()
          Starts reading a byte array using an input stream.
 int readInt()
          Reads an integer <int>value</int>
 int readLength()
          Reads a length <length>value</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 <long>value</long>
 void readMapEnd()
          Reads the end of the map
 int readMapStart()
          Reads the start of a map.
 String readMethod()
          Reads the method <method>method</method>
 Node readNode()
          Reads an XML node.
 void readNull()
          Reads a null <null></null>
 Object readObject()
          Reads an arbitrary object from the input stream when the type is unknown.
 Object readObject(Class cl)
          Reads an object from the input stream with an expected type.
 Object readRef()
          Reads a reference.
 Object readRemote()
          Reads a remote object.
 Object readReply(Class expectedClass)
          Reads a reply as an object.
 short readShort()
          Reads a short <int>value</int>
 String readString()
          Reads a string <string>value</string>
 String readType()
          Parses a type from the stream.
 long readUTCDate()
          Reads a date.
 Object resolveRemote(String type, String url)
          Resolves a remote object.
 void setRef(int i, Object ref)
          Adds a list/map reference.
 void setSerializerFactory(SerializerFactory factory)
          Sets the serializer factory.
protected  int skipWhitespace()
           
 void startCall()
          Starts reading the call <burlap:call> <method>method</method>
 void startReply()
          Starts reading the reply A successful completion will have a single value: <burlap:reply> <value>
protected static 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 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:
setSerializerFactory in class AbstractHessianInput

getSerializerFactory

public SerializerFactory getSerializerFactory()
Gets the serializer factory.


init

public void init(InputStream is)
Initialize the burlap stream with the underlying input stream.

Overrides:
init in class AbstractHessianInput

getMethod

public String getMethod()
Returns the calls method

Specified by:
getMethod in class AbstractHessianInput

getReplyFault

public Throwable getReplyFault()
Returns any reply fault.


startCall

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

Specified by:
startCall in class AbstractHessianInput
Throws:
IOException

readCall

public int readCall()
             throws IOException
Starts reading the call

A successful completion will have a single value:

 <burlap:call>
 

Specified by:
readCall in class AbstractHessianInput
Throws:
IOException

readMethod

public String readMethod()
                  throws IOException
Reads the method
 <method>method</method>
 

Specified by:
readMethod in class AbstractHessianInput
Throws:
IOException

completeCall

public void completeCall()
                  throws IOException
Completes reading the call

A successful completion will have a single value:

 </burlap:call>
 

Specified by:
completeCall in class AbstractHessianInput
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:
readReply in class AbstractHessianInput
Throws:
Throwable

startReply

public void startReply()
                throws Throwable
Starts reading the reply

A successful completion will have a single value:

 <burlap:reply>
 <value>
 

Specified by:
startReply in class AbstractHessianInput
Throws:
Throwable

completeReply

public void completeReply()
                   throws IOException
Completes reading the call

A successful completion will have a single value:

 </burlap:reply>
 

Specified by:
completeReply in class AbstractHessianInput
Throws:
IOException

readHeader

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

Specified by:
readHeader in class AbstractHessianInput
Throws:
IOException

readNull

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

Specified by:
readNull in class AbstractHessianInput
Throws:
IOException

readBoolean

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

Specified by:
readBoolean in class AbstractHessianInput
Throws:
IOException

readByte

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

Throws:
IOException

readShort

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

Throws:
IOException

readInt

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

Specified by:
readInt in class AbstractHessianInput
Throws:
IOException

readLong

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

Specified by:
readLong in class AbstractHessianInput
Throws:
IOException

readFloat

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

Throws:
IOException

readDouble

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

Specified by:
readDouble in class AbstractHessianInput
Throws:
IOException

readUTCDate

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

Specified by:
readUTCDate in class AbstractHessianInput
Throws:
IOException

readLocalDate

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

Throws:
IOException

readString

public String readString()
                  throws IOException
Reads a string
 <string>value</string>
 

Specified by:
readString in class AbstractHessianInput
Throws:
IOException

readNode

public Node readNode()
              throws IOException
Reads an XML node.
 &xml;xml string</xml>
 

Overrides:
readNode in class AbstractHessianInput
Throws:
IOException

readBytes

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

Specified by:
readBytes in class AbstractHessianInput
Throws:
IOException

readLength

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

Specified by:
readLength in class AbstractHessianInput
Throws:
IOException

readObject

public Object readObject(Class cl)
                  throws 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:
IOException

readObject

public Object readObject()
                  throws IOException
Reads an arbitrary object from the input stream when the type is unknown.

Specified by:
readObject in class AbstractHessianInput
Throws:
IOException

readRemote

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

Specified by:
readRemote in class AbstractHessianInput
Throws:
IOException

readRef

public Object readRef()
               throws IOException
Reads a reference.

Specified by:
readRef in class AbstractHessianInput
Throws:
IOException

readListStart

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

Specified by:
readListStart in class AbstractHessianInput
Throws:
IOException

readMapStart

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

Specified by:
readMapStart in class AbstractHessianInput
Throws:
IOException

isEnd

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

Specified by:
isEnd in class AbstractHessianInput
Throws:
IOException

readEnd

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

Specified by:
readEnd in class AbstractHessianInput
Throws:
IOException

readMapEnd

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

Specified by:
readMapEnd in class AbstractHessianInput
Throws:
IOException

readListEnd

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

Specified by:
readListEnd in class AbstractHessianInput
Throws:
IOException

addRef

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

Specified by:
addRef in class AbstractHessianInput

setRef

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

Specified by:
setRef in class AbstractHessianInput

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:
readType in class AbstractHessianInput
Throws:
IOException

parseDate

protected long parseDate()
                  throws IOException
Parses 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 IOException
Parses 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 IOException
Parses 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: 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 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 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)


Copyright © 2013. All Rights Reserved.