Package com.caucho.burlap.io
Class BurlapOutput
java.lang.Object
com.caucho.hessian.io.AbstractHessianOutput
com.caucho.burlap.io.AbstractBurlapOutput
com.caucho.burlap.io.BurlapOutput
Output stream for Burlap requests, compatible with microedition
Java. It only uses classes and types available in JDK.
Since BurlapOutput does not depend on any classes other than in the JDK, it can be extracted independently into a smaller package.
BurlapOutput is unbuffered, so any client needs to provide its own buffering.
OutputStream os = ...; // from http connection BurlapOutput out = new BurlapOutput(os); String value; out.startCall("hello"); // start hello call out.writeString("arg1"); // write a string argument out.completeCall(); // complete the call
-
Field Summary
FieldsFields inherited from class com.caucho.hessian.io.AbstractHessianOutput
_serializerFactory
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an uninitialized Burlap output stream.Creates a new Burlap output stream, initialized with an underlying output stream. -
Method Summary
Modifier and TypeMethodDescriptionboolean
If the object has already been written, just write its ref.void
Writes a complete method call.void
Completes.void
Completes reading the replyint
void
init
(OutputStream os) Initializes the outputprotected void
print
(char v) Prints a char to the stream.protected void
print
(double v) Prints a double to the stream.protected void
print
(int v) Prints an integer to the stream.protected void
print
(long v) Prints a long to the stream.protected void
Prints a string as ascii to the stream.void
Prints a date.void
printString
(char[] v, int offset, int length) Prints a string to the stream, encoded as UTF-8void
Prints a string to the stream, encoded as UTF-8void
printString
(String v, int offset, int length) Prints a string to the stream, encoded as UTF-8boolean
Removes a reference.boolean
replaceRef
(Object oldRef, Object newRef) Replaces a reference from one object to another.void
Starts the method call.void
Starts the method call.void
Starts the replyvoid
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
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
writeDouble
(double value) Writes a double value to the stream.void
writeFault
(String code, String message, Object detail) Writes a fault.void
writeHeader
(String name) Writes a header name.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
Writes the tail of the list to the stream.void
writeLong
(long value) Writes a long value to the stream.void
writeMapBegin
(String type) Writes the map header to the stream.void
Writes the tail of the map to the stream.void
writeMethod
(String method) Writes the method for a call.void
Writes a null value to the stream.void
writeObject
(Object object) Writes any object to the output stream.void
writeRef
(int value) Writes a reference.void
writeRemote
(String type, String url) Writes a remote object reference to the stream.void
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.Methods inherited from class com.caucho.burlap.io.AbstractBurlapOutput
startCall
Methods inherited from class com.caucho.hessian.io.AbstractHessianOutput
close, findSerializerFactory, flush, getSerializerFactory, resetReferences, setSerializerFactory, setUnshared, writeByteStream, writeClassFieldLength, writeObjectBegin, writeObjectEnd, writeReply
-
Field Details
-
os
-
-
Constructor Details
-
BurlapOutput
Creates a new Burlap output stream, initialized with an underlying output stream.- Parameters:
os
- the underlying output stream.
-
BurlapOutput
public BurlapOutput()Creates an uninitialized Burlap output stream.
-
-
Method Details
-
init
Initializes the output- Overrides:
init
in classAbstractHessianOutput
-
call
Writes a complete method call.- Overrides:
call
in classAbstractHessianOutput
- Throws:
IOException
-
startCall
Starts the method call. Clients would usestartCall
instead ofcall
if they wanted finer control over writing the arguments, or needed to write headers.<burlap:call> <method>method-name</method>
- Parameters:
method
- the method name to call.- Throws:
IOException
-
startCall
Starts the method call. Clients would usestartCall
instead ofcall
if they wanted finer control over writing the arguments, or needed to write headers.<method>method-name</method>
- Specified by:
startCall
in classAbstractHessianOutput
- Parameters:
method
- the method name to call.- Throws:
IOException
-
writeMethod
Writes the method for a call.<method>value</method>
- Specified by:
writeMethod
in classAbstractHessianOutput
- Parameters:
method
- the method name to call.- Throws:
IOException
-
completeCall
Completes.</burlap:call>
- Specified by:
completeCall
in classAbstractHessianOutput
- Throws:
IOException
-
startReply
Starts the replyA successful completion will have a single value:
r
- Overrides:
startReply
in classAbstractHessianOutput
- Throws:
IOException
-
completeReply
Completes reading the replyA successful completion will have a single value:
</burlap:reply>
- Overrides:
completeReply
in classAbstractHessianOutput
- Throws:
IOException
-
writeHeader
Writes a header name. The header value must immediately follow.<header>foo</header><int>value</int>
- Overrides:
writeHeader
in classAbstractHessianOutput
- Throws:
IOException
-
writeFault
Writes a fault. The fault will be written as a descriptive string followed by an object:<fault> <string>code <string>the fault code <string>message <string>the fault mesage <string>detail <map>t\x00\xnnjavax.ejb.FinderException ... </map> </fault>
- Overrides:
writeFault
in classAbstractHessianOutput
- Parameters:
code
- the fault code, a three digit- Throws:
IOException
-
writeObject
Writes any object to the output stream.- Specified by:
writeObject
in classAbstractHessianOutput
- Throws:
IOException
-
writeListBegin
Writes the list header to the stream. List writers will callwriteListBegin
followed by the list contents and then callwriteListEnd
.<list> <type>java.util.ArrayList</type> <length>3</length> <int>1</int> <int>2</int> <int>3</int> </list>
- Specified by:
writeListBegin
in classAbstractHessianOutput
- Throws:
IOException
-
writeListEnd
Writes the tail of the list to the stream.- Specified by:
writeListEnd
in classAbstractHessianOutput
- Throws:
IOException
-
writeMapBegin
Writes the map header to the stream. Map writers will callwriteMapBegin
followed by the map contents and then callwriteMapEnd
.<map> <type>type</type> (<key> <value>)* </map>
- Specified by:
writeMapBegin
in classAbstractHessianOutput
- Throws:
IOException
-
writeMapEnd
Writes the tail of the map to the stream.- Specified by:
writeMapEnd
in classAbstractHessianOutput
- Throws:
IOException
-
writeRemote
Writes a remote object reference to the stream. The type is the type of the remote interface.<remote> <type>test.account.Account</type> <string>http://caucho.com/foo;ejbid=bar</string> </remote>
- Throws:
IOException
-
writeBoolean
Writes a boolean value to the stream. The boolean will be written with the following syntax:<boolean>0</boolean> <boolean>1</boolean>
- Specified by:
writeBoolean
in classAbstractHessianOutput
- 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:<int>int value</int>
- Specified by:
writeInt
in classAbstractHessianOutput
- 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:<long>int value</long>
- Specified by:
writeLong
in classAbstractHessianOutput
- 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:<double>value</double>
- Specified by:
writeDouble
in classAbstractHessianOutput
- Parameters:
value
- the double value to write.- Throws:
IOException
-
writeUTCDate
Writes a date to the stream.<date>iso8901</date>
- Specified by:
writeUTCDate
in classAbstractHessianOutput
- 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 syntax<null></null>
- Specified by:
writeNull
in classAbstractHessianOutput
- 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 as<string>string-value</string>
<null></null>
- Specified by:
writeString
in classAbstractHessianOutput
- 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
- Specified by:
writeString
in classAbstractHessianOutput
- 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 as<base64>bytes</base64>
<null></null>
- Specified by:
writeBytes
in classAbstractHessianOutput
- 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 as<base64>bytes</base64>
<null></null>
- Specified by:
writeBytes
in classAbstractHessianOutput
- Parameters:
value
- the string value to write.- Throws:
IOException
-
writeByteBufferStart
Writes a byte buffer to the stream.- Specified by:
writeByteBufferStart
in classAbstractHessianOutput
- Throws:
IOException
-
writeByteBufferPart
Writes a byte buffer to the stream.b b16 b18 bytes
- Specified by:
writeByteBufferPart
in classAbstractHessianOutput
- Throws:
IOException
-
writeByteBufferEnd
Writes a byte buffer to the stream.b b16 b18 bytes
- Specified by:
writeByteBufferEnd
in classAbstractHessianOutput
- Throws:
IOException
-
writeRef
Writes a reference.<ref>int</ref>
- Specified by:
writeRef
in classAbstractHessianOutput
- Parameters:
value
- the integer value to write.- Throws:
IOException
-
addRef
If the object has already been written, just write its ref.- Specified by:
addRef
in classAbstractHessianOutput
- Parameters:
object
- the object to add as a reference.- Returns:
- true if we're writing a ref.
- Throws:
IOException
-
getRef
- Specified by:
getRef
in classAbstractHessianOutput
- Returns:
-
removeRef
Removes a reference.- Overrides:
removeRef
in classAbstractHessianOutput
- Throws:
IOException
-
replaceRef
Replaces a reference from one object to another.- Specified by:
replaceRef
in classAbstractHessianOutput
- Throws:
IOException
-
printString
Prints a string to the stream, encoded as UTF-8- Parameters:
v
- the string to print.- Throws:
IOException
-
printString
Prints a string to the stream, encoded as UTF-8- Parameters:
v
- the string to print.- Throws:
IOException
-
printString
Prints a string to the stream, encoded as UTF-8- Parameters:
v
- the string to print.- Throws:
IOException
-
printDate
Prints a date.- Parameters:
date
- the date to print.- Throws:
IOException
-
print
Prints a char to the stream.- Parameters:
v
- the char to print.- Throws:
IOException
-
print
Prints an integer to the stream.- Parameters:
v
- the integer to print.- Throws:
IOException
-
print
Prints a long to the stream.- Parameters:
v
- the long to print.- Throws:
IOException
-
print
Prints a double to the stream.- Parameters:
v
- the double to print.- Throws:
IOException
-
print
Prints a string as ascii to the stream. Used for tags, etc. that are known to the ascii.- Parameters:
s
- the ascii string to print.- Throws:
IOException
-