Package com.caucho.hessian.io
Class AbstractHessianOutput
- java.lang.Object
-
- com.caucho.hessian.io.AbstractHessianOutput
-
- Direct Known Subclasses:
AbstractBurlapOutput,Hessian2Output,HessianOutput
public abstract class AbstractHessianOutput extends java.lang.ObjectAbstract 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 Modifier and Type Field Description protected SerializerFactory_serializerFactory
-
Constructor Summary
Constructors Constructor Description AbstractHessianOutput()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract booleanaddRef(java.lang.Object object)Adds an object to the reference list.voidcall(java.lang.String method, java.lang.Object[] args)Writes a complete method call.voidclose()abstract voidcompleteCall()Completes the method call:voidcompleteReply()protected SerializerFactoryfindSerializerFactory()Gets the serializer factory.voidflush()abstract intgetRef(java.lang.Object obj)SerializerFactorygetSerializerFactory()Gets the serializer factory.voidinit(java.io.OutputStream os)Initialize the output with a new underlying stream.booleanremoveRef(java.lang.Object obj)Removes a reference.abstract booleanreplaceRef(java.lang.Object oldRef, java.lang.Object newRef)Replaces a reference from one object to another.voidresetReferences()Resets the references for streaming.voidsetSerializerFactory(SerializerFactory factory)Sets the serializer factory.booleansetUnshared(boolean isUnshared)abstract voidstartCall()Starts the method call:abstract voidstartCall(java.lang.String method, int length)Starts the method call:voidstartReply()abstract voidwriteBoolean(boolean value)Writes a boolean value to the stream.abstract voidwriteByteBufferEnd(byte[] buffer, int offset, int length)Writes the last chunk of a byte buffer to the stream.abstract voidwriteByteBufferPart(byte[] buffer, int offset, int length)Writes a byte buffer to the stream.abstract voidwriteByteBufferStart()Writes a byte buffer to the stream.abstract voidwriteBytes(byte[] buffer)Writes a byte array to the stream.abstract voidwriteBytes(byte[] buffer, int offset, int length)Writes a byte array to the stream.voidwriteByteStream(java.io.InputStream is)Writes a full output stream.voidwriteClassFieldLength(int len)Writes the end of the class.abstract voidwriteDouble(double value)Writes a double value to the stream.voidwriteFault(java.lang.String code, java.lang.String message, java.lang.Object detail)voidwriteHeader(java.lang.String name)Deprecated.abstract voidwriteInt(int value)Writes an integer value to the stream.abstract booleanwriteListBegin(int length, java.lang.String type)Writes the list header to the stream.abstract voidwriteListEnd()Writes the tail of the list to the stream.abstract voidwriteLong(long value)Writes a long value to the stream.abstract voidwriteMapBegin(java.lang.String type)Writes the map header to the stream.abstract voidwriteMapEnd()Writes the tail of the map to the stream.abstract voidwriteMethod(java.lang.String method)Writes the method tag.abstract voidwriteNull()Writes a null value to the stream.abstract voidwriteObject(java.lang.Object object)Writes a generic object to the output stream.intwriteObjectBegin(java.lang.String type)Writes the object header to the stream (for Hessian 2.0), or a Map for Hessian 1.0.voidwriteObjectEnd()Writes the tail of the object to the stream.protected abstract voidwriteRef(int value)Writes a reference.voidwriteReply(java.lang.Object o)abstract voidwriteString(char[] buffer, int offset, int length)Writes a string value to the stream using UTF-8 encoding.abstract voidwriteString(java.lang.String value)Writes a string value to the stream using UTF-8 encoding.abstract voidwriteUTCDate(long time)Writes a date to the stream.
-
-
-
Field Detail
-
_serializerFactory
protected SerializerFactory _serializerFactory
-
-
Method Detail
-
setSerializerFactory
public void setSerializerFactory(SerializerFactory factory)
Sets the serializer factory.
-
getSerializerFactory
public SerializerFactory getSerializerFactory()
Gets the serializer factory.
-
findSerializerFactory
protected final SerializerFactory findSerializerFactory()
Gets the serializer factory.
-
init
public void init(java.io.OutputStream os)
Initialize the output with a new underlying stream.
-
setUnshared
public boolean setUnshared(boolean isUnshared)
-
call
public void call(java.lang.String method, java.lang.Object[] args) throws java.io.IOExceptionWrites a complete method call.- Throws:
java.io.IOException
-
startCall
public abstract void startCall() throws java.io.IOExceptionStarts the method call:C
- Parameters:
method- the method name to call.- Throws:
java.io.IOException
-
startCall
public abstract void startCall(java.lang.String method, int length) throws java.io.IOExceptionStarts the method call:C string int
- Parameters:
method- the method name to call.- Throws:
java.io.IOException
-
writeHeader
public void writeHeader(java.lang.String name) throws java.io.IOExceptionDeprecated.For Hessian 2.0, use the Header envelope instead- Throws:
java.io.IOException
-
writeMethod
public abstract void writeMethod(java.lang.String method) throws java.io.IOExceptionWrites the method tag.string
- Parameters:
method- the method name to call.- Throws:
java.io.IOException
-
completeCall
public abstract void completeCall() throws java.io.IOExceptionCompletes the method call:- Throws:
java.io.IOException
-
writeBoolean
public abstract void writeBoolean(boolean value) throws java.io.IOExceptionWrites 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:
java.io.IOException
-
writeInt
public abstract void writeInt(int value) throws java.io.IOExceptionWrites 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:
java.io.IOException
-
writeLong
public abstract void writeLong(long value) throws java.io.IOExceptionWrites 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:
java.io.IOException
-
writeDouble
public abstract void writeDouble(double value) throws java.io.IOExceptionWrites 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:
java.io.IOException
-
writeUTCDate
public abstract void writeUTCDate(long time) throws java.io.IOExceptionWrites 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:
java.io.IOException
-
writeNull
public abstract void writeNull() throws java.io.IOExceptionWrites a null value to the stream. The null will be written with the following syntaxN
- Parameters:
value- the string value to write.- Throws:
java.io.IOException
-
writeString
public abstract void writeString(java.lang.String value) throws java.io.IOExceptionWrites 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:
java.io.IOException
-
writeString
public abstract void writeString(char[] buffer, int offset, int length) throws java.io.IOExceptionWrites 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:
java.io.IOException
-
writeBytes
public abstract void writeBytes(byte[] buffer) throws java.io.IOExceptionWrites 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:
java.io.IOException
-
writeBytes
public abstract void writeBytes(byte[] buffer, int offset, int length) throws java.io.IOExceptionWrites 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:
java.io.IOException
-
writeByteBufferStart
public abstract void writeByteBufferStart() throws java.io.IOExceptionWrites a byte buffer to the stream.- Throws:
java.io.IOException
-
writeByteBufferPart
public abstract void writeByteBufferPart(byte[] buffer, int offset, int length) throws java.io.IOExceptionWrites a byte buffer to the stream.b b16 b18 bytes
- Parameters:
value- the string value to write.- Throws:
java.io.IOException
-
writeByteBufferEnd
public abstract void writeByteBufferEnd(byte[] buffer, int offset, int length) throws java.io.IOExceptionWrites the last chunk of a byte buffer to the stream.b b16 b18 bytes
- Parameters:
value- the string value to write.- Throws:
java.io.IOException
-
writeByteStream
public void writeByteStream(java.io.InputStream is) throws java.io.IOExceptionWrites a full output stream.- Throws:
java.io.IOException
-
writeRef
protected abstract void writeRef(int value) throws java.io.IOExceptionWrites a reference.Q int
- Parameters:
value- the integer value to write.- Throws:
java.io.IOException
-
removeRef
public boolean removeRef(java.lang.Object obj) throws java.io.IOExceptionRemoves a reference.- Throws:
java.io.IOException
-
replaceRef
public abstract boolean replaceRef(java.lang.Object oldRef, java.lang.Object newRef) throws java.io.IOExceptionReplaces a reference from one object to another.- Throws:
java.io.IOException
-
addRef
public abstract boolean addRef(java.lang.Object object) throws java.io.IOExceptionAdds 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:
java.io.IOException
-
getRef
public abstract int getRef(java.lang.Object obj)
- Parameters:
obj-- Returns:
-
resetReferences
public void resetReferences()
Resets the references for streaming.
-
writeObject
public abstract void writeObject(java.lang.Object object) throws java.io.IOExceptionWrites a generic object to the output stream.- Throws:
java.io.IOException
-
writeListBegin
public abstract boolean writeListBegin(int length, java.lang.String type) throws java.io.IOExceptionWrites the list header to the stream. List writers will callwriteListBeginfollowed by the list contents and then callwriteListEnd.V x13 java.util.ArrayList # type x93 # length=3 x91 # 1 x92 # 2 x93 # 3 </list>
- Throws:
java.io.IOException
-
writeListEnd
public abstract void writeListEnd() throws java.io.IOExceptionWrites the tail of the list to the stream.- Throws:
java.io.IOException
-
writeMapBegin
public abstract void writeMapBegin(java.lang.String type) throws java.io.IOExceptionWrites the map header to the stream. Map writers will callwriteMapBeginfollowed by the map contents and then callwriteMapEnd.M type (
)* Z - Throws:
java.io.IOException
-
writeMapEnd
public abstract void writeMapEnd() throws java.io.IOExceptionWrites the tail of the map to the stream.- Throws:
java.io.IOException
-
writeObjectBegin
public int writeObjectBegin(java.lang.String type) throws java.io.IOExceptionWrites the object header to the stream (for Hessian 2.0), or a Map for Hessian 1.0. Object writers will callwriteObjectBeginfollowed by the map contents and then callwriteObjectEnd.C type int
* C int * - Returns:
- true if the object has already been defined.
- Throws:
java.io.IOException
-
writeClassFieldLength
public void writeClassFieldLength(int len) throws java.io.IOExceptionWrites the end of the class.- Throws:
java.io.IOException
-
writeObjectEnd
public void writeObjectEnd() throws java.io.IOExceptionWrites the tail of the object to the stream.- Throws:
java.io.IOException
-
writeReply
public void writeReply(java.lang.Object o) throws java.io.IOException- Throws:
java.io.IOException
-
startReply
public void startReply() throws java.io.IOException- Throws:
java.io.IOException
-
completeReply
public void completeReply() throws java.io.IOException- Throws:
java.io.IOException
-
writeFault
public void writeFault(java.lang.String code, java.lang.String message, java.lang.Object detail) throws java.io.IOException- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Throws:
java.io.IOException
-
-