public class MicroHessianOutput extends Object
MicroHessianOutput does not depend on any classes other than in J2ME, so it can be extracted independently into a smaller package.
MicroHessianOutput is unbuffered, so any client needs to provide its own buffering.
OutputStream os = ...; // from http connection MicroHessianOutput out = new MicroHessianOutput(os); String value; out.startCall("hello"); // start hello call out.writeString("arg1"); // write a string argument out.completeCall(); // complete the call
Modifier and Type | Field and Description |
---|---|
protected OutputStream |
os |
Constructor and Description |
---|
MicroHessianOutput()
Creates an uninitialized Hessian output stream.
|
MicroHessianOutput(OutputStream os)
Creates a new Hessian output stream, initialized with an
underlying output stream.
|
Modifier and Type | Method and Description |
---|---|
void |
completeCall()
Writes the method call:
|
void |
init(OutputStream os) |
void |
printLenString(String v)
Prints a string to the stream, encoded as UTF-8 with preceeding length
|
void |
printString(String v)
Prints a string to the stream, encoded as UTF-8
|
void |
printString(String v,
int offset,
int length)
Prints a string to the stream, encoded as UTF-8
|
void |
startCall(String method)
Writes the method call:
|
void |
writeBoolean(boolean value)
Writes a boolean value to the stream.
|
void |
writeBytes(byte[] buffer)
Writes a byte array to the stream.
|
void |
writeBytes(byte[] buffer,
int offset,
int length)
Writes a byte array to the stream.
|
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 |
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 to the output stream.
|
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.
|
protected OutputStream os
public MicroHessianOutput(OutputStream os)
os
- the underlying output stream.public MicroHessianOutput()
public void init(OutputStream os)
public void startCall(String method) throws IOException
c major minor
m b16 b8 method-namek
method
- the method name to call.IOException
public void completeCall() throws IOException
z
IOException
public void writeBoolean(boolean value) throws IOException
T
F
value
- the boolean value to write.IOException
public void writeInt(int value) throws IOException
I b32 b24 b16 b8
value
- the integer value to write.IOException
public void writeLong(long value) throws IOException
L b64 b56 b48 b40 b32 b24 b16 b8
value
- the long value to write.IOException
public void writeUTCDate(long time) throws IOException
T b64 b56 b48 b40 b32 b24 b16 b8
time
- the date in milliseconds from the epoch in UTCIOException
public void writeNull() throws IOException
N
value
- the string value to write.IOException
public void writeString(String value) throws IOException
S b16 b8 string-value
If the value is null, it will be written as
N
value
- the string value to write.IOException
public void writeBytes(byte[] buffer) throws IOException
B b16 b18 bytes
If the value is null, it will be written as
N
value
- the string value to write.IOException
public void writeBytes(byte[] buffer, int offset, int length) throws IOException
B b16 b18 bytes
If the value is null, it will be written as
N
value
- the string value to write.IOException
public void writeRef(int value) throws IOException
R b32 b24 b16 b8
value
- the integer value to write.IOException
public void writeObject(Object object) throws IOException
IOException
public void writeCustomObject(Object object) throws IOException
object
- the object to write.IOException
public 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>
IOException
public void writeListEnd() throws IOException
IOException
public void writeMapBegin(String type) throws IOException
writeMapBegin
followed by the map contents and then
call writeMapEnd
.
Mt b16 b8 type ( )z
IOException
public void writeMapEnd() throws IOException
IOException
public void writeRemote(String type, String url) throws IOException
'r' 't' b16 b8 type url
IOException
public void printLenString(String v) throws IOException
v
- the string to print.IOException
public void printString(String v) throws IOException
v
- the string to print.IOException
public void printString(String v, int offset, int length) throws IOException
v
- the string to print.IOException
Copyright © 2023. All rights reserved.