|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.caucho.hessian.io.AbstractHessianOutput
com.caucho.hessian.io.Hessian2Output
public class Hessian2Output
Output stream for Hessian 2 requests.
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
Hessian2Output out = new Hessian2Output(os);
String value;
out.startCall("hello", 1); // start hello call
out.writeString("arg1"); // write a string argument
out.completeCall(); // complete the call
| Field Summary | |
|---|---|
protected java.io.OutputStream |
_os
|
static int |
SIZE
|
| Fields inherited from class com.caucho.hessian.io.AbstractHessianOutput |
|---|
_serializerFactory |
| Constructor Summary | |
|---|---|
Hessian2Output(java.io.OutputStream os)
Creates a new Hessian output stream, initialized with an underlying output stream. |
|
| Method Summary | |
|---|---|
boolean |
addRef(java.lang.Object object)
If the object has already been written, just write its ref. |
void |
call(java.lang.String method,
java.lang.Object[] args)
Writes a complete method call. |
void |
close()
|
void |
completeCall()
Completes. |
void |
completeEnvelope()
Completes an envelope. |
void |
completeMessage()
Completes reading the message A successful completion will have a single value: z |
void |
completeReply()
Completes reading the reply A successful completion will have a single value: z |
void |
endPacket()
|
void |
flush()
|
void |
flushBuffer()
|
void |
free()
|
java.io.OutputStream |
getBytesOutputStream()
Returns an output stream to write binary data. |
int |
getRef(java.lang.Object obj)
|
void |
init(java.io.OutputStream os)
Initialize the output with a new underlying stream. |
boolean |
isCloseStreamOnClose()
|
void |
printLenString(java.lang.String v)
Prints a string to the stream, encoded as UTF-8 with preceeding length |
void |
printString(char[] v,
int strOffset,
int length)
Prints a string to the stream, encoded as UTF-8 |
void |
printString(java.lang.String v)
Prints a string to the stream, encoded as UTF-8 |
void |
printString(java.lang.String v,
int strOffset,
int length)
Prints a string to the stream, encoded as UTF-8 |
boolean |
removeRef(java.lang.Object obj)
Removes a reference. |
boolean |
replaceRef(java.lang.Object oldRef,
java.lang.Object newRef)
Replaces a reference from one object to another. |
void |
reset()
Resets all counters and references |
void |
resetReferences()
Resets the references for streaming. |
void |
setCloseStreamOnClose(boolean isClose)
|
void |
startCall()
Writes the call tag. |
void |
startCall(java.lang.String method,
int length)
Starts the method call. |
void |
startEnvelope(java.lang.String method)
Starts an envelope. |
void |
startMessage()
Starts a packet A message contains several objects encapsulated by a length p x02 x00 |
void |
startPacket()
Starts a streaming packet A streaming contains a set of chunks, ending with a zero chunk. |
void |
startReply()
Starts the reply A successful completion will have a single value: R |
void |
writeBoolean(boolean value)
Writes a boolean value to the stream. |
void |
writeByteBufferEnd(byte[] buffer,
int offset,
int length)
Writes a byte buffer to the stream. |
void |
writeByteBufferPart(byte[] buffer,
int offset,
int length)
Writes a byte buffer to the stream. |
void |
writeByteBufferStart()
Writes a byte buffer to the stream. |
void |
writeBytes(byte[] buffer)
Writes a byte array to the stream. |
void |
writeBytes(byte[] buffer,
int offset,
int length)
Writes a byte array to the stream. |
void |
writeByteStream(java.io.InputStream is)
Writes a full output stream. |
void |
writeClassFieldLength(int len)
Writes the tail of the class definition to the stream. |
void |
writeDouble(double value)
Writes a double value to the stream. |
void |
writeFault(java.lang.String code,
java.lang.String message,
java.lang.Object detail)
Writes a fault. |
void |
writeInt(int value)
Writes an integer value to the stream. |
boolean |
writeListBegin(int length,
java.lang.String type)
Writes the list header to the stream. |
void |
writeListEnd()
Writes the tail of the list to the stream for a variable-length list. |
void |
writeLong(long value)
Writes a long value to the stream. |
void |
writeMapBegin(java.lang.String type)
Writes the map header to the stream. |
void |
writeMapEnd()
Writes the tail of the map to the stream. |
void |
writeMethod(java.lang.String method)
Writes the method tag. |
void |
writeNull()
Writes a null value to the stream. |
void |
writeObject(java.lang.Object object)
Writes any object to the output stream. |
int |
writeObjectBegin(java.lang.String type)
Writes the object definition
C <string> <int> <string>*
|
void |
writeObjectEnd()
Writes the tail of the object definition to the stream. |
protected void |
writeRef(int value)
Writes a reference. |
void |
writeStreamingObject(java.lang.Object obj)
Starts the streaming message A streaming message starts with 'P' P x02 x00 |
void |
writeString(char[] buffer,
int offset,
int length)
Writes a string value to the stream using UTF-8 encoding. |
void |
writeString(java.lang.String value)
Writes a string value to the stream using UTF-8 encoding. |
void |
writeUTCDate(long time)
Writes a date to the stream. |
void |
writeVersion()
|
| Methods inherited from class com.caucho.hessian.io.AbstractHessianOutput |
|---|
findSerializerFactory, getSerializerFactory, setSerializerFactory, writeHeader, writeReply |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int SIZE
protected java.io.OutputStream _os
| Constructor Detail |
|---|
public Hessian2Output(java.io.OutputStream os)
os - the underlying output stream.| Method Detail |
|---|
public void init(java.io.OutputStream os)
AbstractHessianOutput
init in class AbstractHessianOutputpublic void setCloseStreamOnClose(boolean isClose)
public boolean isCloseStreamOnClose()
public void call(java.lang.String method,
java.lang.Object[] args)
throws java.io.IOException
call in class AbstractHessianOutputjava.io.IOException
public void startCall(java.lang.String method,
int length)
throws java.io.IOException
startCall
instead of call if they wanted finer control over
writing the arguments, or needed to write headers.
C
string # method name
int # arg count
startCall in class AbstractHessianOutputmethod - the method name to call.
java.io.IOException
public void startCall()
throws java.io.IOException
C
startCall in class AbstractHessianOutputmethod - the method name to call.
java.io.IOException
public void startEnvelope(java.lang.String method)
throws java.io.IOException
E major minor
m b16 b8 method-name
method - the method name to call.
java.io.IOException
public void completeEnvelope()
throws java.io.IOException
A successful completion will have a single value:
Z
java.io.IOException
public void writeMethod(java.lang.String method)
throws java.io.IOException
string
writeMethod in class AbstractHessianOutputmethod - the method name to call.
java.io.IOException
public void completeCall()
throws java.io.IOException
z
completeCall in class AbstractHessianOutputjava.io.IOException
public void startReply()
throws java.io.IOException
A successful completion will have a single value:
R
startReply in class AbstractHessianOutputjava.io.IOException
public void writeVersion()
throws java.io.IOException
java.io.IOException
public void completeReply()
throws java.io.IOException
A successful completion will have a single value:
z
completeReply in class AbstractHessianOutputjava.io.IOException
public void startMessage()
throws java.io.IOException
A message contains several objects encapsulated by a length
p x02 x00
java.io.IOException
public void completeMessage()
throws java.io.IOException
A successful completion will have a single value:
z
java.io.IOException
public void writeFault(java.lang.String code,
java.lang.String message,
java.lang.Object detail)
throws java.io.IOException
F map
F H
\x04code
\x10the fault code
\x07message
\x11the fault message
\x06detail
M\xnnjavax.ejb.FinderException
...
Z
Z
writeFault in class AbstractHessianOutputcode - the fault code, a three digit
java.io.IOException
public void writeObject(java.lang.Object object)
throws java.io.IOException
writeObject in class AbstractHessianOutputjava.io.IOException
public boolean writeListBegin(int length,
java.lang.String type)
throws java.io.IOException
writeListBegin followed by the list contents and then
call writeListEnd.
list ::= V type value* Z
::= v type int value*
writeListBegin in class AbstractHessianOutputjava.io.IOException
public void writeListEnd()
throws java.io.IOException
writeListEnd in class AbstractHessianOutputjava.io.IOException
public void writeMapBegin(java.lang.String type)
throws java.io.IOException
writeMapBegin followed by the map contents and then
call writeMapEnd.
map ::= M type ( )* Z
::= H ( )* Z
writeMapBegin in class AbstractHessianOutputjava.io.IOException
public void writeMapEnd()
throws java.io.IOException
writeMapEnd in class AbstractHessianOutputjava.io.IOException
public int writeObjectBegin(java.lang.String type)
throws java.io.IOException
C <string> <int> <string>*
writeObjectBegin in class AbstractHessianOutputjava.io.IOException
public void writeClassFieldLength(int len)
throws java.io.IOException
writeClassFieldLength in class AbstractHessianOutputjava.io.IOException
public void writeObjectEnd()
throws java.io.IOException
writeObjectEnd in class AbstractHessianOutputjava.io.IOException
public void writeBoolean(boolean value)
throws java.io.IOException
T
F
writeBoolean in class AbstractHessianOutputvalue - the boolean value to write.
java.io.IOException
public void writeInt(int value)
throws java.io.IOException
I b32 b24 b16 b8
writeInt in class AbstractHessianOutputvalue - the integer value to write.
java.io.IOException
public void writeLong(long value)
throws java.io.IOException
L b64 b56 b48 b40 b32 b24 b16 b8
writeLong in class AbstractHessianOutputvalue - the long value to write.
java.io.IOException
public void writeDouble(double value)
throws java.io.IOException
D b64 b56 b48 b40 b32 b24 b16 b8
writeDouble in class AbstractHessianOutputvalue - the double value to write.
java.io.IOException
public void writeUTCDate(long time)
throws java.io.IOException
date ::= d b7 b6 b5 b4 b3 b2 b1 b0
::= x65 b3 b2 b1 b0
writeUTCDate in class AbstractHessianOutputtime - the date in milliseconds from the epoch in UTC
java.io.IOException
public void writeNull()
throws java.io.IOException
N
writeNull in class AbstractHessianOutputvalue - the string value to write.
java.io.IOException
public void writeString(java.lang.String value)
throws java.io.IOException
S b16 b8 string-value
If the value is null, it will be written as
N
writeString in class AbstractHessianOutputvalue - the string value to write.
java.io.IOException
public void writeString(char[] buffer,
int offset,
int length)
throws java.io.IOException
S b16 b8 string-value
If the value is null, it will be written as
N
writeString in class AbstractHessianOutputvalue - the string value to write.
java.io.IOException
public void writeBytes(byte[] buffer)
throws java.io.IOException
B b16 b18 bytes
If the value is null, it will be written as
N
writeBytes in class AbstractHessianOutputvalue - the string value to write.
java.io.IOException
public void writeBytes(byte[] buffer,
int offset,
int length)
throws java.io.IOException
B b16 b18 bytes
If the value is null, it will be written as
N
writeBytes in class AbstractHessianOutputvalue - the string value to write.
java.io.IOException
public void writeByteBufferStart()
throws java.io.IOException
writeByteBufferStart in class AbstractHessianOutputjava.io.IOException
public void writeByteBufferPart(byte[] buffer,
int offset,
int length)
throws java.io.IOException
b b16 b18 bytes
writeByteBufferPart in class AbstractHessianOutputjava.io.IOException
public void writeByteBufferEnd(byte[] buffer,
int offset,
int length)
throws java.io.IOException
b b16 b18 bytes
writeByteBufferEnd in class AbstractHessianOutputjava.io.IOException
public java.io.OutputStream getBytesOutputStream()
throws java.io.IOException
java.io.IOException
public void writeByteStream(java.io.InputStream is)
throws java.io.IOException
writeByteStream in class AbstractHessianOutputjava.io.IOException
protected void writeRef(int value)
throws java.io.IOException
x51 <int>
writeRef in class AbstractHessianOutputvalue - the integer value to write.
java.io.IOException
public boolean addRef(java.lang.Object object)
throws java.io.IOException
addRef in class AbstractHessianOutputobject - the object to add as a reference.
java.io.IOExceptionpublic int getRef(java.lang.Object obj)
getRef in class AbstractHessianOutput
public boolean removeRef(java.lang.Object obj)
throws java.io.IOException
removeRef in class AbstractHessianOutputjava.io.IOException
public boolean replaceRef(java.lang.Object oldRef,
java.lang.Object newRef)
throws java.io.IOException
replaceRef in class AbstractHessianOutputjava.io.IOException
public void writeStreamingObject(java.lang.Object obj)
throws java.io.IOException
A streaming message starts with 'P'
P x02 x00
java.io.IOException
public void startPacket()
throws java.io.IOException
A streaming contains a set of chunks, ending with a zero chunk. Each chunk is a length followed by data where the length is encoded by (b1xxxxxxxx)* b0xxxxxxxx
java.io.IOException
public void endPacket()
throws java.io.IOException
java.io.IOException
public void printLenString(java.lang.String v)
throws java.io.IOException
v - the string to print.
java.io.IOException
public void printString(java.lang.String v)
throws java.io.IOException
v - the string to print.
java.io.IOException
public void printString(java.lang.String v,
int strOffset,
int length)
throws java.io.IOException
v - the string to print.
java.io.IOException
public void printString(char[] v,
int strOffset,
int length)
throws java.io.IOException
v - the string to print.
java.io.IOException
public final void flush()
throws java.io.IOException
flush in class AbstractHessianOutputjava.io.IOException
public final void flushBuffer()
throws java.io.IOException
java.io.IOException
public void close()
throws java.io.IOException
close in class AbstractHessianOutputjava.io.IOExceptionpublic void free()
public void resetReferences()
resetReferences in class AbstractHessianOutputpublic void reset()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||