public class InputBitStream extends InputStream
InputBitStream
. This implementation allows you to
swap the underlying InputStream
source with another one.
InputBitStream
doesn't buffer the source InputStream internally. It
has one byte buffer for reading SWF bit-values. The buffer is filled 8 bits
at a time. All the bit value methods read from this buffer.
If a SWF file is compressed, InputBitStream uses an
InflaterInputStream
to decompress the source input.
Constructor and Description |
---|
InputBitStream(byte[] bytes) |
InputBitStream(InputStream in)
Create an
InputBitStream . |
Modifier and Type | Method and Description |
---|---|
void |
byteAlign()
Discard the data left in the bit value cache.
|
long |
getOffset()
Get the offset of the read cursor.
|
long |
getReadBoundary()
Get the read boundary.
|
int |
read() |
byte[] |
read(int length)
Read raw bytes.
|
boolean |
readBit()
Read 1-bit boolean value.
|
protected int |
readBits(int length)
Read multiple bits as a padded int.
|
protected int |
readByte()
This helps to mute the
IOException . |
double |
readDOUBLE()
Read 64-bit floating-point number
|
long |
readEncodedU32()
Read encoded unsigned 32-bit integer
|
float |
readFB(int length)
Read fixed-point bit values.
|
float |
readFIXED()
Read 32-bit 16.16 fixed point number.
|
float |
readFIXED8()
Read 16-bit 8.8 fixed point number
|
float |
readFLOAT()
Read 32-bit floating-point number
|
int |
readSB(int length)
Read signed bit values.
|
short |
readSI16()
Read 16-bit signed integer.
|
int |
readSI32()
Read 32-bit signed integer.
|
long |
readSI64()
Read 64-bit signed integer.
|
byte |
readSI8()
Read 8-bit signed integer.
|
String |
readString()
Read string.
|
byte[] |
readToBoundary()
Read all the bytes from the current position up to the read boundary.
|
int |
readUB(int length)
Read unsigned bit values.
|
int |
readUI16()
Read 16-bit unsigned integer.
|
int |
readUI24()
Read 24-bit unsigned integer.
|
long |
readUI32()
Read 32-bit unsigned integer.
|
short |
readUI8()
Read 8-bit unsigned integer.
|
void |
setCompress(Header.Compression compression)
Set if the InputStream is a compressed SWF stream.
|
void |
setReadBoundary(long offset)
Set the read boundary.
|
available, close, mark, markSupported, read, read, reset, skip
public InputBitStream(InputStream in)
InputBitStream
.in
- source InputStream
public InputBitStream(byte[] bytes)
public void byteAlign()
public int read() throws IOException
read
in class InputStream
IOException
public byte[] read(int length)
length
- number of bytes to readpublic boolean readBit()
protected int readBits(int length)
length
- number of bits to readprotected int readByte()
IOException
. If there's no data in the
source input stream, calling this method will raise an runtime exception.
All the methods implementing IInputBitStream
should call this
method when consuming the next byte from the input stream.
public double readDOUBLE()
public long readEncodedU32()
public float readFB(int length)
length
- number of bits to readpublic float readFIXED()
public float readFIXED8()
public float readFLOAT()
public int readSB(int length)
length
- number of bits to readpublic short readSI16()
public int readSI32()
public long readSI64()
public byte readSI8()
public String readString()
public int readUB(int length)
length
- number of bits to readpublic int readUI16()
public int readUI24()
public long readUI32()
public short readUI8()
public void setCompress(Header.Compression compression) throws IOException
IOException
public byte[] readToBoundary()
public long getOffset()
public void setReadBoundary(long offset)
The read boundary can move forward and backward. This is because DefineSprite has nested tags. The read boundary for a DefineSprite tag is at the end of all the nested tags, but it moves backwards when starting to read the nested ones.
offset
- boundary offset to the beginning of the stream.public long getReadBoundary()
Copyright © 2016 The Apache Software Foundation. All rights reserved.