public class MicroBurlapInput extends Object
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
Modifier and Type | Field and Description |
---|---|
protected Date |
date |
protected StringBuffer |
entity |
protected String |
method |
protected int |
peek |
protected boolean |
peekTag |
protected Vector |
refs |
protected StringBuffer |
sbuf |
protected Calendar |
utcCalendar |
Constructor and Description |
---|
MicroBurlapInput()
Creates an uninitialized Burlap input stream.
|
MicroBurlapInput(InputStream is)
Creates a new Burlap input stream, initialized with an
underlying input stream.
|
Modifier and Type | Method and Description |
---|---|
void |
completeCall()
Completes reading the call.
|
void |
completeReply()
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) |
String |
getMethod()
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[] |
parseBytes()
Parses a byte array.
|
protected ByteArrayOutputStream |
parseBytes(ByteArrayOutputStream bos)
Parses a byte array.
|
protected long |
parseDate(Calendar calendar)
Parses a date value from the stream.
|
protected int |
parseInt()
Parses an integer value from the stream.
|
protected long |
parseLong()
Parses a long value from the stream.
|
protected String |
parseString()
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 |
readBoolean()
Reads a boolean value from the input stream.
|
byte[] |
readBytes()
Reads a byte array from the input stream.
|
protected Object |
readExtensionObject(Class expectedClass,
String tag)
Reads object unknown to MicroBurlapInput.
|
Hashtable |
readFault()
Reads a fault.
|
int |
readInt()
Reads an integer value from the input stream.
|
int |
readLength()
Reads a length value from the input stream.
|
Object |
readList(Class expectedClass,
String type,
int length)
Reads a list object from the input stream.
|
long |
readLocalDate()
Reads a date value from the input stream.
|
long |
readLong()
Reads a long value from the input stream.
|
Object |
readMap(Class expectedClass,
String type)
Reads an object from the input stream.
|
Object |
readObject(Class expectedClass)
Reads an arbitrary object the input stream.
|
BurlapRemote |
readRemote()
Reads a remote value from the input stream.
|
Object |
readReply(Class expectedClass)
Reads a reply as an object.
|
String |
readString()
Reads a string value from the input stream.
|
String |
readType()
Reads a type value from the input stream.
|
long |
readUTCDate()
Reads a date value from the input stream.
|
Object |
resolveRemote(String type,
String url)
Resolves a remote object.
|
protected int |
skipWhitespace() |
void |
startCall()
Starts reading the call
|
boolean |
startReply()
Starts reading the reply.
|
protected int peek
protected boolean peekTag
protected Date date
protected Calendar utcCalendar
protected Vector refs
protected String method
protected StringBuffer sbuf
protected StringBuffer entity
public MicroBurlapInput(InputStream is)
is
- the underlying input stream.public MicroBurlapInput()
public String getMethod()
public void init(InputStream is)
init(InputStream)
to reuse
MicroBurlapInput to save garbage collection.public void startCall() throws IOException
A successful completion will have a single value:
<burlap:call> <method>method</method>
IOException
public void completeCall() throws IOException
</burlap:call>
IOException
public Object readReply(Class expectedClass) throws Exception
Exception
public boolean startReply() throws IOException
A successful completion will have a single value. An unsuccessful one will have a fault:
<burlap:reply>
IOException
public void completeReply() throws IOException
</burlap:reply>
IOException
public boolean readBoolean() throws IOException
IOException
public int readInt() throws IOException
IOException
public long readLong() throws IOException
IOException
public long readUTCDate() throws IOException
IOException
public long readLocalDate() throws IOException
IOException
public BurlapRemote readRemote() throws IOException
IOException
public String readString() throws IOException
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>
IOException
public byte[] readBytes() throws IOException
The two valid possibilities are either a <null> or a <base64>.
IOException
public Object readObject(Class expectedClass) throws IOException
IOException
public String readType() throws IOException
<type>a utf-8 encoded string</type>
IOException
public int readLength() throws IOException
<length>integer</length>
IOException
public Object resolveRemote(String type, String url) throws IOException
IOException
public Hashtable readFault() throws IOException
IOException
public Object readMap(Class expectedClass, String type) throws IOException
expectedClass
- the calling routine's expected classtype
- the type from the streamIOException
protected Object readExtensionObject(Class expectedClass, String tag) throws IOException
IOException
public Object readList(Class expectedClass, String type, int length) throws IOException
expectedClass
- the calling routine's expected classtype
- the type from the streamlength
- the expected length, -1 for unspecified lengthIOException
protected int parseInt() throws IOException
IOException
protected long parseLong() throws IOException
IOException
protected long parseDate(Calendar calendar) throws IOException
IOException
protected String parseString() throws IOException
IOException
protected StringBuffer parseString(StringBuffer sbuf) throws IOException
IOException
protected byte[] parseBytes() throws IOException
IOException
protected ByteArrayOutputStream parseBytes(ByteArrayOutputStream bos) throws IOException
IOException
protected void expectStartTag(String tag) throws IOException
IOException
protected void expectEndTag(String tag) throws IOException
IOException
protected boolean parseTag() throws IOException
IOException
protected IOException expectedChar(String expect, int actualChar)
protected IOException expectBeginTag(String expect, String tag)
protected int skipWhitespace() throws IOException
IOException
protected boolean isWhitespace(int ch) throws IOException
IOException
protected int read() throws IOException
IOException
Copyright © 2023. All rights reserved.