public class MicroBurlapOutput extends Object
MicroBurlapOutput does not depend on any classes other than in J2ME, so it can be extracted independently into a smaller package.
MicroBurlapOutput is unbuffered, so any client needs to provide its own buffering.
OutputStream os = ...; // from http connection
MicroBurlapOutput out = new MicroBurlapOutput(os);
String value;
out.startCall("hello"); // start hello call
out.writeString("arg1"); // write a string argument
out.completeCall(); // complete the call
| Constructor and Description |
|---|
MicroBurlapOutput()
Creates an uninitialized Burlap output stream.
|
MicroBurlapOutput(OutputStream os)
Creates a new Burlap output stream, initialized with an
underlying output stream.
|
| Modifier and Type | Method and Description |
|---|---|
static char |
base64encode(int d)
Converts the digit to its base64 encoding.
|
void |
call(String method,
Object[] args)
Writes a complete method call.
|
void |
completeCall()
Writes the method call:
|
void |
init(OutputStream os) |
void |
print(String s)
Prints a string as ascii to the stream.
|
void |
printBytes(byte[] data,
int offset,
int length)
Prints a byte array to the stream, properly encoded in base64.
|
void |
printDate(Calendar calendar)
Prints a date.
|
void |
printInt(int v)
Prints an integer to the stream.
|
void |
printLong(long v)
Prints a long to the stream.
|
void |
printString(String v)
Prints a string to the stream, properly encoded.
|
void |
startCall(String method)
Writes the method call:
|
void |
writeBoolean(boolean value)
Writes a boolean value to the stream.
|
void |
writeBytes(byte[] buffer,
int offset,
int length)
Writes a byte array to the stream using base64 encoding.
|
void |
writeCustomObject(Object object)
Applications which override this can do custom serialization.
|
void |
writeInt(int value)
Writes an integer value to the stream.
|
void |
writeListBegin(int length,
String type)
Writes the list header to the stream.
|
void |
writeListEnd()
Writes the tail of the list to the stream.
|
void |
writeLocalDate(long time)
Writes a date to the stream using ISO8609.
|
void |
writeLong(long value)
Writes a long value to the stream.
|
void |
writeMapBegin(String type)
Writes the map header to the stream.
|
void |
writeMapEnd()
Writes the tail of the map to the stream.
|
void |
writeNull()
Writes a null value to the stream.
|
void |
writeObject(Object object)
Writes a generic object.
|
void |
writeRef(int value)
Writes a reference.
|
void |
writeRemote(String type,
String url)
Writes a remote object reference to the stream.
|
void |
writeString(String value)
Writes a string value to the stream using UTF-8 encoding.
|
void |
writeUTCDate(long time)
Writes a date to the stream using ISO8609.
|
public MicroBurlapOutput(OutputStream os)
os - the underlying output stream.public MicroBurlapOutput()
public void init(OutputStream os)
public void call(String method, Object[] args) throws IOException
IOExceptionpublic void startCall(String method) throws IOException
<burlap:request>
<method>add</method>
method - the method name to call.IOExceptionpublic void completeCall()
throws IOException
</burlap:request>
IOExceptionpublic void writeBoolean(boolean value)
throws IOException
<boolean>1</boolean>
value - the boolean value to write.IOExceptionpublic void writeInt(int value)
throws IOException
<int>123</int>
value - the integer value to write.IOExceptionpublic void writeLong(long value)
throws IOException
<long>123</long>
value - the long value to write.IOExceptionpublic void writeNull()
throws IOException
<null></null>
value - the string value to write.IOExceptionpublic void writeString(String value) throws IOException
<string>12.3e10</string>
If the value is null, it will be written as
<null></null>
value - the string value to write.IOExceptionpublic void writeBytes(byte[] buffer,
int offset,
int length)
throws IOException
<base64>dJmO==</base64>
If the value is null, it will be written as
<null></null>
value - the string value to write.IOExceptionpublic void writeUTCDate(long time)
throws IOException
<date>19980508T095131Z</date>
value - the date in milliseconds from the epoch in UTCIOExceptionpublic void writeLocalDate(long time)
throws IOException
<date>19980508T095131Z</date>
value - the date in milliseconds from the epoch in local timezoneIOExceptionpublic void writeRef(int value)
throws IOException
<ref>123</ref>
value - the integer value to write.IOExceptionpublic void writeObject(Object object) throws IOException
writeCustomObject.IOExceptionpublic void writeCustomObject(Object object) throws IOException
object - the object to write.IOExceptionpublic void writeListBegin(int length,
String type)
throws IOException
writeListBegin followed by the list contents and then
call writeListEnd.
<list>
<type>java.util.ArrayList</type>
<length>3</length>
<int>1</int>
<int>2</int>
<int>3</int>
</list>
IOExceptionpublic void writeListEnd()
throws IOException
IOExceptionpublic void writeMapBegin(String type) throws IOException
writeMapBegin followed by the map contents and then
call writeMapEnd.
<map>
<type>java.util.Hashtable</type>
<string>a</string;<int>1</int>
<string>b</string;<int>2</int>
<string>c</string;<int>3</int>
</map>
IOExceptionpublic void writeMapEnd()
throws IOException
IOExceptionpublic void writeRemote(String type, String url) throws IOException
<remote>
<type>test.account.Account</type>
<string>http://caucho.com/foo;ejbid=bar</string>
</remote>
IOExceptionpublic void printInt(int v)
throws IOException
v - the integer to print.IOExceptionpublic void printLong(long v)
throws IOException
v - the long to print.IOExceptionpublic void printString(String v) throws IOException
v - the string to print.IOExceptionpublic void printBytes(byte[] data,
int offset,
int length)
throws IOException
data - the bytes to print.IOExceptionpublic static char base64encode(int d)
public void printDate(Calendar calendar) throws IOException
date - the date to print.IOExceptionpublic void print(String s) throws IOException
s - the ascii string to print.IOExceptionCopyright © 2017 Caucho Technology, Inc. All rights reserved.