com.caucho.hessian.io

Class HessianInput

Known Direct Subclasses:
HessianSerializerInput

public class HessianInput
extends AbstractHessianInput

Input stream for Hessian requests.

HessianInput is unbuffered, so any client needs to provide its own buffering.

 InputStream is = ...; // from http connection
 HessianInput in = new HessianInput(is);
 String value;

 in.startReply();         // read reply header
 value = in.readString(); // read string value
 in.completeReply();      // read reply footer
 

Field Summary

private static int
END_OF_DATA
private InputStream
_chunkInputStream
private int
_chunkLength
private Reader
_chunkReader
private static Field
_detailMessageField
private InputStream
_is
private boolean
_isLastChunk
private String
_method
protected int
_peek
protected ArrayList
_refs
private Throwable
_replyFault
protected SerializerFactory
_serializerFactory

Fields inherited from class com.caucho.hessian.io.AbstractHessianInput

resolver

Constructor Summary

HessianInput()
Creates an uninitialized Hessian input stream.
HessianInput(InputStream is)
Creates a new Hessian input stream, initialized with an underlying input stream.

Method Summary

int
addRef(Object ref)
Adds a list/map reference.
void
completeCall()
Completes reading the call

A successful completion will have a single value:

 z
 
void
completeReply()
Completes reading the call

A successful completion will have a single value:

 z
 
void
completeValueReply()
Completes reading the call

A successful completion will have a single value:

 z
 
protected IOException
error(String message)
protected IOException
expect(String expect, int ch)
String
getMethod()
Returns the calls method
Reader
getReader()
Starts reading a string.
Throwable
getReplyFault()
Returns any reply fault.
SerializerFactory
getSerializerFactory()
Gets the serializer factory.
void
init(InputStream is)
Initialize the hessian stream with the underlying input stream.
boolean
isEnd()
Returns true if this is the end of a list or a map.
private int
parseByte()
Reads a byte from the underlying stream.
private int
parseChar()
Reads a character from the underlying stream.
private double
parseDouble()
Parses a 64-bit double value from the stream.
private int
parseInt()
Parses a 32-bit integer value from the stream.
private long
parseLong()
Parses a 64-bit long value from the stream.
private int
parseUTF8Char()
Parses a single UTF8 character.
(package private) org.w3c.dom.Node
parseXML()
private Throwable
prepareFault()
Prepares the fault.
(package private) int
read()
(package private) int
read(byte[] buffer, int offset, int length)
Reads bytes from the underlying stream.
boolean
readBoolean()
Reads a boolean
 T
 F
 
int
readByte()
Reads a byte from the stream.
byte[]
readBytes()
Reads a byte array
 B b16 b8 data value
 
int
readBytes(byte[] buffer, int offset, int length)
Reads a byte array from the stream.
int
readCall()
Starts reading the call
 c major minor
 
int
readChar()
Reads a byte from the stream.
double
readDouble()
Reads a double
 D b64 b56 b48 b40 b32 b24 b16 b8
 
void
readEnd()
Reads the end byte.
private HashMap
readFault()
Reads a fault.
float
readFloat()
Reads a float
 D b64 b56 b48 b40 b32 b24 b16 b8
 
String
readHeader()
Reads a header, returning null if there are no headers.
InputStream
readInputStream()
Reads bytes based on an input stream.
int
readInt()
Reads an integer
 I b32 b24 b16 b8
 
int
readLength()
Parses the length for an array
 l b32 b24 b16 b8
 
void
readListEnd()
Reads the end byte.
int
readListStart()
Reads the start of a list.
long
readLong()
Reads a long
 L b64 b56 b48 b40 b32 b24 b16 b8
 
void
readMapEnd()
Reads the end byte.
int
readMapStart()
Reads the start of a list.
String
readMethod()
Starts reading the call

A successful completion will have a single value:

 m b16 b8 method
 
org.w3c.dom.Node
readNode()
Reads an XML node.
void
readNull()
Reads a null
 N
 
Object
readObject()
Reads an arbitrary object from the input stream when the type is unknown.
Object
readObject(Class cl)
Reads an object from the input stream with an expected type.
Object
readRef()
Reads a reference.
Object
readRemote()
Reads a remote object.
Object
readReply(Class expectedClass)
Reads a reply as an object.
short
readShort()
Reads a short
 I b32 b24 b16 b8
 
String
readString()
Reads a string
 S b16 b8 string value
 
int
readString(char[] buffer, int offset, int length)
Reads a byte array from the stream.
String
readType()
Parses a type from the stream.
long
readUTCDate()
Reads a date.
Object
resolveRemote(String type, String url)
Resolves a remote object.
void
setRef(int i, Object ref)
Adds a list/map reference.
void
setSerializerFactory(SerializerFactory factory)
Sets the serializer factory.
void
startCall()
Starts reading the call

A successful completion will have a single value:

 c major minor
 m b16 b8 method
 
void
startReply()
Starts reading the reply

A successful completion will have a single value:

 r
 

Methods inherited from class com.caucho.hessian.io.AbstractHessianInput

addRef, completeCall, completeReply, getMethod, getReader, getRemoteResolver, init, isEnd, readBoolean, readBytes, readDouble, readEnd, readInputStream, readInt, readLength, readListEnd, readListStart, readLong, readMapEnd, readMapStart, readNode, readNull, readObject, readObject, readRef, readRemote, readReply, readString, readType, readUTCDate, setRef, setRemoteResolver, startCall, startReply

Field Details

END_OF_DATA

private static int END_OF_DATA

_chunkInputStream

private InputStream _chunkInputStream

_chunkLength

private int _chunkLength

_chunkReader

private Reader _chunkReader

_detailMessageField

private static Field _detailMessageField

_is

private InputStream _is

_isLastChunk

private boolean _isLastChunk

_method

private String _method

_peek

protected int _peek

_refs

protected ArrayList _refs

_replyFault

private Throwable _replyFault

_serializerFactory

protected SerializerFactory _serializerFactory

Constructor Details

HessianInput

public HessianInput()
Creates an uninitialized Hessian input stream.

HessianInput

public HessianInput(InputStream is)
Creates a new Hessian input stream, initialized with an underlying input stream.
Parameters:
is - the underlying input stream.

Method Details

addRef

public int addRef(Object ref)
Adds a list/map reference.
Overrides:
addRef in interface AbstractHessianInput

completeCall

public void completeCall()
            throws IOException
Completes reading the call

A successful completion will have a single value:

 z
 
Overrides:
completeCall in interface AbstractHessianInput

completeReply

public void completeReply()
            throws IOException
Completes reading the call

A successful completion will have a single value:

 z
 
Overrides:
completeReply in interface AbstractHessianInput

completeValueReply

public void completeValueReply()
            throws IOException
Completes reading the call

A successful completion will have a single value:

 z
 

error

protected IOException error(String message)

expect

protected IOException expect(String expect,
                             int ch)

getMethod

public String getMethod()
Returns the calls method
Overrides:
getMethod in interface AbstractHessianInput

getReader

public Reader getReader()
Starts reading a string. All the characters must be read before calling the next method. The actual characters will be read with the reader's read() or read(char [], int, int).
 s b16 b8 non-final string chunk
 S b16 b8 final string chunk
 
Overrides:
getReader in interface AbstractHessianInput

getReplyFault

public Throwable getReplyFault()
Returns any reply fault.

getSerializerFactory

public SerializerFactory getSerializerFactory()
Gets the serializer factory.

init

public void init(InputStream is)
Initialize the hessian stream with the underlying input stream.
Overrides:
init in interface AbstractHessianInput

isEnd

public boolean isEnd()
            throws IOException
Returns true if this is the end of a list or a map.
Overrides:
isEnd in interface AbstractHessianInput

parseByte

private int parseByte()
            throws IOException
Reads a byte from the underlying stream.

parseChar

private int parseChar()
            throws IOException
Reads a character from the underlying stream.

parseDouble

private double parseDouble()
            throws IOException
Parses a 64-bit double value from the stream.
 b64 b56 b48 b40 b32 b24 b16 b8
 

parseInt

private int parseInt()
            throws IOException
Parses a 32-bit integer value from the stream.
 b32 b24 b16 b8
 

parseLong

private long parseLong()
            throws IOException
Parses a 64-bit long value from the stream.
 b64 b56 b48 b40 b32 b24 b16 b8
 

parseUTF8Char

private int parseUTF8Char()
            throws IOException
Parses a single UTF8 character.

parseXML

(package private)  org.w3c.dom.Node parseXML()
            throws IOException

prepareFault

private Throwable prepareFault()
            throws IOException
Prepares the fault.

read

(package private) final int read()
            throws IOException

read

(package private)  int read(byte[] buffer,
                            int offset,
                            int length)
            throws IOException
Reads bytes from the underlying stream.

readBoolean

public boolean readBoolean()
            throws IOException
Reads a boolean
 T
 F
 
Overrides:
readBoolean in interface AbstractHessianInput

readByte

public int readByte()
            throws IOException
Reads a byte from the stream.

readBytes

public byte[] readBytes()
            throws IOException
Reads a byte array
 B b16 b8 data value
 
Overrides:
readBytes in interface AbstractHessianInput

readBytes

public int readBytes(byte[] buffer,
                     int offset,
                     int length)
            throws IOException
Reads a byte array from the stream.

readCall

public int readCall()
            throws IOException
Starts reading the call
 c major minor
 

readChar

public int readChar()
            throws IOException
Reads a byte from the stream.

readDouble

public double readDouble()
            throws IOException
Reads a double
 D b64 b56 b48 b40 b32 b24 b16 b8
 
Overrides:
readDouble in interface AbstractHessianInput

readEnd

public void readEnd()
            throws IOException
Reads the end byte.
Overrides:
readEnd in interface AbstractHessianInput

readFault

private HashMap readFault()
            throws IOException
Reads a fault.

readFloat

public float readFloat()
            throws IOException
Reads a float
 D b64 b56 b48 b40 b32 b24 b16 b8
 

readHeader

public String readHeader()
            throws IOException
Reads a header, returning null if there are no headers.
 H b16 b8 value
 

readInputStream

public InputStream readInputStream()
            throws IOException
Reads bytes based on an input stream.
Overrides:
readInputStream in interface AbstractHessianInput

readInt

public int readInt()
            throws IOException
Reads an integer
 I b32 b24 b16 b8
 
Overrides:
readInt in interface AbstractHessianInput

readLength

public int readLength()
            throws IOException
Parses the length for an array
 l b32 b24 b16 b8
 
Overrides:
readLength in interface AbstractHessianInput

readListEnd

public void readListEnd()
            throws IOException
Reads the end byte.
Overrides:
readListEnd in interface AbstractHessianInput

readListStart

public int readListStart()
            throws IOException
Reads the start of a list.
Overrides:
readListStart in interface AbstractHessianInput

readLong

public long readLong()
            throws IOException
Reads a long
 L b64 b56 b48 b40 b32 b24 b16 b8
 
Overrides:
readLong in interface AbstractHessianInput

readMapEnd

public void readMapEnd()
            throws IOException
Reads the end byte.
Overrides:
readMapEnd in interface AbstractHessianInput

readMapStart

public int readMapStart()
            throws IOException
Reads the start of a list.
Overrides:
readMapStart in interface AbstractHessianInput

readMethod

public String readMethod()
            throws IOException
Starts reading the call

A successful completion will have a single value:

 m b16 b8 method
 

readNode

public org.w3c.dom.Node readNode()
            throws IOException
Reads an XML node.
 S b16 b8 string value
 
Overrides:
readNode in interface AbstractHessianInput

readNull

public void readNull()
            throws IOException
Reads a null
 N
 
Overrides:
readNull in interface AbstractHessianInput

readObject

public Object readObject()
            throws IOException
Reads an arbitrary object from the input stream when the type is unknown.
Overrides:
readObject in interface AbstractHessianInput

readObject

public Object readObject(Class cl)
            throws IOException
Reads an object from the input stream with an expected type.
Overrides:
readObject in interface AbstractHessianInput

readRef

public Object readRef()
            throws IOException
Reads a reference.
Overrides:
readRef in interface AbstractHessianInput

readRemote

public Object readRemote()
            throws IOException
Reads a remote object.
Overrides:
readRemote in interface AbstractHessianInput

readReply

public Object readReply(Class expectedClass)
            throws Throwable
Reads a reply as an object. If the reply has a fault, throws the exception.
Overrides:
readReply in interface AbstractHessianInput

readShort

public short readShort()
            throws IOException
Reads a short
 I b32 b24 b16 b8
 

readString

public String readString()
            throws IOException
Reads a string
 S b16 b8 string value
 
Overrides:
readString in interface AbstractHessianInput

readString

public int readString(char[] buffer,
                      int offset,
                      int length)
            throws IOException
Reads a byte array from the stream.

readType

public String readType()
            throws IOException
Parses a type from the stream.
 t b16 b8
 
Overrides:
readType in interface AbstractHessianInput

readUTCDate

public long readUTCDate()
            throws IOException
Reads a date.
 T b64 b56 b48 b40 b32 b24 b16 b8
 
Overrides:
readUTCDate in interface AbstractHessianInput

resolveRemote

public Object resolveRemote(String type,
                            String url)
            throws IOException
Resolves a remote object.

setRef

public void setRef(int i,
                   Object ref)
Adds a list/map reference.
Overrides:
setRef in interface AbstractHessianInput

setSerializerFactory

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

startCall

public void startCall()
            throws IOException
Starts reading the call

A successful completion will have a single value:

 c major minor
 m b16 b8 method
 
Overrides:
startCall in interface AbstractHessianInput

startReply

public void startReply()
            throws Throwable
Starts reading the reply

A successful completion will have a single value:

 r
 
Overrides:
startReply in interface AbstractHessianInput