类 Hessian2Output
- java.lang.Object
-
- com.alibaba.com.caucho.hessian.io.AbstractHessianOutput
-
- com.alibaba.com.caucho.hessian.io.Hessian2Output
-
- 所有已实现的接口:
Hessian2Constants
public class Hessian2Output extends AbstractHessianOutput implements Hessian2Constants
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
-
-
字段概要
字段 修饰符和类型 字段 说明 static int
SIZE
-
从接口继承的字段 com.alibaba.com.caucho.hessian.io.Hessian2Constants
BC_BINARY, BC_BINARY_CHUNK, BC_BINARY_DIRECT, BC_BINARY_SHORT, BC_CLASS_DEF, BC_DATE, BC_DATE_MINUTE, BC_DOUBLE, BC_DOUBLE_BYTE, BC_DOUBLE_MILL, BC_DOUBLE_ONE, BC_DOUBLE_SHORT, BC_DOUBLE_ZERO, BC_END, BC_FALSE, BC_INT, BC_INT_BYTE_ZERO, BC_INT_SHORT_ZERO, BC_INT_ZERO, BC_LIST_DIRECT, BC_LIST_DIRECT_UNTYPED, BC_LIST_FIXED, BC_LIST_FIXED_UNTYPED, BC_LIST_VARIABLE, BC_LIST_VARIABLE_UNTYPED, BC_LONG, BC_LONG_BYTE_ZERO, BC_LONG_INT, BC_LONG_SHORT_ZERO, BC_LONG_ZERO, BC_MAP, BC_MAP_UNTYPED, BC_NULL, BC_OBJECT, BC_OBJECT_DEF, BC_OBJECT_DIRECT, BC_REF, BC_STRING, BC_STRING_CHUNK, BC_STRING_DIRECT, BC_STRING_SHORT, BC_TRUE, BINARY_DIRECT_MAX, BINARY_SHORT_MAX, INT_BYTE_MAX, INT_BYTE_MIN, INT_DIRECT_MAX, INT_DIRECT_MIN, INT_SHORT_MAX, INT_SHORT_MIN, LIST_DIRECT_MAX, LONG_BYTE_MAX, LONG_BYTE_MIN, LONG_DIRECT_MAX, LONG_DIRECT_MIN, LONG_SHORT_MAX, LONG_SHORT_MIN, OBJECT_DIRECT_MAX, P_PACKET, P_PACKET_CHUNK, P_PACKET_DIRECT, P_PACKET_SHORT, PACKET_DIRECT_MAX, PACKET_SHORT_MAX, STRING_DIRECT_MAX, STRING_SHORT_MAX
-
-
构造器概要
构造器 构造器 说明 Hessian2Output(OutputStream os)
Creates a new Hessian output stream, initialized with an underlying output stream.
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 boolean
addRef(Object object)
If the object has already been written, just write its ref.void
call(String method, Object[] args)
Writes a complete method call.void
close()
void
completeCall()
Completes.void
completeEnvelope()
Completes an envelope.void
completeMessage()
Completes reading the messagevoid
completeReply()
Completes reading the replyvoid
endStreamingPacket()
void
flush()
void
flushBuffer()
OutputStream
getBytesOutputStream()
Returns an output stream to write binary data.void
init(OutputStream os)
Initialize the output with a new underlying stream.boolean
isCloseStreamOnClose()
void
printLenString(String v)
Prints a string to the stream, encoded as UTF-8 with preceeding lengthvoid
printString(char[] v, int strOffset, int length)
Prints a string to the stream, encoded as UTF-8void
printString(String v)
Prints a string to the stream, encoded as UTF-8void
printString(String v, int strOffset, int length)
Prints a string to the stream, encoded as UTF-8boolean
removeRef(Object obj)
Removes a reference.boolean
replaceRef(Object oldRef, Object newRef)
Replaces a reference from one object to another.void
reset()
Resets all counters and referencesvoid
resetReferences()
Resets the references for streaming.void
setCloseStreamOnClose(boolean isClose)
void
startCall()
Writes the call tag.void
startCall(String method, int length)
Starts the method call.void
startEnvelope(String method)
Starts an envelope.void
startMessage()
Starts a packetvoid
startReply()
Starts the replyvoid
startStreamingPacket()
Starts a streaming packetvoid
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
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(String code, String message, Object detail)
Writes a fault.void
writeInt(int value)
Writes an integer value to the stream.boolean
writeListBegin(int length, 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(String type)
Writes the map header to the stream.void
writeMapEnd()
Writes the tail of the map to the stream.void
writeMethod(String method)
Writes the method tag.void
writeNull()
Writes a null value to the stream.void
writeObject(Object object)
Writes any object to the output stream.int
writeObjectBegin(String type)
Writes the object definitionvoid
writeObjectEnd()
Writes the tail of the object definition to the stream.void
writeStreamingObject(Object obj)
Starts the streaming messagevoid
writeString(char[] buffer, int offset, int length)
Writes a string value to the stream using UTF-8 encoding.void
writeString(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()
-
从类继承的方法 com.alibaba.com.caucho.hessian.io.AbstractHessianOutput
findSerializerFactory, getSerializerFactory, setSerializerFactory, writeHeader, writeReply
-
-
-
-
字段详细资料
-
SIZE
public static final int SIZE
- 另请参阅:
- 常量字段值
-
-
构造器详细资料
-
Hessian2Output
public Hessian2Output(OutputStream os)
Creates a new Hessian output stream, initialized with an underlying output stream.- 参数:
os
- the underlying output stream.
-
-
方法详细资料
-
init
public void init(OutputStream os)
从类复制的说明:AbstractHessianOutput
Initialize the output with a new underlying stream.- 覆盖:
init
在类中AbstractHessianOutput
-
reset
public void reset()
Resets all counters and references
-
isCloseStreamOnClose
public boolean isCloseStreamOnClose()
-
setCloseStreamOnClose
public void setCloseStreamOnClose(boolean isClose)
-
call
public void call(String method, Object[] args) throws IOException
Writes a complete method call.- 覆盖:
call
在类中AbstractHessianOutput
- 抛出:
IOException
-
startCall
public void startCall(String method, int length) throws IOException
Starts the method call. Clients would usestartCall
instead ofcall
if they wanted finer control over writing the arguments, or needed to write headers.C string # method name int # arg count
- 指定者:
startCall
在类中AbstractHessianOutput
- 参数:
method
- the method name to call.- 抛出:
IOException
-
startCall
public void startCall() throws IOException
Writes the call tag. This would be followed by the method and the argumentsC
- 指定者:
startCall
在类中AbstractHessianOutput
- 参数:
method
- the method name to call.- 抛出:
IOException
-
startEnvelope
public void startEnvelope(String method) throws IOException
Starts an envelope.E major minor m b16 b8 method-name
- 参数:
method
- the method name to call.- 抛出:
IOException
-
completeEnvelope
public void completeEnvelope() throws IOException
Completes an envelope.A successful completion will have a single value:
Z
- 抛出:
IOException
-
writeMethod
public void writeMethod(String method) throws IOException
Writes the method tag.string
- 指定者:
writeMethod
在类中AbstractHessianOutput
- 参数:
method
- the method name to call.- 抛出:
IOException
-
completeCall
public void completeCall() throws IOException
Completes.z
- 指定者:
completeCall
在类中AbstractHessianOutput
- 抛出:
IOException
-
startReply
public void startReply() throws IOException
Starts the replyA successful completion will have a single value:
R
- 覆盖:
startReply
在类中AbstractHessianOutput
- 抛出:
IOException
-
writeVersion
public void writeVersion() throws IOException
- 抛出:
IOException
-
completeReply
public void completeReply() throws IOException
Completes reading the replyA successful completion will have a single value:
z
- 覆盖:
completeReply
在类中AbstractHessianOutput
- 抛出:
IOException
-
startMessage
public void startMessage() throws IOException
Starts a packetA message contains several objects encapsulated by a length
p x02 x00
- 抛出:
IOException
-
completeMessage
public void completeMessage() throws IOException
Completes reading the messageA successful completion will have a single value:
z
- 抛出:
IOException
-
writeFault
public void writeFault(String code, String message, Object detail) throws IOException
Writes a fault. The fault will be written as a descriptive string followed by an object:F map
F H \x04code \x10the fault code
\x07message \x11the fault message
\x06detail M\xnnjavax.ejb.FinderException ... Z Z
- 覆盖:
writeFault
在类中AbstractHessianOutput
- 参数:
code
- the fault code, a three digit- 抛出:
IOException
-
writeObject
public void writeObject(Object object) throws IOException
Writes any object to the output stream.- 指定者:
writeObject
在类中AbstractHessianOutput
- 抛出:
IOException
-
writeListBegin
public boolean writeListBegin(int length, String type) throws IOException
Writes the list header to the stream. List writers will callwriteListBegin
followed by the list contents and then callwriteListEnd
.list ::= V type value* Z ::= v type int value*
- 指定者:
writeListBegin
在类中AbstractHessianOutput
- 返回:
- true for variable lists, false for fixed lists
- 抛出:
IOException
-
writeListEnd
public void writeListEnd() throws IOException
Writes the tail of the list to the stream for a variable-length list.- 指定者:
writeListEnd
在类中AbstractHessianOutput
- 抛出:
IOException
-
writeMapBegin
public void writeMapBegin(String type) throws IOException
Writes the map header to the stream. Map writers will callwriteMapBegin
followed by the map contents and then callwriteMapEnd
.map ::= M type (
)* Z ::= H ( )* Z - 指定者:
writeMapBegin
在类中AbstractHessianOutput
- 抛出:
IOException
-
writeMapEnd
public void writeMapEnd() throws IOException
Writes the tail of the map to the stream.- 指定者:
writeMapEnd
在类中AbstractHessianOutput
- 抛出:
IOException
-
writeObjectBegin
public int writeObjectBegin(String type) throws IOException
Writes the object definitionC <string> <int> <string>*
- 覆盖:
writeObjectBegin
在类中AbstractHessianOutput
- 返回:
- true if the object has already been defined.
- 抛出:
IOException
-
writeClassFieldLength
public void writeClassFieldLength(int len) throws IOException
Writes the tail of the class definition to the stream.- 覆盖:
writeClassFieldLength
在类中AbstractHessianOutput
- 抛出:
IOException
-
writeObjectEnd
public void writeObjectEnd() throws IOException
Writes the tail of the object definition to the stream.- 覆盖:
writeObjectEnd
在类中AbstractHessianOutput
- 抛出:
IOException
-
writeBoolean
public void writeBoolean(boolean value) throws IOException
Writes a boolean value to the stream. The boolean will be written with the following syntax:T F
- 指定者:
writeBoolean
在类中AbstractHessianOutput
- 参数:
value
- the boolean value to write.- 抛出:
IOException
-
writeInt
public 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
- 指定者:
writeInt
在类中AbstractHessianOutput
- 参数:
value
- the integer value to write.- 抛出:
IOException
-
writeLong
public 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
- 指定者:
writeLong
在类中AbstractHessianOutput
- 参数:
value
- the long value to write.- 抛出:
IOException
-
writeDouble
public 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
- 指定者:
writeDouble
在类中AbstractHessianOutput
- 参数:
value
- the double value to write.- 抛出:
IOException
-
writeUTCDate
public void writeUTCDate(long time) throws IOException
Writes a date to the stream.date ::= d b7 b6 b5 b4 b3 b2 b1 b0 ::= x65 b3 b2 b1 b0
- 指定者:
writeUTCDate
在类中AbstractHessianOutput
- 参数:
time
- the date in milliseconds from the epoch in UTC- 抛出:
IOException
-
writeNull
public void writeNull() throws IOException
Writes a null value to the stream. The null will be written with the following syntaxN
- 指定者:
writeNull
在类中AbstractHessianOutput
- 参数:
value
- the string value to write.- 抛出:
IOException
-
writeString
public 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
- 指定者:
writeString
在类中AbstractHessianOutput
- 参数:
value
- the string value to write.- 抛出:
IOException
-
writeString
public 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
- 指定者:
writeString
在类中AbstractHessianOutput
- 参数:
value
- the string value to write.- 抛出:
IOException
-
writeBytes
public 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
- 指定者:
writeBytes
在类中AbstractHessianOutput
- 参数:
value
- the string value to write.- 抛出:
IOException
-
writeBytes
public 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
- 指定者:
writeBytes
在类中AbstractHessianOutput
- 参数:
value
- the string value to write.- 抛出:
IOException
-
writeByteBufferStart
public void writeByteBufferStart() throws IOException
Writes a byte buffer to the stream.- 指定者:
writeByteBufferStart
在类中AbstractHessianOutput
- 抛出:
IOException
-
writeByteBufferPart
public void writeByteBufferPart(byte[] buffer, int offset, int length) throws IOException
Writes a byte buffer to the stream.b b16 b18 bytes
- 指定者:
writeByteBufferPart
在类中AbstractHessianOutput
- 抛出:
IOException
-
writeByteBufferEnd
public void writeByteBufferEnd(byte[] buffer, int offset, int length) throws IOException
Writes a byte buffer to the stream.b b16 b18 bytes
- 指定者:
writeByteBufferEnd
在类中AbstractHessianOutput
- 抛出:
IOException
-
getBytesOutputStream
public OutputStream getBytesOutputStream() throws IOException
Returns an output stream to write binary data.- 抛出:
IOException
-
addRef
public boolean addRef(Object object) throws IOException
If the object has already been written, just write its ref.- 指定者:
addRef
在类中AbstractHessianOutput
- 参数:
object
- the object to add as a reference.- 返回:
- true if we're writing a ref.
- 抛出:
IOException
-
removeRef
public boolean removeRef(Object obj) throws IOException
Removes a reference.- 指定者:
removeRef
在类中AbstractHessianOutput
- 抛出:
IOException
-
replaceRef
public boolean replaceRef(Object oldRef, Object newRef) throws IOException
Replaces a reference from one object to another.- 指定者:
replaceRef
在类中AbstractHessianOutput
- 抛出:
IOException
-
resetReferences
public void resetReferences()
Resets the references for streaming.- 覆盖:
resetReferences
在类中AbstractHessianOutput
-
writeStreamingObject
public void writeStreamingObject(Object obj) throws IOException
Starts the streaming messageA streaming message starts with 'P'
P x02 x00
- 抛出:
IOException
-
startStreamingPacket
public void startStreamingPacket() throws IOException
Starts a streaming packetA streaming message starts with 'P'
P x02 x00
- 抛出:
IOException
-
endStreamingPacket
public void endStreamingPacket() throws IOException
- 抛出:
IOException
-
printLenString
public void printLenString(String v) throws IOException
Prints a string to the stream, encoded as UTF-8 with preceeding length- 参数:
v
- the string to print.- 抛出:
IOException
-
printString
public void printString(String v) throws IOException
Prints a string to the stream, encoded as UTF-8- 参数:
v
- the string to print.- 抛出:
IOException
-
printString
public void printString(String v, int strOffset, int length) throws IOException
Prints a string to the stream, encoded as UTF-8- 参数:
v
- the string to print.- 抛出:
IOException
-
printString
public void printString(char[] v, int strOffset, int length) throws IOException
Prints a string to the stream, encoded as UTF-8- 参数:
v
- the string to print.- 抛出:
IOException
-
flush
public final void flush() throws IOException
- 覆盖:
flush
在类中AbstractHessianOutput
- 抛出:
IOException
-
flushBuffer
public final void flushBuffer() throws IOException
- 抛出:
IOException
-
close
public final void close() throws IOException
- 覆盖:
close
在类中AbstractHessianOutput
- 抛出:
IOException
-
-