Package com.caucho.hessian.micro
Class MicroHessianOutput
java.lang.Object
com.caucho.hessian.micro.MicroHessianOutput
Output stream for Hessian 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.
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
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates an uninitialized Hessian output stream.Creates a new Hessian output stream, initialized with an underlying output stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidWrites the method call:voidinit(OutputStream os) voidPrints a string to the stream, encoded as UTF-8 with preceeding lengthvoidPrints a string to the stream, encoded as UTF-8voidprintString(String v, int offset, int length) Prints a string to the stream, encoded as UTF-8voidWrites the method call:voidwriteBoolean(boolean value) Writes a boolean value to the stream.voidwriteBytes(byte[] buffer) Writes a byte array to the stream.voidwriteBytes(byte[] buffer, int offset, int length) Writes a byte array to the stream.voidwriteCustomObject(Object object) Applications which override this can do custom serialization.voidwriteInt(int value) Writes an integer value to the stream.voidwriteListBegin(int length, String type) Writes the list header to the stream.voidWrites the tail of the list to the stream.voidwriteLong(long value) Writes a long value to the stream.voidwriteMapBegin(String type) Writes the map header to the stream.voidWrites the tail of the map to the stream.voidWrites a null value to the stream.voidwriteObject(Object object) Writes a generic object to the output stream.voidwriteRef(int value) Writes a reference.voidwriteRemote(String type, String url) Writes a remote object reference to the stream.voidwriteString(String value) Writes a string value to the stream using UTF-8 encoding.voidwriteUTCDate(long time) Writes a date to the stream.
-
Field Details
-
os
-
-
Constructor Details
-
MicroHessianOutput
Creates a new Hessian output stream, initialized with an underlying output stream.- Parameters:
os- the underlying output stream.
-
MicroHessianOutput
public MicroHessianOutput()Creates an uninitialized Hessian output stream.
-
-
Method Details
-
init
-
startCall
Writes the method call:c major minor m b16 b8 method-namek
- Parameters:
method- the method name to call.- Throws:
IOException
-
completeCall
Writes the method call:z
- Throws:
IOException
-
writeBoolean
Writes a boolean value to the stream. The boolean will be written with the following syntax:T F
- Parameters:
value- the boolean value to write.- Throws:
IOException
-
writeInt
Writes an integer value to the stream. The integer will be written with the following syntax:I b32 b24 b16 b8
- Parameters:
value- the integer value to write.- Throws:
IOException
-
writeLong
Writes a long value to the stream. The long will be written with the following syntax:L b64 b56 b48 b40 b32 b24 b16 b8
- Parameters:
value- the long value to write.- Throws:
IOException
-
writeUTCDate
Writes a date to the stream.T b64 b56 b48 b40 b32 b24 b16 b8
- Parameters:
time- the date in milliseconds from the epoch in UTC- Throws:
IOException
-
writeNull
Writes a null value to the stream. The null will be written with the following syntaxN
- Parameters:
value- the string value to write.- Throws:
IOException
-
writeString
Writes a string value to the stream using UTF-8 encoding. The string will be written with the following syntax:If the value is null, it will be written asS b16 b8 string-value
N
- Parameters:
value- the string value to write.- Throws:
IOException
-
writeBytes
Writes a byte array to the stream. The array will be written with the following syntax:If the value is null, it will be written asB b16 b18 bytes
N
- Parameters:
value- the string value to write.- Throws:
IOException
-
writeBytes
Writes a byte array to the stream. The array will be written with the following syntax:If the value is null, it will be written asB b16 b18 bytes
N
- Parameters:
value- the string value to write.- Throws:
IOException
-
writeRef
Writes a reference.R b32 b24 b16 b8
- Parameters:
value- the integer value to write.- Throws:
IOException
-
writeObject
Writes a generic object to the output stream.- Throws:
IOException
-
writeCustomObject
Applications which override this can do custom serialization.- Parameters:
object- the object to write.- Throws:
IOException
-
writeListBegin
Writes the list header to the stream. List writers will callwriteListBeginfollowed by the list contents and then callwriteListEnd.<list> <type>java.util.ArrayList</type> <length>3</length> <int>1</int> <int>2</int> <int>3</int> </list>
- Throws:
IOException
-
writeListEnd
Writes the tail of the list to the stream.- Throws:
IOException
-
writeMapBegin
Writes the map header to the stream. Map writers will callwriteMapBeginfollowed by the map contents and then callwriteMapEnd.Mt b16 b8 type (
)z - Throws:
IOException
-
writeMapEnd
Writes the tail of the map to the stream.- Throws:
IOException
-
writeRemote
Writes a remote object reference to the stream. The type is the type of the remote interface.'r' 't' b16 b8 type url
- Throws:
IOException
-
printLenString
Prints a string to the stream, encoded as UTF-8 with preceeding length- Parameters:
v- the string to print.- Throws:
IOException
-
printString
Prints a string to the stream, encoded as UTF-8- Parameters:
v- the string to print.- Throws:
IOException
-
printString
Prints a string to the stream, encoded as UTF-8- Parameters:
v- the string to print.- Throws:
IOException
-