Package com.caucho.burlap.client
Class MicroBurlapInput
java.lang.Object
com.caucho.burlap.client.MicroBurlapInput
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 Summary
FieldsModifier and TypeFieldDescriptionprotected Date
protected StringBuffer
protected String
protected int
protected boolean
protected Vector
protected StringBuffer
protected Calendar
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an uninitialized Burlap input stream.Creates a new Burlap input stream, initialized with an underlying input stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Completes reading the call.void
Completes reading the reply.protected IOException
expectBeginTag
(String expect, String tag) protected IOException
expectedChar
(String expect, int actualChar) protected void
expectEndTag
(String tag) protected void
expectStartTag
(String tag) Returns a call's method.void
init
(InputStream is) Initialize the Burlap input stream with a new underlying stream.protected boolean
isWhitespace
(int ch) protected byte[]
Parses a byte array.protected ByteArrayOutputStream
Parses a byte array.protected long
Parses a date value from the stream.protected int
parseInt()
Parses an integer value from the stream.protected long
Parses a long value from the stream.protected String
Parses a string value from the stream.protected StringBuffer
parseString
(StringBuffer sbuf) Parses a string value from the stream.protected boolean
parseTag()
Parses a tag.protected int
read()
boolean
Reads a boolean value from the input stream.byte[]
Reads a byte array from the input stream.protected Object
readExtensionObject
(Class expectedClass, String tag) Reads object unknown to MicroBurlapInput.Reads a fault.int
readInt()
Reads an integer value from the input stream.int
Reads a length value from the input stream.Reads a list object from the input stream.long
Reads a date value from the input stream.long
readLong()
Reads a long value from the input stream.Reads an object from the input stream.readObject
(Class expectedClass) Reads an arbitrary object the input stream.Reads a remote value from the input stream.Reads a reply as an object.Reads a string value from the input stream.readType()
Reads a type value from the input stream.long
Reads a date value from the input stream.resolveRemote
(String type, String url) Resolves a remote object.protected int
void
Starts reading the callboolean
Starts reading the reply.
-
Field Details
-
peek
protected int peek -
peekTag
protected boolean peekTag -
date
-
utcCalendar
-
refs
-
method
-
sbuf
-
entity
-
-
Constructor Details
-
MicroBurlapInput
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
Returns a call's method. -
init
Initialize the Burlap input stream with a new underlying stream. Applications can useinit(InputStream)
to reuse MicroBurlapInput to save garbage collection. -
startCall
Starts reading the callA successful completion will have a single value:
<burlap:call> <method>method</method>
- Throws:
IOException
-
completeCall
Completes reading the call.</burlap:call>
- Throws:
IOException
-
readReply
Reads a reply as an object. If the reply has a fault, throws the exception.- Throws:
Exception
-
startReply
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
Completes reading the reply.</burlap:reply>
- Throws:
IOException
-
readBoolean
Reads a boolean value from the input stream.- Throws:
IOException
-
readInt
Reads an integer value from the input stream.- Throws:
IOException
-
readLong
Reads a long value from the input stream.- Throws:
IOException
-
readUTCDate
Reads a date value from the input stream.- Throws:
IOException
-
readLocalDate
Reads a date value from the input stream.- Throws:
IOException
-
readRemote
Reads a remote value from the input stream.- Throws:
IOException
-
readString
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
Reads a byte array from the input stream.The two valid possibilities are either a <null> or a <base64>.
- Throws:
IOException
-
readObject
Reads an arbitrary object the input stream.- Throws:
IOException
-
readType
Reads a type value from the input stream.<type>a utf-8 encoded string</type>
- Throws:
IOException
-
readLength
Reads a length value from the input stream. If the length isn't specified, returns -1.<length>integer</length>
- Throws:
IOException
-
resolveRemote
Resolves a remote object.- Throws:
IOException
-
readFault
Reads a fault.- Throws:
IOException
-
readMap
Reads an object from the input stream.- Parameters:
expectedClass
- the calling routine's expected classtype
- the type from the stream- Throws:
IOException
-
readExtensionObject
Reads object unknown to MicroBurlapInput.- Throws:
IOException
-
readList
Reads a list object from the input stream.- Parameters:
expectedClass
- the calling routine's expected classtype
- the type from the streamlength
- the expected length, -1 for unspecified length- Throws:
IOException
-
parseInt
Parses an integer value from the stream.- Throws:
IOException
-
parseLong
Parses a long value from the stream.- Throws:
IOException
-
parseDate
Parses a date value from the stream.- Throws:
IOException
-
parseString
Parses a string value from the stream. string buffer is used for the result.- Throws:
IOException
-
parseString
Parses a string value from the stream. The burlap object's string buffer is used for the result.- Throws:
IOException
-
parseBytes
Parses a byte array.- Throws:
IOException
-
parseBytes
Parses a byte array.- Throws:
IOException
-
expectStartTag
- Throws:
IOException
-
expectEndTag
- Throws:
IOException
-
parseTag
Parses a tag. Returns true if it's a start tag.- Throws:
IOException
-
expectedChar
-
expectBeginTag
-
skipWhitespace
- Throws:
IOException
-
isWhitespace
- Throws:
IOException
-
read
- Throws:
IOException
-