Package com.caucho.burlap.client
Class MicroBurlapInput
- java.lang.Object
-
- com.caucho.burlap.client.MicroBurlapInput
-
public class MicroBurlapInput extends java.lang.ObjectInput 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
Fields Modifier and Type Field Description protected java.util.Datedateprotected java.lang.StringBufferentityprotected java.lang.Stringmethodprotected intpeekprotected booleanpeekTagprotected java.util.Vectorrefsprotected java.lang.StringBuffersbufprotected java.util.CalendarutcCalendar
-
Constructor Summary
Constructors Constructor Description MicroBurlapInput()Creates an uninitialized Burlap input stream.MicroBurlapInput(java.io.InputStream is)Creates a new Burlap input stream, initialized with an underlying input stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcompleteCall()Completes reading the call.voidcompleteReply()Completes reading the reply.protected java.io.IOExceptionexpectBeginTag(java.lang.String expect, java.lang.String tag)protected java.io.IOExceptionexpectedChar(java.lang.String expect, int actualChar)protected voidexpectEndTag(java.lang.String tag)protected voidexpectStartTag(java.lang.String tag)java.lang.StringgetMethod()Returns a call's method.voidinit(java.io.InputStream is)Initialize the Burlap input stream with a new underlying stream.protected booleanisWhitespace(int ch)protected byte[]parseBytes()Parses a byte array.protected java.io.ByteArrayOutputStreamparseBytes(java.io.ByteArrayOutputStream bos)Parses a byte array.protected longparseDate(java.util.Calendar calendar)Parses a date value from the stream.protected intparseInt()Parses an integer value from the stream.protected longparseLong()Parses a long value from the stream.protected java.lang.StringparseString()Parses a string value from the stream.protected java.lang.StringBufferparseString(java.lang.StringBuffer sbuf)Parses a string value from the stream.protected booleanparseTag()Parses a tag.protected intread()booleanreadBoolean()Reads a boolean value from the input stream.byte[]readBytes()Reads a byte array from the input stream.protected java.lang.ObjectreadExtensionObject(java.lang.Class expectedClass, java.lang.String tag)Reads object unknown to MicroBurlapInput.java.util.HashtablereadFault()Reads a fault.intreadInt()Reads an integer value from the input stream.intreadLength()Reads a length value from the input stream.java.lang.ObjectreadList(java.lang.Class expectedClass, java.lang.String type, int length)Reads a list object from the input stream.longreadLocalDate()Reads a date value from the input stream.longreadLong()Reads a long value from the input stream.java.lang.ObjectreadMap(java.lang.Class expectedClass, java.lang.String type)Reads an object from the input stream.java.lang.ObjectreadObject(java.lang.Class expectedClass)Reads an arbitrary object the input stream.BurlapRemotereadRemote()Reads a remote value from the input stream.java.lang.ObjectreadReply(java.lang.Class expectedClass)Reads a reply as an object.java.lang.StringreadString()Reads a string value from the input stream.java.lang.StringreadType()Reads a type value from the input stream.longreadUTCDate()Reads a date value from the input stream.java.lang.ObjectresolveRemote(java.lang.String type, java.lang.String url)Resolves a remote object.protected intskipWhitespace()voidstartCall()Starts reading the callbooleanstartReply()Starts reading the reply.
-
-
-
Field Detail
-
peek
protected int peek
-
peekTag
protected boolean peekTag
-
date
protected java.util.Date date
-
utcCalendar
protected java.util.Calendar utcCalendar
-
refs
protected java.util.Vector refs
-
method
protected java.lang.String method
-
sbuf
protected java.lang.StringBuffer sbuf
-
entity
protected java.lang.StringBuffer entity
-
-
Method Detail
-
getMethod
public java.lang.String getMethod()
Returns a call's method.
-
init
public void init(java.io.InputStream is)
Initialize the Burlap input stream with a new underlying stream. Applications can useinit(InputStream)to reuse MicroBurlapInput to save garbage collection.
-
startCall
public void startCall() throws java.io.IOExceptionStarts reading the callA successful completion will have a single value:
<burlap:call> <method>method</method>
- Throws:
java.io.IOException
-
completeCall
public void completeCall() throws java.io.IOExceptionCompletes reading the call.</burlap:call>
- Throws:
java.io.IOException
-
readReply
public java.lang.Object readReply(java.lang.Class expectedClass) throws java.lang.ExceptionReads a reply as an object. If the reply has a fault, throws the exception.- Throws:
java.lang.Exception
-
startReply
public boolean startReply() throws java.io.IOExceptionStarts 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:
java.io.IOException
-
completeReply
public void completeReply() throws java.io.IOExceptionCompletes reading the reply.</burlap:reply>
- Throws:
java.io.IOException
-
readBoolean
public boolean readBoolean() throws java.io.IOExceptionReads a boolean value from the input stream.- Throws:
java.io.IOException
-
readInt
public int readInt() throws java.io.IOExceptionReads an integer value from the input stream.- Throws:
java.io.IOException
-
readLong
public long readLong() throws java.io.IOExceptionReads a long value from the input stream.- Throws:
java.io.IOException
-
readUTCDate
public long readUTCDate() throws java.io.IOExceptionReads a date value from the input stream.- Throws:
java.io.IOException
-
readLocalDate
public long readLocalDate() throws java.io.IOExceptionReads a date value from the input stream.- Throws:
java.io.IOException
-
readRemote
public BurlapRemote readRemote() throws java.io.IOException
Reads a remote value from the input stream.- Throws:
java.io.IOException
-
readString
public java.lang.String readString() throws java.io.IOExceptionReads 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:
java.io.IOException
-
readBytes
public byte[] readBytes() throws java.io.IOExceptionReads a byte array from the input stream.The two valid possibilities are either a <null> or a <base64>.
- Throws:
java.io.IOException
-
readObject
public java.lang.Object readObject(java.lang.Class expectedClass) throws java.io.IOExceptionReads an arbitrary object the input stream.- Throws:
java.io.IOException
-
readType
public java.lang.String readType() throws java.io.IOExceptionReads a type value from the input stream.<type>a utf-8 encoded string</type>
- Throws:
java.io.IOException
-
readLength
public int readLength() throws java.io.IOExceptionReads a length value from the input stream. If the length isn't specified, returns -1.<length>integer</length>
- Throws:
java.io.IOException
-
resolveRemote
public java.lang.Object resolveRemote(java.lang.String type, java.lang.String url) throws java.io.IOExceptionResolves a remote object.- Throws:
java.io.IOException
-
readFault
public java.util.Hashtable readFault() throws java.io.IOExceptionReads a fault.- Throws:
java.io.IOException
-
readMap
public java.lang.Object readMap(java.lang.Class expectedClass, java.lang.String type) throws java.io.IOExceptionReads an object from the input stream.- Parameters:
expectedClass- the calling routine's expected classtype- the type from the stream- Throws:
java.io.IOException
-
readExtensionObject
protected java.lang.Object readExtensionObject(java.lang.Class expectedClass, java.lang.String tag) throws java.io.IOExceptionReads object unknown to MicroBurlapInput.- Throws:
java.io.IOException
-
readList
public java.lang.Object readList(java.lang.Class expectedClass, java.lang.String type, int length) throws java.io.IOExceptionReads 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:
java.io.IOException
-
parseInt
protected int parseInt() throws java.io.IOExceptionParses an integer value from the stream.- Throws:
java.io.IOException
-
parseLong
protected long parseLong() throws java.io.IOExceptionParses a long value from the stream.- Throws:
java.io.IOException
-
parseDate
protected long parseDate(java.util.Calendar calendar) throws java.io.IOExceptionParses a date value from the stream.- Throws:
java.io.IOException
-
parseString
protected java.lang.String parseString() throws java.io.IOExceptionParses a string value from the stream. string buffer is used for the result.- Throws:
java.io.IOException
-
parseString
protected java.lang.StringBuffer parseString(java.lang.StringBuffer sbuf) throws java.io.IOExceptionParses 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.IOExceptionParses a byte array.- Throws:
java.io.IOException
-
parseBytes
protected java.io.ByteArrayOutputStream parseBytes(java.io.ByteArrayOutputStream bos) throws java.io.IOExceptionParses a byte array.- Throws:
java.io.IOException
-
expectStartTag
protected void expectStartTag(java.lang.String tag) throws java.io.IOException- Throws:
java.io.IOException
-
expectEndTag
protected void expectEndTag(java.lang.String tag) throws java.io.IOException- Throws:
java.io.IOException
-
parseTag
protected boolean parseTag() throws java.io.IOExceptionParses a tag. Returns true if it's a start tag.- Throws:
java.io.IOException
-
expectedChar
protected java.io.IOException expectedChar(java.lang.String expect, int actualChar)
-
expectBeginTag
protected java.io.IOException expectBeginTag(java.lang.String expect, java.lang.String tag)
-
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
-
read
protected int read() throws java.io.IOException- Throws:
java.io.IOException
-
-