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 Dateprotected StringBufferprotected Stringprotected intprotected booleanprotected Vectorprotected StringBufferprotected 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 TypeMethodDescriptionvoidCompletes reading the call.voidCompletes reading the reply.protected IOExceptionexpectBeginTag(String expect, String tag) protected IOExceptionexpectedChar(String expect, int actualChar) protected voidexpectEndTag(String tag) protected voidexpectStartTag(String tag) Returns a call's method.voidinit(InputStream is) Initialize the Burlap input stream with a new underlying stream.protected booleanisWhitespace(int ch) protected byte[]Parses a byte array.protected ByteArrayOutputStreamParses a byte array.protected longParses a date value from the stream.protected intparseInt()Parses an integer value from the stream.protected longParses a long value from the stream.protected StringParses a string value from the stream.protected StringBufferparseString(StringBuffer sbuf) Parses a string value from the stream.protected booleanparseTag()Parses a tag.protected intread()booleanReads a boolean value from the input stream.byte[]Reads a byte array from the input stream.protected ObjectreadExtensionObject(Class expectedClass, String tag) Reads object unknown to MicroBurlapInput.Reads a fault.intreadInt()Reads an integer value from the input stream.intReads a length value from the input stream.Reads a list object from the input stream.longReads a date value from the input stream.longreadLong()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.longReads a date value from the input stream.resolveRemote(String type, String url) Resolves a remote object.protected intvoidStarts reading the callbooleanStarts 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
-