public abstract class ChunkReader extends Object
ChunkReader.ChunkReaderMode.BUFFER, ChunkReader.ChunkReaderMode.PROCESS,
ChunkReader.ChunkReaderMode.SKIP.
It calls chunkDone() when done. Also calls
processData(byte[], int, int) if PROCESS mode. Apart
from thas, it's totally agnostic (it doesn't know about IDAT chunks, or PNG
general structure)
The object wraps a ChunkRaw instance (content filled only if BUFFER mode); it should be short lived (one instance created for each chunk, and discarded after reading), but the wrapped chunkRaw can be (usually is) long lived.
| Modifier and Type | Class and Description |
|---|---|
static class |
ChunkReader.ChunkReaderMode
Modes of ChunkReader chunk processing.
|
| Modifier and Type | Field and Description |
|---|---|
protected ChunkReader.ChunkReaderMode |
mode |
protected int |
read
How many bytes have been read for this chunk, data only
|
| Constructor and Description |
|---|
ChunkReader(int clen,
String id,
long offsetInPng,
ChunkReader.ChunkReaderMode mode)
The constructor creates also a chunkRaw, preallocated if mode =
ChunkReaderMode.BUFFER
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
chunkDone()
This method will be called (in all modes) when the full chunk -including
crc- has been read
|
boolean |
equals(Object obj)
Equality (and hash) is basically delegated to the ChunkRaw
|
int |
feedBytes(byte[] buf,
int off,
int len)
Consumes data for the chunk (data and CRC).
|
ChunkRaw |
getChunkRaw()
Returns raw chunk (data can be empty or not, depending on
ChunkReaderMode)
|
int |
hashCode() |
boolean |
isDone()
Chunks has been read
|
protected abstract void |
processData(byte[] buf,
int off,
int len)
This method will only be called in PROCESS mode, probably several times,
each time with a new fragment of data
It's guaranteed that the data to read has non-zero length and it
corresponds exclusively to this chunk data (no crc, no data from no other
chunks, )
|
void |
setCrcCheck(boolean crcCheck)
Determines if CRC should be checked.
|
String |
toString() |
protected final ChunkReader.ChunkReaderMode mode
protected int read
public ChunkReader(int clen,
String id,
long offsetInPng,
ChunkReader.ChunkReaderMode mode)
clen - id - offsetInPng - Informational, is stored in chunkRawmode - public ChunkRaw getChunkRaw()
public final int feedBytes(byte[] buf,
int off,
int len)
buf - off - len - public final boolean isDone()
public void setCrcCheck(boolean crcCheck)
crcCheck - protected abstract void processData(byte[] buf,
int off,
int len)
protected abstract void chunkDone()
public boolean equals(Object obj)
Copyright © 2013. All rights reserved.