com.caucho.hessian.io

Class AbstractHessianOutput

Known Direct Subclasses:
HessianOutput

public abstract class AbstractHessianOutput
extends java.lang.Object

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

protected SerializerFactory
_serializerFactory

Method Summary

abstract boolean
addRef(Object object)
Adds an object to the reference list.
abstract void
completeCall()
Writes the method call:
 z
 
abstract void
init(OutputStream os)
Initialize the output with a new underlying stream.
abstract boolean
removeRef(Object obj)
Removes a reference.
abstract boolean
replaceRef(Object oldRef, Object newRef)
Replaces a reference from one object to another.
void
setSerializerFactory(SerializerFactory factory)
Sets the serializer factory.
abstract void
startCall(String method)
Writes the method call:
 c major minor
 m b16 b8 method-namek
 
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
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.
abstract void
writeDouble(double value)
Writes a double value to the stream.
abstract void
writeInt(int value)
Writes an integer value to the stream.
abstract void
writeListBegin(int length, String type)
Writes the list header to the stream.
abstract void
writeListEnd()
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
writeMapEnd()
Writes the tail of the map to the stream.
abstract void
writeNull()
Writes a null value to the stream.
abstract void
writeObject(Object object)
Writes a generic object to the output stream.
abstract void
writeRef(int value)
Writes a reference.
abstract void
writeRemote(String type, String url)
Writes a remote object reference to the stream.
abstract void
writeString(String value)
Writes a string value to the stream using UTF-8 encoding.
abstract void
writeString(char[] buffer, int offset, int length)
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

protected SerializerFactory _serializerFactory

Method Details

addRef

public abstract boolean addRef(Object object)
            throws IOException
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.

completeCall

public abstract void completeCall()
            throws IOException
Writes the method call:
 z
 

init

public abstract void init(OutputStream os)
Initialize the output with a new underlying stream.

removeRef

public abstract boolean removeRef(Object obj)
            throws IOException
Removes a reference.

replaceRef

public abstract boolean replaceRef(Object oldRef,
                                   Object newRef)
            throws IOException
Replaces a reference from one object to another.

setSerializerFactory

public void setSerializerFactory(SerializerFactory factory)
Sets the serializer factory.

startCall

public abstract void startCall(String method)
            throws IOException
Writes the method call:
 c major minor
 m b16 b8 method-namek
 
Parameters:
method - the method name to call.

writeBoolean

public abstract void writeBoolean(boolean value)
            throws IOException
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.

writeByteBufferEnd

public abstract void writeByteBufferEnd(byte[] buffer,
                                        int offset,
                                        int length)
            throws IOException
Writes the last chunk of a byte buffer to the stream.
 b b16 b18 bytes
 
Parameters:

writeByteBufferPart

public abstract void writeByteBufferPart(byte[] buffer,
                                         int offset,
                                         int length)
            throws IOException
Writes a byte buffer to the stream.
 b b16 b18 bytes
 
Parameters:

writeBytes

public abstract void writeBytes(byte[] buffer)
            throws IOException
Writes a byte array to the stream. The array will be written with the following syntax:
 B b16 b18 bytes
 
If the value is null, it will be written as
 N
 
Parameters:

writeBytes

public abstract void writeBytes(byte[] buffer,
                                int offset,
                                int length)
            throws IOException
Writes a byte array to the stream. The array will be written with the following syntax:
 B b16 b18 bytes
 
If the value is null, it will be written as
 N
 
Parameters:

writeDouble

public abstract void writeDouble(double value)
            throws IOException
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.

writeInt

public abstract void writeInt(int value)
            throws IOException
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.

writeListBegin

public abstract void writeListBegin(int length,
                                    String type)
            throws IOException
Writes the list header to the stream. List writers will call 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>
 

writeListEnd

public abstract void writeListEnd()
            throws IOException
Writes the tail of the list to the stream.

writeLong

public abstract void writeLong(long value)
            throws IOException
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.

writeMapBegin

public abstract void writeMapBegin(String type)
            throws IOException
Writes the map header to the stream. Map writers will call writeMapBegin followed by the map contents and then call writeMapEnd.
 Mt b16 b8 type ( )z
 

writeMapEnd

public abstract void writeMapEnd()
            throws IOException
Writes the tail of the map to the stream.

writeNull

public abstract void writeNull()
            throws IOException
Writes a null value to the stream. The null will be written with the following syntax
 N
 
Parameters:

writeObject

public abstract void writeObject(Object object)
            throws IOException
Writes a generic object to the output stream.

writeRef

public abstract void writeRef(int value)
            throws IOException
Writes a reference.
 R b32 b24 b16 b8
 
Parameters:
value - the integer value to write.

writeRemote

public abstract void writeRemote(String type,
                                 String url)
            throws IOException
Writes a remote object reference to the stream. The type is the type of the remote interface.
 'r' 't' b16 b8 type url
 

writeString

public abstract void writeString(String value)
            throws IOException
Writes a string value to the stream using UTF-8 encoding. The string will be written with the following syntax:
 S b16 b8 string-value
 
If the value is null, it will be written as
 N
 
Parameters:
value - the string value to write.

writeString

public abstract void writeString(char[] buffer,
                                 int offset,
                                 int length)
            throws IOException
Writes a string value to the stream using UTF-8 encoding. The string will be written with the following syntax:
 S b16 b8 string-value
 
If the value is null, it will be written as
 N
 
Parameters:

writeUTCDate

public abstract void writeUTCDate(long time)
            throws IOException
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