Package com.caucho.hessian.io
Class HessianOutput
java.lang.Object
com.caucho.hessian.io.AbstractHessianOutput
com.caucho.hessian.io.HessianOutput
Output stream for Hessian requests, compatible with microedition
Java. It only uses classes and types available in JDK.
Since HessianOutput does not depend on any classes other than in the JDK, it can be extracted independently into a smaller package.
HessianOutput is unbuffered, so any client needs to provide its own buffering.
OutputStream os = ...; // from http connection
HessianOutput out = new HessianOutput(os);
String value;
out.startCall("hello"); // start hello call
out.writeString("arg1"); // write a string argument
out.completeCall(); // complete the call
-
Field Summary
FieldsFields inherited from class com.caucho.hessian.io.AbstractHessianOutput
_serializerFactory -
Constructor Summary
ConstructorsConstructorDescriptionCreates an uninitialized Hessian output stream.Creates a new Hessian output stream, initialized with an underlying output stream. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIf the object has already been written, just write its ref.voidWrites a complete method call.voidclose()voidCompletes.voidCompletes reading the replyvoidflush()intvoidinit(OutputStream os) Initializes the outputvoidPrints a string to the stream, encoded as UTF-8 with preceeding lengthvoidprintString(char[] v, int offset, int length) Prints a string to the stream, encoded as UTF-8voidPrints a string to the stream, encoded as UTF-8voidprintString(String v, int offset, int length) Prints a string to the stream, encoded as UTF-8booleanRemoves a reference.booleanreplaceRef(Object oldRef, Object newRef) Replaces a reference from one object to another.voidResets the references for streaming.voidsetVersion(int version) Sets the client's version.voidWrites the call tag.voidStarts the method call.voidStarts the replyvoidwriteBoolean(boolean value) Writes a boolean value to the stream.voidwriteByteBufferEnd(byte[] buffer, int offset, int length) Writes a byte buffer to the stream.voidwriteByteBufferPart(byte[] buffer, int offset, int length) Writes a byte buffer to the stream.voidWrites a byte buffer 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.voidwriteDouble(double value) Writes a double value to the stream.voidwriteFault(String code, String message, Object detail) Writes a fault.voidwriteHeader(String name) Writes a header name.voidwriteInt(int value) Writes an integer value to the stream.booleanwriteListBegin(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.voidwriteMethod(String method) Writes the method tag.voidWrites a null value to the stream.voidwriteObject(Object object) Writes any object to the output stream.voidWrites a placeholder.voidwriteRef(int value) Writes a reference.voidwriteRemote(String type, String url) Writes a remote object reference to the stream.voidwriteString(char[] buffer, int offset, int length) Writes a string value to the stream using UTF-8 encoding.voidwriteString(String value) Writes a string value to the stream using UTF-8 encoding.voidwriteUTCDate(long time) Writes a date to the stream.Methods inherited from class com.caucho.hessian.io.AbstractHessianOutput
findSerializerFactory, getSerializerFactory, setSerializerFactory, setUnshared, writeByteStream, writeClassFieldLength, writeObjectBegin, writeObjectEnd, writeReply
-
Field Details
-
os
-
-
Constructor Details
-
HessianOutput
Creates a new Hessian output stream, initialized with an underlying output stream.- Parameters:
os- the underlying output stream.
-
HessianOutput
public HessianOutput()Creates an uninitialized Hessian output stream.
-
-
Method Details
-
init
Initializes the output- Overrides:
initin classAbstractHessianOutput
-
setVersion
public void setVersion(int version) Sets the client's version. -
call
Writes a complete method call.- Overrides:
callin classAbstractHessianOutput- Throws:
IOException
-
startCall
Starts the method call. Clients would usestartCallinstead ofcallif they wanted finer control over writing the arguments, or needed to write headers.c major minor m b16 b8 method-name
- Specified by:
startCallin classAbstractHessianOutput- Parameters:
method- the method name to call.- Throws:
IOException
-
startCall
Writes the call tag. This would be followed by the headers and the method tag.c major minor
- Specified by:
startCallin classAbstractHessianOutput- Parameters:
method- the method name to call.- Throws:
IOException
-
writeMethod
Writes the method tag.m b16 b8 method-name
- Specified by:
writeMethodin classAbstractHessianOutput- Parameters:
method- the method name to call.- Throws:
IOException
-
completeCall
Completes.z
- Specified by:
completeCallin classAbstractHessianOutput- Throws:
IOException
-
startReply
Starts the replyA successful completion will have a single value:
r
- Overrides:
startReplyin classAbstractHessianOutput- Throws:
IOException
-
completeReply
Completes reading the replyA successful completion will have a single value:
z
- Overrides:
completeReplyin classAbstractHessianOutput- Throws:
IOException
-
writeHeader
Writes a header name. The header value must immediately follow.H b16 b8 foo value
- Overrides:
writeHeaderin classAbstractHessianOutput- Throws:
IOException
-
writeFault
Writes a fault. The fault will be written as a descriptive string followed by an object:f <string>code <string>the fault code <string>message <string>the fault mesage <string>detail mt\x00\xnnjavax.ejb.FinderException ... z z- Overrides:
writeFaultin classAbstractHessianOutput- Parameters:
code- the fault code, a three digit- Throws:
IOException
-
writeObject
Writes any object to the output stream.- Specified by:
writeObjectin classAbstractHessianOutput- Throws:
IOException
-
writeListBegin
Writes the list header to the stream. List writers will callwriteListBeginfollowed by the list contents and then callwriteListEnd.V t b16 b8 type l b32 b24 b16 b8
- Specified by:
writeListBeginin classAbstractHessianOutput- Throws:
IOException
-
writeListEnd
Writes the tail of the list to the stream.- Specified by:
writeListEndin classAbstractHessianOutput- Throws:
IOException
-
writeMapBegin
Writes the map header to the stream. Map writers will callwriteMapBeginfollowed by the map contents and then callwriteMapEnd.Mt b16 b8 (
)z - Specified by:
writeMapBeginin classAbstractHessianOutput- Throws:
IOException
-
writeMapEnd
Writes the tail of the map to the stream.- Specified by:
writeMapEndin classAbstractHessianOutput- 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
-
writeBoolean
Writes a boolean value to the stream. The boolean will be written with the following syntax:T F
- Specified by:
writeBooleanin classAbstractHessianOutput- 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
- Specified by:
writeIntin classAbstractHessianOutput- 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
- Specified by:
writeLongin classAbstractHessianOutput- Parameters:
value- the long value to write.- Throws:
IOException
-
writeDouble
Writes a double value to the stream. The double will be written with the following syntax:D b64 b56 b48 b40 b32 b24 b16 b8
- Specified by:
writeDoublein classAbstractHessianOutput- Parameters:
value- the double value to write.- Throws:
IOException
-
writeUTCDate
Writes a date to the stream.T b64 b56 b48 b40 b32 b24 b16 b8
- Specified by:
writeUTCDatein classAbstractHessianOutput- 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
- Specified by:
writeNullin classAbstractHessianOutput- 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
- Specified by:
writeStringin classAbstractHessianOutput- 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
- Specified by:
writeStringin classAbstractHessianOutput- 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
- Specified by:
writeBytesin classAbstractHessianOutput- 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
- Specified by:
writeBytesin classAbstractHessianOutput- Parameters:
value- the string value to write.- Throws:
IOException
-
writeByteBufferStart
Writes a byte buffer to the stream.- Specified by:
writeByteBufferStartin classAbstractHessianOutput- Throws:
IOException
-
writeByteBufferPart
Writes a byte buffer to the stream.b b16 b18 bytes
- Specified by:
writeByteBufferPartin classAbstractHessianOutput- Throws:
IOException
-
writeByteBufferEnd
Writes a byte buffer to the stream.b b16 b18 bytes
- Specified by:
writeByteBufferEndin classAbstractHessianOutput- Throws:
IOException
-
writeRef
Writes a reference.R b32 b24 b16 b8
- Specified by:
writeRefin classAbstractHessianOutput- Parameters:
value- the integer value to write.- Throws:
IOException
-
writePlaceholder
Writes a placeholder.P
- Throws:
IOException
-
addRef
If the object has already been written, just write its ref.- Specified by:
addRefin classAbstractHessianOutput- Parameters:
object- the object to add as a reference.- Returns:
- true if we're writing a ref.
- Throws:
IOException
-
getRef
- Specified by:
getRefin classAbstractHessianOutput- Returns:
-
resetReferences
public void resetReferences()Resets the references for streaming.- Overrides:
resetReferencesin classAbstractHessianOutput
-
removeRef
Removes a reference.- Overrides:
removeRefin classAbstractHessianOutput- Throws:
IOException
-
replaceRef
Replaces a reference from one object to another.- Specified by:
replaceRefin classAbstractHessianOutput- 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
-
printString
Prints a string to the stream, encoded as UTF-8- Parameters:
v- the string to print.- Throws:
IOException
-
flush
- Overrides:
flushin classAbstractHessianOutput- Throws:
IOException
-
close
- Overrides:
closein classAbstractHessianOutput- Throws:
IOException
-