Class MicroBurlapInput

java.lang.Object
com.caucho.burlap.client.MicroBurlapInput

public class MicroBurlapInput extends Object
Input stream for Burlap requests, compatible with microedition Java. It only uses classes and types available to J2ME. In particular, it does not have any support for the <double> type.

MicroBurlapInput does not depend on any classes other than in J2ME, so it can be extracted independently into a smaller package.

MicroBurlapInput is unbuffered, so any client needs to provide its own buffering.

 InputStream is = ...; // from http connection
 MicroBurlapInput in = new MicroBurlapInput(is);
 String value;

 in.startReply();         // read reply header
 value = in.readString(); // read string value
 in.completeReply();      // read reply footer
 
  • Field Details

    • peek

      protected int peek
    • peekTag

      protected boolean peekTag
    • date

      protected Date date
    • utcCalendar

      protected Calendar utcCalendar
    • refs

      protected Vector refs
    • method

      protected String method
    • sbuf

      protected StringBuffer sbuf
    • entity

      protected StringBuffer entity
  • Constructor Details

    • MicroBurlapInput

      public MicroBurlapInput(InputStream is)
      Creates a new Burlap input stream, initialized with an underlying input stream.
      Parameters:
      is - the underlying input stream.
    • MicroBurlapInput

      public MicroBurlapInput()
      Creates an uninitialized Burlap input stream.
  • Method Details

    • getMethod

      public String getMethod()
      Returns a call's method.
    • init

      public void init(InputStream is)
      Initialize the Burlap input stream with a new underlying stream. Applications can use init(InputStream) to reuse MicroBurlapInput to save garbage collection.
    • startCall

      public void startCall() throws IOException
      Starts reading the call

      A successful completion will have a single value:

       <burlap:call>
       <method>method</method>
       
      Throws:
      IOException
    • completeCall

      public void completeCall() throws IOException
      Completes reading the call.
       </burlap:call>
       
      Throws:
      IOException
    • readReply

      public Object readReply(Class expectedClass) throws Exception
      Reads a reply as an object. If the reply has a fault, throws the exception.
      Throws:
      Exception
    • startReply

      public boolean startReply() throws IOException
      Starts reading the reply.

      A successful completion will have a single value. An unsuccessful one will have a fault:

       <burlap:reply>
       
      Returns:
      true if success, false for fault.
      Throws:
      IOException
    • completeReply

      public void completeReply() throws IOException
      Completes reading the reply.
       </burlap:reply>
       
      Throws:
      IOException
    • readBoolean

      public boolean readBoolean() throws IOException
      Reads a boolean value from the input stream.
      Throws:
      IOException
    • readInt

      public int readInt() throws IOException
      Reads an integer value from the input stream.
      Throws:
      IOException
    • readLong

      public long readLong() throws IOException
      Reads a long value from the input stream.
      Throws:
      IOException
    • readUTCDate

      public long readUTCDate() throws IOException
      Reads a date value from the input stream.
      Throws:
      IOException
    • readLocalDate

      public long readLocalDate() throws IOException
      Reads a date value from the input stream.
      Throws:
      IOException
    • readRemote

      public BurlapRemote readRemote() throws IOException
      Reads a remote value from the input stream.
      Throws:
      IOException
    • readString

      public String readString() throws IOException
      Reads a string value from the input stream.

      The two valid possibilities are either a <null> or a <string>. The string value is encoded in utf-8, and understands the basic XML escapes: "&123;", "<", ">", "'", """.

       <null></null>
       <string>a utf-8 encoded string</string>
       
      Throws:
      IOException
    • readBytes

      public byte[] readBytes() throws IOException
      Reads a byte array from the input stream.

      The two valid possibilities are either a <null> or a <base64>.

      Throws:
      IOException
    • readObject

      public Object readObject(Class expectedClass) throws IOException
      Reads an arbitrary object the input stream.
      Throws:
      IOException
    • readType

      public String readType() throws IOException
      Reads a type value from the input stream.
       <type>a utf-8 encoded string</type>
       
      Throws:
      IOException
    • readLength

      public int readLength() throws IOException
      Reads a length value from the input stream. If the length isn't specified, returns -1.
       <length>integer</length>
       
      Throws:
      IOException
    • resolveRemote

      public Object resolveRemote(String type, String url) throws IOException
      Resolves a remote object.
      Throws:
      IOException
    • readFault

      public Hashtable readFault() throws IOException
      Reads a fault.
      Throws:
      IOException
    • readMap

      public Object readMap(Class expectedClass, String type) throws IOException
      Reads an object from the input stream.
      Parameters:
      expectedClass - the calling routine's expected class
      type - the type from the stream
      Throws:
      IOException
    • readExtensionObject

      protected Object readExtensionObject(Class expectedClass, String tag) throws IOException
      Reads object unknown to MicroBurlapInput.
      Throws:
      IOException
    • readList

      public Object readList(Class expectedClass, String type, int length) throws IOException
      Reads a list object from the input stream.
      Parameters:
      expectedClass - the calling routine's expected class
      type - the type from the stream
      length - the expected length, -1 for unspecified length
      Throws:
      IOException
    • parseInt

      protected int parseInt() throws IOException
      Parses an integer value from the stream.
      Throws:
      IOException
    • parseLong

      protected long parseLong() throws IOException
      Parses a long 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
      Parses a string value from the stream. string buffer is used for the result.
      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
    • expectStartTag

      protected void expectStartTag(String tag) throws IOException
      Throws:
      IOException
    • expectEndTag

      protected void expectEndTag(String tag) throws IOException
      Throws:
      IOException
    • parseTag

      protected boolean parseTag() throws IOException
      Parses a tag. Returns true if it's a start tag.
      Throws:
      IOException
    • expectedChar

      protected IOException expectedChar(String expect, int actualChar)
    • expectBeginTag

      protected IOException expectBeginTag(String expect, String tag)
    • skipWhitespace

      protected int skipWhitespace() throws IOException
      Throws:
      IOException
    • isWhitespace

      protected boolean isWhitespace(int ch) throws IOException
      Throws:
      IOException
    • read

      protected int read() throws IOException
      Throws:
      IOException