Class Hessian2Input

  • All Implemented Interfaces:
    Hessian2Constants
    Direct Known Subclasses:
    HessianSerializerInput

    public class Hessian2Input
    extends AbstractHessianInput
    implements Hessian2Constants
    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 Detail

      • _refs

        protected java.util.ArrayList<java.lang.Object> _refs
      • _classDefs

        protected java.util.ArrayList<com.caucho.hessian.io.Hessian2Input.ObjectDefinition> _classDefs
      • _types

        protected java.util.ArrayList<java.lang.String> _types
    • Constructor Detail

      • Hessian2Input

        public Hessian2Input()
      • Hessian2Input

        public Hessian2Input​(java.io.InputStream is)
        Creates a new Hessian input stream, initialized with an underlying input stream.
        Parameters:
        is - the underlying input stream.
    • Method Detail

      • getSerializerFactory

        public SerializerFactory getSerializerFactory()
        Gets the serializer factory.
      • findSerializerFactory

        protected final SerializerFactory findSerializerFactory()
        Gets the serializer factory.
      • setCloseStreamOnClose

        public void setCloseStreamOnClose​(boolean isClose)
      • isCloseStreamOnClose

        public boolean isCloseStreamOnClose()
      • getReplyFault

        public java.lang.Throwable getReplyFault()
        Returns any reply fault.
      • initPacket

        public void initPacket​(java.io.InputStream is)
      • readCall

        public int readCall()
                     throws java.io.IOException
        Starts reading the call
         c major minor
         
        Specified by:
        readCall in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readEnvelope

        public int readEnvelope()
                         throws java.io.IOException
        Starts reading the envelope
         E major minor
         
        Throws:
        java.io.IOException
      • completeEnvelope

        public void completeEnvelope()
                              throws java.io.IOException
        Completes reading the envelope

        A successful completion will have a single value:

         Z
         
        Throws:
        java.io.IOException
      • readMethod

        public java.lang.String readMethod()
                                    throws java.io.IOException
        Starts reading the call

        A successful completion will have a single value:

         string
         
        Specified by:
        readMethod in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readMethodArgLength

        public int readMethodArgLength()
                                throws java.io.IOException
        Returns the number of method arguments
         int
         
        Overrides:
        readMethodArgLength in class AbstractHessianInput
        Returns:
        -1 for a variable length (hessian 1.0)
        Throws:
        java.io.IOException
      • startCall

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

        The call expects the following protocol data

         c major minor
         m b16 b8 method
         
        Specified by:
        startCall in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readArguments

        public java.lang.Object[] readArguments()
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • completeCall

        public void completeCall()
                          throws java.io.IOException
        Completes reading the call

        A successful completion will have a single value:

         
        Specified by:
        completeCall in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readReply

        public java.lang.Object readReply​(java.lang.Class expectedClass)
                                   throws java.lang.Throwable
        Reads a reply as an object. If the reply has a fault, throws the exception.
        Specified by:
        readReply in class AbstractHessianInput
        Throws:
        java.lang.Throwable
      • startReply

        public void startReply()
                        throws java.lang.Throwable
        Starts reading the reply

        A successful completion will have a single value:

         r
         
        Specified by:
        startReply in class AbstractHessianInput
        Throws:
        java.lang.Throwable
      • completeReply

        public void completeReply()
                           throws java.io.IOException
        Completes reading the call

        A successful completion will have a single value:

         z
         
        Specified by:
        completeReply in class AbstractHessianInput
        Throws:
        java.io.IOException
      • completeValueReply

        public void completeValueReply()
                                throws java.io.IOException
        Completes reading the call

        A successful completion will have a single value:

         z
         
        Throws:
        java.io.IOException
      • readHeader

        public java.lang.String readHeader()
                                    throws java.io.IOException
        Reads a header, returning null if there are no headers.
         H b16 b8 value
         
        Specified by:
        readHeader in class AbstractHessianInput
        Throws:
        java.io.IOException
      • startMessage

        public int startMessage()
                         throws java.io.IOException
        Starts reading a packet
         p major minor
         
        Throws:
        java.io.IOException
      • completeMessage

        public void completeMessage()
                             throws java.io.IOException
        Completes reading the message

        A successful completion will have a single value:

         z
         
        Throws:
        java.io.IOException
      • readNull

        public void readNull()
                      throws java.io.IOException
        Reads a null
         N
         
        Specified by:
        readNull in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readBoolean

        public boolean readBoolean()
                            throws java.io.IOException
        Reads a boolean
         T
         F
         
        Specified by:
        readBoolean in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readShort

        public short readShort()
                        throws java.io.IOException
        Reads a short
         I b32 b24 b16 b8
         
        Throws:
        java.io.IOException
      • readInt

        public final int readInt()
                          throws java.io.IOException
        Reads an integer
         I b32 b24 b16 b8
         
        Specified by:
        readInt in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readLong

        public long readLong()
                      throws java.io.IOException
        Reads a long
         L b64 b56 b48 b40 b32 b24 b16 b8
         
        Specified by:
        readLong in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readFloat

        public float readFloat()
                        throws java.io.IOException
        Reads a float
         D b64 b56 b48 b40 b32 b24 b16 b8
         
        Throws:
        java.io.IOException
      • readDouble

        public double readDouble()
                          throws java.io.IOException
        Reads a double
         D b64 b56 b48 b40 b32 b24 b16 b8
         
        Specified by:
        readDouble in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readUTCDate

        public long readUTCDate()
                         throws java.io.IOException
        Reads a date.
         T b64 b56 b48 b40 b32 b24 b16 b8
         
        Specified by:
        readUTCDate in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readChar

        public int readChar()
                     throws java.io.IOException
        Reads a byte from the stream.
        Throws:
        java.io.IOException
      • readString

        public int readString​(char[] buffer,
                              int offset,
                              int length)
                       throws java.io.IOException
        Reads a byte array from the stream.
        Throws:
        java.io.IOException
      • readString

        public java.lang.String readString()
                                    throws java.io.IOException
        Reads a string
         S b16 b8 string value
         
        Specified by:
        readString in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readBytes

        public byte[] readBytes()
                         throws java.io.IOException
        Reads a byte array
         B b16 b8 data value
         
        Specified by:
        readBytes in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readByte

        public int readByte()
                     throws java.io.IOException
        Reads a byte from the stream.
        Throws:
        java.io.IOException
      • readBytes

        public int readBytes​(byte[] buffer,
                             int offset,
                             int length)
                      throws java.io.IOException
        Reads a byte array from the stream.
        Throws:
        java.io.IOException
      • readObject

        public java.lang.Object readObject​(java.lang.Class cl)
                                    throws java.io.IOException
        Reads an object from the input stream with an expected type.
        Specified by:
        readObject in class AbstractHessianInput
        Parameters:
        cl - the expected class if the protocol doesn't supply it.
        Throws:
        java.io.IOException
      • readObject

        public java.lang.Object readObject()
                                    throws java.io.IOException
        Reads an arbitrary object from the input stream when the type is unknown.
        Specified by:
        readObject in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readRemote

        public java.lang.Object readRemote()
                                    throws java.io.IOException
        Reads a remote object.
        Specified by:
        readRemote in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readRef

        public java.lang.Object readRef()
                                 throws java.io.IOException
        Reads a reference.
        Specified by:
        readRef in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readListStart

        public int readListStart()
                          throws java.io.IOException
        Reads the start of a list.
        Specified by:
        readListStart in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readMapStart

        public int readMapStart()
                         throws java.io.IOException
        Reads the start of a list.
        Specified by:
        readMapStart in class AbstractHessianInput
        Throws:
        java.io.IOException
      • isEnd

        public boolean isEnd()
                      throws java.io.IOException
        Returns true if this is the end of a list or a map.
        Specified by:
        isEnd in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readEnd

        public void readEnd()
                     throws java.io.IOException
        Reads the end byte.
        Specified by:
        readEnd in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readMapEnd

        public void readMapEnd()
                        throws java.io.IOException
        Reads the end byte.
        Specified by:
        readMapEnd in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readListEnd

        public void readListEnd()
                         throws java.io.IOException
        Reads the end byte.
        Specified by:
        readListEnd in class AbstractHessianInput
        Throws:
        java.io.IOException
      • addRef

        public int addRef​(java.lang.Object ref)
        Adds a list/map reference.
        Specified by:
        addRef in class AbstractHessianInput
      • setRef

        public void setRef​(int i,
                           java.lang.Object ref)
        Adds a list/map reference.
        Specified by:
        setRef in class AbstractHessianInput
      • reset

        public void reset()
      • resetBuffer

        public void resetBuffer()
      • readStreamingObject

        public java.lang.Object readStreamingObject()
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • resolveRemote

        public java.lang.Object resolveRemote​(java.lang.String type,
                                              java.lang.String url)
                                       throws java.io.IOException
        Resolves a remote object.
        Throws:
        java.io.IOException
      • readType

        public java.lang.String readType()
                                  throws java.io.IOException
        Parses a type from the stream.
         type ::= string
         type ::= int
         
        Specified by:
        readType in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readLength

        public int readLength()
                       throws java.io.IOException
        Parses the length for an array
         l b32 b24 b16 b8
         
        Specified by:
        readLength in class AbstractHessianInput
        Throws:
        java.io.IOException
      • readInputStream

        public java.io.InputStream readInputStream()
                                            throws java.io.IOException
        Reads bytes based on an input stream.
        Specified by:
        readInputStream in class AbstractHessianInput
        Throws:
        java.io.IOException
      • read

        public final int read()
                       throws java.io.IOException
        Normally, shouldn't be called externally, but needed for QA, e.g. ejb/3b01.
        Throws:
        java.io.IOException
      • unread

        protected void unread()
      • getReader

        public java.io.Reader getReader()
        Description copied from class: AbstractHessianInput
        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
         
        Specified by:
        getReader in class AbstractHessianInput
      • expect

        protected java.io.IOException expect​(java.lang.String expect,
                                             int ch)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • codeName

        protected java.lang.String codeName​(int ch)
      • error

        protected java.io.IOException error​(java.lang.String message)
      • free

        public void free()
      • close

        public void close()
                   throws java.io.IOException
        Overrides:
        close in class AbstractHessianInput
        Throws:
        java.io.IOException