pt.tumba.parser.swf
Class InStream

java.lang.Object
  extended by pt.tumba.parser.swf.InStream

public class InStream
extends java.lang.Object

Input Stream Wrapper

Author:
unknown

Field Summary
protected  int bitBuf
          Description of the Field
protected  int bitPos
          Description of the Field
protected  long bytesRead
          Description of the Field
protected  java.io.InputStream in
          Description of the Field
 
Constructor Summary
InStream(byte[] bytes)
          Constructor for the InStream object
InStream(java.io.InputStream in)
          Constructor for the InStream object
 
Method Summary
static int bytesToSigned(byte lo, byte hi)
          Util to convert 2 bytes to a signed value
 long getBytesRead()
          Gets the bytesRead attribute of the InStream object
 byte[] read()
          Read all remaining bytes from the stream
 byte[] read(int length)
          Read bytes from the input stream
 double readDouble()
          Read a 64 bit floating point number
 float readFloat()
          Read a 32 bit floating point number
 int readSBits(int numBits)
          Read a signed value from the given number of bits
 short readSI16()
          Read a signed 16 bit value
 int readSI32()
          Read a 32 bit signed number
 java.lang.String readString()
          Read a null terminated string using the default character encoding
 byte[] readStringBytes()
          Read a string from the input stream
 long readUBits(int numBits)
          Read an unsigned value from the given number of bits
 int readUI16()
          Read an unsigned 16 bit value
 long readUI32()
          Read an unsigned 32 bit value
 int readUI8()
          Read an unsigned 8 bit value
 void setBytesRead(long read)
          Sets the bytesRead attribute of the InStream object
 void skipBytes(long length)
          Skip a number of bytes from the input stream
 void synchBits()
          Reset the bit buffer
static int ubyteToInt(byte b2)
          Util to convert an unsigned byte to an unsigned int
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

protected java.io.InputStream in
Description of the Field


bytesRead

protected long bytesRead
Description of the Field


bitBuf

protected int bitBuf
Description of the Field


bitPos

protected int bitPos
Description of the Field

Constructor Detail

InStream

public InStream(java.io.InputStream in)
Constructor for the InStream object

Parameters:
in - Description of the Parameter

InStream

public InStream(byte[] bytes)
Constructor for the InStream object

Parameters:
bytes - Description of the Parameter
Method Detail

readStringBytes

public byte[] readStringBytes()
                       throws java.io.IOException
Read a string from the input stream

Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

readString

public java.lang.String readString()
                            throws java.io.IOException
Read a null terminated string using the default character encoding

Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

read

public byte[] read()
            throws java.io.IOException
Read all remaining bytes from the stream

Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

read

public byte[] read(int length)
            throws java.io.IOException
Read bytes from the input stream

Parameters:
length - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

synchBits

public void synchBits()
Reset the bit buffer


getBytesRead

public long getBytesRead()
Gets the bytesRead attribute of the InStream object

Returns:
The bytesRead value

setBytesRead

public void setBytesRead(long read)
Sets the bytesRead attribute of the InStream object

Parameters:
read - The new bytesRead value

skipBytes

public void skipBytes(long length)
               throws java.io.IOException
Skip a number of bytes from the input stream

Parameters:
length - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception

readUBits

public long readUBits(int numBits)
               throws java.io.IOException
Read an unsigned value from the given number of bits

Parameters:
numBits - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

readUI8

public int readUI8()
            throws java.io.IOException
Read an unsigned 8 bit value

Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

readUI16

public int readUI16()
             throws java.io.IOException
Read an unsigned 16 bit value

Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

readSI16

public short readSI16()
               throws java.io.IOException
Read a signed 16 bit value

Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

readUI32

public long readUI32()
              throws java.io.IOException
Read an unsigned 32 bit value

Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

readSBits

public int readSBits(int numBits)
              throws java.io.IOException
Read a signed value from the given number of bits

Parameters:
numBits - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

readSI32

public int readSI32()
             throws java.io.IOException
Read a 32 bit signed number

Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

readFloat

public float readFloat()
                throws java.io.IOException
Read a 32 bit floating point number

Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

readDouble

public double readDouble()
                  throws java.io.IOException
Read a 64 bit floating point number

Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

ubyteToInt

public static int ubyteToInt(byte b2)
Util to convert an unsigned byte to an unsigned int

Parameters:
b - Description of the Parameter
Returns:
Description of the Return Value

bytesToSigned

public static int bytesToSigned(byte lo,
                                byte hi)
Util to convert 2 bytes to a signed value

Parameters:
lo - Description of the Parameter
hi - Description of the Parameter
Returns:
Description of the Return Value