com.caucho.hessian.io
Class AbstractHessianInput

java.lang.Object
  extended by com.caucho.hessian.io.AbstractHessianInput
Direct Known Subclasses:
AbstractBurlapInput, Hessian2Input, HessianInput

public abstract class AbstractHessianInput
extends Object

Abstract base class for Hessian requests. Hessian users should only need to use the methods in this class.

 AbstractHessianInput in = ...; // get input
 String value;

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


Constructor Summary
AbstractHessianInput()
           
 
Method Summary
abstract  int addRef(Object obj)
          Adds an object reference.
 void close()
           
abstract  void completeCall()
          Completes reading the call The call expects the following protocol data Z
abstract  void completeReply()
          Completes reading the call A successful completion will have a single value: z
abstract  String getMethod()
          Returns the call's method
abstract  Reader getReader()
          Starts reading a string.
 HessianRemoteResolver getRemoteResolver()
          Sets the resolver used to lookup remote objects.
 void init(InputStream is)
          Initialize the Hessian stream with the underlying input stream.
abstract  boolean isEnd()
          Returns true if the data has ended.
abstract  boolean readBoolean()
          Reads a boolean T F
abstract  byte[] readBytes()
          Reads a byte array.
abstract  int readCall()
          Reads the call c major minor
abstract  double readDouble()
          Reads a double.
abstract  void readEnd()
          Read the end byte
abstract  String readHeader()
          Reads a header, returning null if there are no headers.
abstract  InputStream readInputStream()
          Starts reading a byte array using an input stream.
abstract  int readInt()
          Reads an integer I b32 b24 b16 b8
abstract  int readLength()
          Reads the length of a list.
abstract  void readListEnd()
          Read the end byte
abstract  int readListStart()
          Reads the start of a list
abstract  long readLong()
          Reads a long L b64 b56 b48 b40 b32 b24 b16 b8
abstract  void readMapEnd()
          Read the end byte
abstract  int readMapStart()
          Reads the start of a map
abstract  String readMethod()
          Starts reading the call A successful completion will have a single value: m b16 b8 method
 int readMethodArgLength()
          Reads the number of method arguments
 Node readNode()
          Reads an XML node encoded in UTF-8 x b16 b8 non-final xml chunk X b16 b8 final xml chunk
abstract  void readNull()
          Reads a null N
abstract  Object readObject()
          Reads an arbitrary object from the input stream.
abstract  Object readObject(Class expectedClass)
          Reads an arbitrary object from the input stream.
abstract  Object readRef()
          Reads a reference R b32 b24 b16 b8
abstract  Object readRemote()
          Reads a remote object reference to the stream.
abstract  Object readReply(Class expectedClass)
          Reads a reply as an object.
abstract  String readString()
          Reads a string encoded in UTF-8 s b16 b8 non-final string chunk S b16 b8 final string chunk
 boolean readToOutputStream(OutputStream os)
          Reads data to an output stream.
abstract  String readType()
          Reads an object type.
abstract  long readUTCDate()
          Reads a date.
 void resetReferences()
          Resets the references for streaming.
abstract  void setRef(int i, Object obj)
          Sets an object reference.
 void setRemoteResolver(HessianRemoteResolver resolver)
          Sets the resolver used to lookup remote objects.
 void setSerializerFactory(SerializerFactory ser)
          Sets the serializer factory.
 void skipOptionalCall()
          For backward compatibility with HessianSkeleton
abstract  void startCall()
          Starts reading the call, including the headers.
abstract  void startReply()
          Starts reading the reply A successful completion will have a single value: r v
 void startReplyBody()
          Starts reading the body of the reply, i.e. after the 'r' has been parsed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractHessianInput

public AbstractHessianInput()
Method Detail

init

public void init(InputStream is)
Initialize the Hessian stream with the underlying input stream.


getMethod

public abstract String getMethod()
Returns the call's method


setRemoteResolver

public void setRemoteResolver(HessianRemoteResolver resolver)
Sets the resolver used to lookup remote objects.


getRemoteResolver

public HessianRemoteResolver getRemoteResolver()
Sets the resolver used to lookup remote objects.


setSerializerFactory

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


readCall

public abstract int readCall()
                      throws IOException
Reads the call
 c major minor
 

Throws:
IOException

skipOptionalCall

public void skipOptionalCall()
                      throws IOException
For backward compatibility with HessianSkeleton

Throws:
IOException

readHeader

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

Throws:
IOException

readMethod

public abstract String readMethod()
                           throws IOException
Starts reading the call

A successful completion will have a single value:

 m b16 b8 method
 

Throws:
IOException

readMethodArgLength

public int readMethodArgLength()
                        throws IOException
Reads the number of method arguments

Returns:
-1 for a variable length (hessian 1.0)
Throws:
IOException

startCall

public abstract void startCall()
                        throws IOException
Starts reading the call, including the headers.

The call expects the following protocol data

 c major minor
 m b16 b8 method
 

Throws:
IOException

completeCall

public abstract void completeCall()
                           throws IOException
Completes reading the call

The call expects the following protocol data

 Z
 

Throws:
IOException

readReply

public abstract Object readReply(Class expectedClass)
                          throws Throwable
Reads a reply as an object. If the reply has a fault, throws the exception.

Throws:
Throwable

startReply

public abstract void startReply()
                         throws Throwable
Starts reading the reply

A successful completion will have a single value:

 r
 v
 

Throws:
Throwable

startReplyBody

public void startReplyBody()
                    throws Throwable
Starts reading the body of the reply, i.e. after the 'r' has been parsed.

Throws:
Throwable

completeReply

public abstract void completeReply()
                            throws IOException
Completes reading the call

A successful completion will have a single value:

 z
 

Throws:
IOException

readBoolean

public abstract boolean readBoolean()
                             throws IOException
Reads a boolean
 T
 F
 

Throws:
IOException

readNull

public abstract void readNull()
                       throws IOException
Reads a null
 N
 

Throws:
IOException

readInt

public abstract int readInt()
                     throws IOException
Reads an integer
 I b32 b24 b16 b8
 

Throws:
IOException

readLong

public abstract long readLong()
                       throws IOException
Reads a long
 L b64 b56 b48 b40 b32 b24 b16 b8
 

Throws:
IOException

readDouble

public abstract double readDouble()
                           throws IOException
Reads a double.
 D b64 b56 b48 b40 b32 b24 b16 b8
 

Throws:
IOException

readUTCDate

public abstract long readUTCDate()
                          throws IOException
Reads a date.
 T b64 b56 b48 b40 b32 b24 b16 b8
 

Throws:
IOException

readString

public abstract String readString()
                           throws IOException
Reads a string encoded in UTF-8
 s b16 b8 non-final string chunk
 S b16 b8 final string chunk
 

Throws:
IOException

readNode

public Node readNode()
              throws IOException
Reads an XML node encoded in UTF-8
 x b16 b8 non-final xml chunk
 X b16 b8 final xml chunk
 

Throws:
IOException

getReader

public abstract Reader getReader()
                          throws IOException
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
 

Throws:
IOException

readInputStream

public abstract InputStream readInputStream()
                                     throws IOException
Starts reading a byte array using an input stream. All the bytes must be read before calling the following method.
 b b16 b8 non-final binary chunk
 B b16 b8 final binary chunk
 

Throws:
IOException

readToOutputStream

public boolean readToOutputStream(OutputStream os)
                           throws IOException
Reads data to an output stream.
 b b16 b8 non-final binary chunk
 B b16 b8 final binary chunk
 

Throws:
IOException

readBytes

public abstract byte[] readBytes()
                          throws IOException
Reads a byte array.
 b b16 b8 non-final binary chunk
 B b16 b8 final binary chunk
 

Throws:
IOException

readObject

public abstract Object readObject(Class expectedClass)
                           throws IOException
Reads an arbitrary object from the input stream.

Parameters:
expectedClass - the expected class if the protocol doesn't supply it.
Throws:
IOException

readObject

public abstract Object readObject()
                           throws IOException
Reads an arbitrary object from the input stream.

Throws:
IOException

readRemote

public abstract Object readRemote()
                           throws IOException
Reads a remote object reference to the stream. The type is the type of the remote interface.
 'r' 't' b16 b8 type url
 

Throws:
IOException

readRef

public abstract Object readRef()
                        throws IOException
Reads a reference
 R b32 b24 b16 b8
 

Throws:
IOException

addRef

public abstract int addRef(Object obj)
                    throws IOException
Adds an object reference.

Throws:
IOException

setRef

public abstract void setRef(int i,
                            Object obj)
                     throws IOException
Sets an object reference.

Throws:
IOException

resetReferences

public void resetReferences()
Resets the references for streaming.


readListStart

public abstract int readListStart()
                           throws IOException
Reads the start of a list

Throws:
IOException

readLength

public abstract int readLength()
                        throws IOException
Reads the length of a list.

Throws:
IOException

readMapStart

public abstract int readMapStart()
                          throws IOException
Reads the start of a map

Throws:
IOException

readType

public abstract String readType()
                         throws IOException
Reads an object type.

Throws:
IOException

isEnd

public abstract boolean isEnd()
                       throws IOException
Returns true if the data has ended.

Throws:
IOException

readEnd

public abstract void readEnd()
                      throws IOException
Read the end byte

Throws:
IOException

readMapEnd

public abstract void readMapEnd()
                         throws IOException
Read the end byte

Throws:
IOException

readListEnd

public abstract void readListEnd()
                          throws IOException
Read the end byte

Throws:
IOException

close

public void close()
           throws IOException
Throws:
IOException


Copyright © 2013. All Rights Reserved.