jp.develop.common.util.amf
Class AmfDecoder

java.lang.Object
  extended by jp.develop.common.util.amf.AmfDecoder
All Implemented Interfaces:
DataInput, ObjectInput

public class AmfDecoder
extends Object
implements ObjectInput

Main class of AMF decoder. This class implements ObjectInput for the decode of externalizable object.

Author:
Waki Takeya
See Also:
AmfUtil

Constructor Summary
AmfDecoder(InputStream in)
          Constructs a instance with specified input stream.
AmfDecoder(InputStream in, AmfDecoderOption option)
          Constructs a instance with specified input stream and configuration option.
 
Method Summary
 int available()
          
 void close()
          
 int read()
          
 int read(byte[] b)
          
 int read(byte[] b, int off, int len)
          
 Object readAmfArray(Type type)
          Read array by AMF manner.
 Object readAmfArray(Type type, IWrapper resultContainer)
          Read array by AMF manner.
 byte[] readAmfByteArray()
          Read byte array by AMF manner.
 Date readAmfDate()
          Read date by AMF manner.
 Object readAmfDictionary(Type type)
          Read dictionary by AMF manner.
 int readAmfInteger()
          Read integer by AMF manner.
 Object readAmfObject(Type type)
          Read object by AMF manner.
 String readAmfString()
          Read string by AMF manner.
 Object readAmfVectorInt(Type type)
          Read vector of int by AMF manner.
 Object readAmfVectorNumber(Type type)
          Read vector of number by AMF manner.
 Object readAmfVectorObject(Type type)
          Read vector of object by AMF manner.
 Object readAmfVectorUint(Type type)
          Read vector of uint by AMF manner.
 String readAmfXMLString()
          Read XML document by AMF manner.
 boolean readBoolean()
          
 byte readByte()
          
 char readChar()
          
 double readDouble()
          
 float readFloat()
          
 void readFully(byte[] b)
          
 void readFully(byte[] b, int off, int len)
          
 int readInt()
          
 String readLine()
          This method is not supported.
 long readLong()
          
 Object readObject()
          
<T> T
readObject(Type type)
          Read object as specified type.
 short readShort()
          
 String readString(int bytes)
          Read string(UTF-8) by AMF manner.
 int readU29()
          Read unsigned integer(29bit) by AMF manner.
 int readUnsignedByte()
          
 long readUnsignedInt()
          Read unsigned int.
 int readUnsignedShort()
          
 String readUTF()
          
 long skip(long n)
          
 int skipBytes(int n)
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AmfDecoder

public AmfDecoder(InputStream in)
Constructs a instance with specified input stream.

Parameters:
in - Input stream.

AmfDecoder

public AmfDecoder(InputStream in,
                  AmfDecoderOption option)
Constructs a instance with specified input stream and configuration option.

Parameters:
in - Input stream.
option - Configuration option.
Method Detail

readObject

public <T> T readObject(Type type)
             throws IOException
Read object as specified type.

Type Parameters:
T - The type of result.
Parameters:
type - Target type.
Returns:
Decoded object.
Throws:
IOException - I/O Exception.

readAmfObject

public Object readAmfObject(Type type)
                     throws IOException
Read object by AMF manner.

Parameters:
type - Target type.
Returns:
Decoded object.
Throws:
IOException - I/O Exception.

readAmfArray

public Object readAmfArray(Type type)
                    throws IOException
Read array by AMF manner.

Parameters:
type - Target type.
Returns:
Decoded object.
Throws:
IOException - I/O Exception.

readAmfArray

public Object readAmfArray(Type type,
                           IWrapper resultContainer)
                    throws IOException
Read array by AMF manner. You can get result instance to result container in advance.

Parameters:
type - Target type.
resultContainer - The container for result object.
Returns:
Decoded object.
Throws:
IOException - I/O Exception.

readAmfInteger

public int readAmfInteger()
                   throws IOException
Read integer by AMF manner.

Returns:
Decoded value.
Throws:
IOException - I/O Exception.

readAmfString

public String readAmfString()
                     throws IOException
Read string by AMF manner.

Returns:
Decoded string.
Throws:
IOException - I/O Exception.

readAmfXMLString

public String readAmfXMLString()
                        throws IOException
Read XML document by AMF manner.

Returns:
Decoded XML string.
Throws:
IOException - I/O Exception.

readAmfDate

public Date readAmfDate()
                 throws IOException
Read date by AMF manner.

Returns:
Decoded date.
Throws:
IOException - I/O Exception.

readAmfByteArray

public byte[] readAmfByteArray()
                        throws IOException
Read byte array by AMF manner.

Returns:
Decoded byte array.
Throws:
IOException - I/O Exception.

readAmfVectorInt

public Object readAmfVectorInt(Type type)
                        throws IOException
Read vector of int by AMF manner. This is trial implementation, because there is no official public specification.

Parameters:
type - Target type.
Returns:
Decoded object.
Throws:
IOException - I/O Exception.

readAmfVectorUint

public Object readAmfVectorUint(Type type)
                         throws IOException
Read vector of uint by AMF manner. This is trial implementation, because there is no official public specification.

Parameters:
type - Target type.
Returns:
Decoded object.
Throws:
IOException - I/O Exception.

readAmfVectorNumber

public Object readAmfVectorNumber(Type type)
                           throws IOException
Read vector of number by AMF manner. This is trial implementation, because there is no official public specification.

Parameters:
type - Target type.
Returns:
Decoded object.
Throws:
IOException - I/O Exception.

readAmfVectorObject

public Object readAmfVectorObject(Type type)
                           throws IOException
Read vector of object by AMF manner. This is trial implementation, because there is no official public specification.

Parameters:
type - Target type.
Returns:
Decoded object.
Throws:
IOException - I/O Exception.

readAmfDictionary

public Object readAmfDictionary(Type type)
                         throws IOException
Read dictionary by AMF manner. This is trial implementation, because there is no official public specification.

Parameters:
type - Target type.
Returns:
Decoded object.
Throws:
IOException - I/O Exception.

readU29

public int readU29()
            throws IOException
Read unsigned integer(29bit) by AMF manner.

Returns:
Decoded value.
Throws:
IOException - I/O Exception.

readString

public String readString(int bytes)
                  throws IOException
Read string(UTF-8) by AMF manner.

Parameters:
bytes - Byte length.
Returns:
Decoded string.
Throws:
IOException - I/O Exception.

readFully

public void readFully(byte[] b)
               throws IOException

Specified by:
readFully in interface DataInput
Throws:
IOException

readFully

public void readFully(byte[] b,
                      int off,
                      int len)
               throws IOException

Specified by:
readFully in interface DataInput
Throws:
IOException

skipBytes

public int skipBytes(int n)
              throws IOException

Specified by:
skipBytes in interface DataInput
Throws:
IOException

readBoolean

public boolean readBoolean()
                    throws IOException

Specified by:
readBoolean in interface DataInput
Throws:
IOException

readByte

public byte readByte()
              throws IOException

Specified by:
readByte in interface DataInput
Throws:
IOException

readUnsignedByte

public int readUnsignedByte()
                     throws IOException

Specified by:
readUnsignedByte in interface DataInput
Throws:
IOException

readShort

public short readShort()
                throws IOException

Specified by:
readShort in interface DataInput
Throws:
IOException

readUnsignedShort

public int readUnsignedShort()
                      throws IOException

Specified by:
readUnsignedShort in interface DataInput
Throws:
IOException

readChar

public char readChar()
              throws IOException

Specified by:
readChar in interface DataInput
Throws:
IOException

readInt

public int readInt()
            throws IOException

Specified by:
readInt in interface DataInput
Throws:
IOException

readUnsignedInt

public long readUnsignedInt()
                     throws IOException
Read unsigned int.

Returns:
Unsigned int value.(long type)
Throws:
IOException - I/O Exception.

readLong

public long readLong()
              throws IOException

Specified by:
readLong in interface DataInput
Throws:
IOException

readFloat

public float readFloat()
                throws IOException

Specified by:
readFloat in interface DataInput
Throws:
IOException

readDouble

public double readDouble()
                  throws IOException

Specified by:
readDouble in interface DataInput
Throws:
IOException

readLine

public String readLine()
                throws IOException
This method is not supported. UnsupportedOperationException is just thrown.

Specified by:
readLine in interface DataInput
Throws:
IOException

readUTF

public String readUTF()
               throws IOException

Specified by:
readUTF in interface DataInput
Throws:
IOException

readObject

public Object readObject()
                  throws IOException

Specified by:
readObject in interface ObjectInput
Throws:
IOException

read

public int read()
         throws IOException

Specified by:
read in interface ObjectInput
Throws:
IOException

read

public int read(byte[] b)
         throws IOException

Specified by:
read in interface ObjectInput
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException

Specified by:
read in interface ObjectInput
Throws:
IOException

skip

public long skip(long n)
          throws IOException

Specified by:
skip in interface ObjectInput
Throws:
IOException

available

public int available()
              throws IOException

Specified by:
available in interface ObjectInput
Throws:
IOException

close

public void close()
           throws IOException

Specified by:
close in interface ObjectInput
Throws:
IOException