org.spicefactory.cinnamon.io
Interface DataInput

All Known Implementing Classes:
AMFInput

public interface DataInput

Interface providing methods for reading from binary data. This interface corresponds to the flash.utils.IDataInput interface of the core Flash Player API. It assumes binary data to be in big-endian format.

Author:
Jens Halm

Method Summary
 boolean readBoolean()
          Reads a boolean value.
 byte readByte()
          Reads and returns a single byte.
 void readBytes(byte[] buffer, int offset, int length)
          Reads the number of bytes specified by the length parameter into the given byte buffer starting at the specified offset.
 double readDouble()
          Reads and returns a double.
 float readFloat()
          Reads and returns a float.
 int readInt()
          Reads and returns an int.
 String readMultiByte(int length, String charset)
          Reads a multibyte string of specified length using the given character set.
 Object readObject()
          Reads, deserializes and returns an object encoded in AMF3 binary format.
 short readShort()
          Reads and returns a short.
 long readUnsignedInt()
          Reads and returns an unsigned int.
 String readUTF()
          Reads and returns a UTF-8 String.
 String readUTFBytes(int length)
          Reads the specified number of UTF-8 encoded bytes and returns the decoded string.
 

Method Detail

readBoolean

boolean readBoolean()
Reads a boolean value. Reads a single byte and returns true if the value is 1 and false if the value is 0. Throws an Exception for all other values.

Returns:
true if the byte value read was 1, false if it was 0

readByte

byte readByte()
Reads and returns a single byte.

Returns:
a single byte.

readBytes

void readBytes(byte[] buffer,
               int offset,
               int length)
Reads the number of bytes specified by the length parameter into the given byte buffer starting at the specified offset.

Parameters:
buffer - the buffer to read into
offset - the offset into the data
length - the number of bytes to read

readDouble

double readDouble()
Reads and returns a double.

Returns:
a double

readFloat

float readFloat()
Reads and returns a float.

Returns:
a double

readShort

short readShort()
Reads and returns a short.

Returns:
a short

readInt

int readInt()
Reads and returns an int.

Returns:
an int

readUnsignedInt

long readUnsignedInt()
Reads and returns an unsigned int.

Returns:
an unsigned int as a long value

readUTF

String readUTF()
Reads and returns a UTF-8 String. The string must be prefixed with an unsigned short indicating the length in bytes.

Returns:
the decoded string

readUTFBytes

String readUTFBytes(int length)
Reads the specified number of UTF-8 encoded bytes and returns the decoded string.

Parameters:
length - the number of bytes to read
Returns:
the decoded string

readMultiByte

String readMultiByte(int length,
                     String charset)
Reads a multibyte string of specified length using the given character set.

Parameters:
length - the number of bytes to read
charset - the character set to use to decode the bytes
Returns:
the decoded string

readObject

Object readObject()
Reads, deserializes and returns an object encoded in AMF3 binary format.

Returns:
the deserialized object