com.caucho.hessian.micro
Class MicroHessianInput

java.lang.Object
  extended by com.caucho.hessian.micro.MicroHessianInput

public class MicroHessianInput
extends java.lang.Object

Input stream for Hessian requests, compatible with microedition Java. It only uses classes and types available to J2ME. In particular, it does not have any support for the <double> type.

MicroHessianInput does not depend on any classes other than in J2ME, so it can be extracted independently into a smaller package.

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

 InputStream is = ...; // from http connection
 MicroHessianInput in = new MicroHessianInput(is);
 String value;
 in.startReply();         // read reply header
 value = in.readString(); // read string value
 in.completeReply();      // read reply footer
 


Nested Class Summary
private static class MicroHessianInput.End
          Place-holder class for End tag 'z'
static class MicroHessianInput.Fault
          Class holding error string returned during Hessian decoding
private static class MicroHessianInput.Type
          Place-holder class for Type tag 't'
 
Field Summary
protected  java.io.InputStream is
           
 
Constructor Summary
MicroHessianInput()
          Creates an uninitialized Hessian input stream.
MicroHessianInput(java.io.InputStream is)
          Creates a new Hessian input stream, initialized with an underlying input stream.
 
Method Summary
 void completeReply()
          Completes reading the call A successful completion will have a single value: z
 java.lang.Object decodeTag()
           
 java.lang.Object decodeType(int tag)
           
protected  java.io.IOException expect(java.lang.String expect, int ch)
           
 void init(java.io.InputStream is)
          Initialize the hessian stream with the underlying input stream.
protected  java.io.IOException protocolException(java.lang.String message)
           
 boolean readBoolean()
          Reads a boolean T F
 byte[] readBytes()
          Reads a byte array
private  byte[] readBytes(int tag)
           
 MicroHessianInput.Fault readFault()
           
 java.util.Hashtable<java.lang.String,java.lang.Object> readHashMap()
           
 java.util.Hashtable<java.lang.String,java.lang.Object> readHashMap(int tag)
           
 int readInt()
          Reads an integer I b32 b24 b16 b8
 int readInt(int tag)
           
 long readLong()
          Reads a long L b64 b56 b48 b40 b32 b24 b16 b8
private  long readLong(int tag)
           
 java.lang.Object readObject(java.lang.Class<?> expectedClass)
          Reads an arbitrary object the input stream.
 java.lang.String readString()
          Reads a string S b16 b8 string value
private  java.lang.String readString(int tag)
           
private  java.lang.String readStringImpl(int length)
          Reads a string from the underlying stream.
 long readUTCDate()
          Reads a date.
 java.util.Vector<java.lang.Object> readVector()
           
private  java.util.Vector<java.lang.Object> readVector(int tag)
           
 void startReply()
          Starts reading the reply A successful completion will have a single value: r x01 x00
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

is

protected java.io.InputStream is
Constructor Detail

MicroHessianInput

public MicroHessianInput(java.io.InputStream is)
Creates a new Hessian input stream, initialized with an underlying input stream.

Parameters:
is - the underlying input stream.

MicroHessianInput

public MicroHessianInput()
Creates an uninitialized Hessian input stream.

Method Detail

init

public void init(java.io.InputStream is)
Initialize the hessian stream with the underlying input stream.


startReply

public void startReply()
                throws java.io.IOException
Starts reading the reply

A successful completion will have a single value:

 r x01 x00
 

Throws:
java.io.IOException

completeReply

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

A successful completion will have a single value:

 z
 

Throws:
java.io.IOException

readBoolean

public boolean readBoolean()
                    throws java.io.IOException
Reads a boolean
 T
 F
 

Throws:
java.io.IOException

readInt

public int readInt()
            throws java.io.IOException
Reads an integer
 I b32 b24 b16 b8
 

Throws:
java.io.IOException

readInt

public int readInt(int tag)
            throws java.io.IOException
Throws:
java.io.IOException

readLong

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

Throws:
java.io.IOException

readLong

private long readLong(int tag)
               throws java.io.IOException
Throws:
java.io.IOException

readUTCDate

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

Throws:
java.io.IOException

readBytes

public byte[] readBytes()
                 throws java.io.IOException
Reads a byte array

Returns:
byte[] array extracted from Hessian stream, NULL if 'N' specified in data.
Throws:
IOException.
java.io.IOException

readBytes

private byte[] readBytes(int tag)
                  throws java.io.IOException
Throws:
java.io.IOException

readObject

public java.lang.Object readObject(java.lang.Class<?> expectedClass)
                            throws java.io.IOException
Reads an arbitrary object the input stream.

Throws:
java.io.IOException

readVector

public java.util.Vector<java.lang.Object> readVector()
                                              throws java.io.IOException
Throws:
java.io.IOException

readVector

private java.util.Vector<java.lang.Object> readVector(int tag)
                                               throws java.io.IOException
Throws:
java.io.IOException

readFault

public MicroHessianInput.Fault readFault()
                                  throws java.io.IOException
Throws:
java.io.IOException

decodeTag

public java.lang.Object decodeTag()
                           throws java.io.IOException
Throws:
java.io.IOException

decodeType

public java.lang.Object decodeType(int tag)
                            throws java.io.IOException
Throws:
java.io.IOException

readString

public java.lang.String readString()
                            throws java.io.IOException
Reads a string
 S b16 b8 string value
 

Throws:
java.io.IOException

readString

private java.lang.String readString(int tag)
                             throws java.io.IOException
Throws:
java.io.IOException

readStringImpl

private java.lang.String readStringImpl(int length)
                                 throws java.io.IOException
Reads a string from the underlying stream.

Throws:
java.io.IOException

readHashMap

public java.util.Hashtable<java.lang.String,java.lang.Object> readHashMap()
                                                                   throws java.io.IOException
Throws:
java.io.IOException

readHashMap

public java.util.Hashtable<java.lang.String,java.lang.Object> readHashMap(int tag)
                                                                   throws java.io.IOException
Throws:
java.io.IOException

expect

protected java.io.IOException expect(java.lang.String expect,
                                     int ch)

protocolException

protected java.io.IOException protocolException(java.lang.String message)


JavaDoc