Class AbstractHessianOutput

  • Direct Known Subclasses:
    AbstractBurlapOutput, Hessian2Output, HessianOutput

    public abstract class AbstractHessianOutput
    extends Object
    Abstract output stream for Hessian requests.
     OutputStream os = ...; // from http connection
     AbstractOutput out = new HessianSerializerOutput(os);
     String value;
    
     out.startCall("hello");  // start hello call
     out.writeString("arg1"); // write a string argument
     out.completeCall();      // complete the call
     
    • Constructor Detail

      • AbstractHessianOutput

        public AbstractHessianOutput()
    • Method Detail

      • setSerializerFactory

        public void setSerializerFactory​(SerializerFactory factory)
        Sets the serializer factory.
      • getSerializerFactory

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

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

        public void init​(OutputStream os)
        Initialize the output with a new underlying stream.
      • setUnshared

        public boolean setUnshared​(boolean isUnshared)
      • startCall

        public abstract void startCall()
                                throws IOException
        Starts the method call:
         C
         
        Parameters:
        method - the method name to call.
        Throws:
        IOException
      • startCall

        public abstract void startCall​(String method,
                                       int length)
                                throws IOException
        Starts the method call:
         C string int
         
        Parameters:
        method - the method name to call.
        Throws:
        IOException
      • writeHeader

        public void writeHeader​(String name)
                         throws IOException
        Deprecated.
        For Hessian 2.0, use the Header envelope instead
        Throws:
        IOException
      • writeMethod

        public abstract void writeMethod​(String method)
                                  throws IOException
        Writes the method tag.
         string
         
        Parameters:
        method - the method name to call.
        Throws:
        IOException
      • completeCall

        public abstract void completeCall()
                                   throws IOException
        Completes the method call:
         
        Throws:
        IOException
      • writeBoolean

        public abstract void writeBoolean​(boolean value)
                                   throws IOException
        Writes a boolean value to the stream. The boolean will be written with the following syntax:
         T
         F
         
        Parameters:
        value - the boolean value to write.
        Throws:
        IOException
      • writeInt

        public abstract 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
         
        Parameters:
        value - the integer value to write.
        Throws:
        IOException
      • writeLong

        public abstract 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
         
        Parameters:
        value - the long value to write.
        Throws:
        IOException
      • writeDouble

        public abstract 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
         
        Parameters:
        value - the double value to write.
        Throws:
        IOException
      • writeUTCDate

        public abstract void writeUTCDate​(long time)
                                   throws IOException
        Writes a date to the stream.
         T  b64 b56 b48 b40 b32 b24 b16 b8
         
        Parameters:
        time - the date in milliseconds from the epoch in UTC
        Throws:
        IOException
      • writeNull

        public abstract void writeNull()
                                throws IOException
        Writes a null value to the stream. The null will be written with the following syntax
         N
         
        Parameters:
        value - the string value to write.
        Throws:
        IOException
      • writeString

        public abstract 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
         
        Parameters:
        value - the string value to write.
        Throws:
        IOException
      • writeString

        public abstract 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
         
        Parameters:
        value - the string value to write.
        Throws:
        IOException
      • writeBytes

        public abstract 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
         
        Parameters:
        value - the string value to write.
        Throws:
        IOException
      • writeBytes

        public abstract 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
         
        Parameters:
        value - the string value to write.
        Throws:
        IOException
      • writeByteBufferStart

        public abstract void writeByteBufferStart()
                                           throws IOException
        Writes a byte buffer to the stream.
        Throws:
        IOException
      • writeByteBufferPart

        public abstract void writeByteBufferPart​(byte[] buffer,
                                                 int offset,
                                                 int length)
                                          throws IOException
        Writes a byte buffer to the stream.
         b b16 b18 bytes
         
        Parameters:
        value - the string value to write.
        Throws:
        IOException
      • writeByteBufferEnd

        public abstract void writeByteBufferEnd​(byte[] buffer,
                                                int offset,
                                                int length)
                                         throws IOException
        Writes the last chunk of a byte buffer to the stream.
         b b16 b18 bytes
         
        Parameters:
        value - the string value to write.
        Throws:
        IOException
      • writeRef

        protected abstract void writeRef​(int value)
                                  throws IOException
        Writes a reference.
         Q int
         
        Parameters:
        value - the integer value to write.
        Throws:
        IOException
      • replaceRef

        public abstract boolean replaceRef​(Object oldRef,
                                           Object newRef)
                                    throws IOException
        Replaces a reference from one object to another.
        Throws:
        IOException
      • addRef

        public abstract boolean addRef​(Object object)
                                throws IOException
        Adds an object to the reference list. If the object already exists, writes the reference, otherwise, the caller is responsible for the serialization.
         R b32 b24 b16 b8
         
        Parameters:
        object - the object to add as a reference.
        Returns:
        true if the object has already been written.
        Throws:
        IOException
      • getRef

        public abstract int getRef​(Object obj)
        Parameters:
        obj -
        Returns:
      • resetReferences

        public void resetReferences()
        Resets the references for streaming.
      • writeObject

        public abstract void writeObject​(Object object)
                                  throws IOException
        Writes a generic object to the output stream.
        Throws:
        IOException
      • writeListBegin

        public abstract boolean writeListBegin​(int length,
                                               String type)
                                        throws IOException
        Writes the list header to the stream. List writers will call writeListBegin followed by the list contents and then call writeListEnd.
         V
           x13 java.util.ArrayList   # type
           x93                       # length=3
           x91                       # 1
           x92                       # 2
           x93                       # 3
         </list>
         
        Throws:
        IOException
      • writeListEnd

        public abstract void writeListEnd()
                                   throws IOException
        Writes the tail of the list to the stream.
        Throws:
        IOException
      • writeMapBegin

        public abstract void writeMapBegin​(String type)
                                    throws IOException
        Writes the map header to the stream. Map writers will call writeMapBegin followed by the map contents and then call writeMapEnd.
         M type ( )* Z
         
        Throws:
        IOException
      • writeMapEnd

        public abstract void writeMapEnd()
                                  throws IOException
        Writes the tail of the map to the stream.
        Throws:
        IOException
      • writeObjectBegin

        public int writeObjectBegin​(String type)
                             throws IOException
        Writes the object header to the stream (for Hessian 2.0), or a Map for Hessian 1.0. Object writers will call writeObjectBegin followed by the map contents and then call writeObjectEnd.
         C type int *
         C int *
         
        Returns:
        true if the object has already been defined.
        Throws:
        IOException
      • writeClassFieldLength

        public void writeClassFieldLength​(int len)
                                   throws IOException
        Writes the end of the class.
        Throws:
        IOException
      • writeObjectEnd

        public void writeObjectEnd()
                            throws IOException
        Writes the tail of the object to the stream.
        Throws:
        IOException