Package com.caucho.hessian.io
Class AbstractHessianOutput
java.lang.Object
com.caucho.hessian.io.AbstractHessianOutput
- Direct Known Subclasses:
AbstractBurlapOutput
,Hessian2Output
,HessianOutput
Abstract output stream for Hessian requests.
OutputStream os = ...; // from http connection AbstractOutput out = new HessianSerializerOutput(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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
Adds an object to the reference list.void
Writes a complete method call.void
close()
abstract void
Completes the method call:void
protected final SerializerFactory
Gets the serializer factory.void
flush()
abstract int
Gets the serializer factory.void
init
(OutputStream os) Initialize the output with a new underlying stream.boolean
Removes a reference.abstract boolean
replaceRef
(Object oldRef, Object newRef) Replaces a reference from one object to another.void
Resets the references for streaming.void
setSerializerFactory
(SerializerFactory factory) Sets the serializer factory.boolean
setUnshared
(boolean isUnshared) abstract void
Starts the method call:abstract void
Starts the method call:void
abstract void
writeBoolean
(boolean value) Writes a boolean value to the stream.abstract void
writeByteBufferEnd
(byte[] buffer, int offset, int length) Writes the last chunk of a byte buffer to the stream.abstract void
writeByteBufferPart
(byte[] buffer, int offset, int length) Writes a byte buffer to the stream.abstract void
Writes a byte buffer to the stream.abstract void
writeBytes
(byte[] buffer) Writes a byte array to the stream.abstract void
writeBytes
(byte[] buffer, int offset, int length) Writes a byte array to the stream.void
Writes a full output stream.void
writeClassFieldLength
(int len) Writes the end of the class.abstract void
writeDouble
(double value) Writes a double value to the stream.void
writeFault
(String code, String message, Object detail) void
writeHeader
(String name) Deprecated.abstract void
writeInt
(int value) Writes an integer value to the stream.abstract boolean
writeListBegin
(int length, String type) Writes the list header to the stream.abstract void
Writes the tail of the list to the stream.abstract void
writeLong
(long value) Writes a long value to the stream.abstract void
writeMapBegin
(String type) Writes the map header to the stream.abstract void
Writes the tail of the map to the stream.abstract void
writeMethod
(String method) Writes the method tag.abstract void
Writes a null value to the stream.abstract void
writeObject
(Object object) Writes a generic object to the output stream.int
writeObjectBegin
(String type) Writes the object header to the stream (for Hessian 2.0), or a Map for Hessian 1.0.void
Writes the tail of the object to the stream.protected abstract void
writeRef
(int value) Writes a reference.void
writeReply
(Object o) abstract void
writeString
(char[] buffer, int offset, int length) Writes a string value to the stream using UTF-8 encoding.abstract void
writeString
(String value) Writes a string value to the stream using UTF-8 encoding.abstract void
writeUTCDate
(long time) Writes a date to the stream.
-
Field Details
-
_serializerFactory
-
-
Constructor Details
-
AbstractHessianOutput
public AbstractHessianOutput()
-
-
Method Details
-
setSerializerFactory
Sets the serializer factory. -
getSerializerFactory
Gets the serializer factory. -
findSerializerFactory
Gets the serializer factory. -
init
Initialize the output with a new underlying stream. -
call
Writes a complete method call.- Throws:
IOException
-
startCall
Starts the method call:C
- Parameters:
method
- the method name to call.- Throws:
IOException
-
startCall
Starts the method call:C string int
- Parameters:
method
- the method name to call.- Throws:
IOException
-
writeHeader
Deprecated.For Hessian 2.0, use the Header envelope instead- Throws:
IOException
-
writeMethod
Writes the method tag.string
- Parameters:
method
- the method name to call.- Throws:
IOException
-
completeCall
Completes the method call:- 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
-
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
- 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
- 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
-
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
-
writeByteBufferStart
Writes a byte buffer to the stream.- Throws:
IOException
-
writeByteBufferPart
Writes a byte buffer to the stream.b b16 b18 bytes
- Parameters:
value
- the string value to write.- Throws:
IOException
-
writeByteBufferEnd
Writes the last chunk of a byte buffer to the stream.b b16 b18 bytes
- Parameters:
value
- the string value to write.- Throws:
IOException
-
writeByteStream
Writes a full output stream.- Throws:
IOException
-
writeRef
Writes a reference.Q int
- Parameters:
value
- the integer value to write.- Throws:
IOException
-
removeRef
Removes a reference.- Throws:
IOException
-
replaceRef
Replaces a reference from one object to another.- Throws:
IOException
-
addRef
Adds an object to the reference list. If the object already exists, writes the reference, otherwise, the caller is responsible for the serialization.R b32 b24 b16 b8
- Parameters:
object
- the object to add as a reference.- Returns:
- true if the object has already been written.
- Throws:
IOException
-
getRef
- Parameters:
obj
-- Returns:
-
resetReferences
public void resetReferences()Resets the references for streaming. -
writeObject
Writes a generic object to the output stream.- Throws:
IOException
-
writeListBegin
Writes the list header to the stream. List writers will callwriteListBegin
followed by the list contents and then callwriteListEnd
.V x13 java.util.ArrayList # type x93 # length=3 x91 # 1 x92 # 2 x93 # 3 </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 callwriteMapBegin
followed by the map contents and then callwriteMapEnd
.M type (
)* Z - Throws:
IOException
-
writeMapEnd
Writes the tail of the map to the stream.- Throws:
IOException
-
writeObjectBegin
Writes the object header to the stream (for Hessian 2.0), or a Map for Hessian 1.0. Object writers will callwriteObjectBegin
followed by the map contents and then callwriteObjectEnd
.C type int
* C int * - Returns:
- true if the object has already been defined.
- Throws:
IOException
-
writeClassFieldLength
Writes the end of the class.- Throws:
IOException
-
writeObjectEnd
Writes the tail of the object to the stream.- Throws:
IOException
-
writeReply
- Throws:
IOException
-
startReply
- Throws:
IOException
-
completeReply
- Throws:
IOException
-
writeFault
- Throws:
IOException
-
flush
- Throws:
IOException
-
close
- Throws:
IOException
-