|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.simpleframework.http.message.ArrayConsumer
public abstract class ArrayConsumer
The ArrayConsumer object is a consumer that consumes
bytes in to an internal array before processing. This consumes
all bytes read in to an internal array. Each read is met with an
invocation of the scan method, which searches for
the terminal token within the read chunk. Once the terminal token
has been read the excess bytes are reset and the data can be
processed by the subclass implementation. The internal array is
expanded if the number of consumed bytes exceeds its capacity.
| Field Summary | |
|---|---|
protected byte[] |
array
This is the array that is used to contain the read bytes. |
protected int |
chunk
This is the size of the chunk of bytes to read each time. |
protected int |
count
This is the number of bytes that have been consumed so far. |
protected boolean |
done
This determines whether the terminal token has been read. |
| Constructor Summary | |
|---|---|
ArrayConsumer()
Constructor for the ArrayConsumer object. |
|
ArrayConsumer(int size)
Constructor for the ArrayConsumer object. |
|
ArrayConsumer(int size,
int chunk)
Constructor for the ArrayConsumer object. |
|
| Method Summary | |
|---|---|
void |
consume(ByteCursor cursor)
This method is used to consume bytes from the provided cursor. |
boolean |
isFinished()
When the terminal token is read from the cursor this will be true. |
protected abstract void |
process()
This method is invoked after the terminal token has been read. |
protected void |
resize(int size)
This method is used to add an additional chunk size to the internal array. |
protected abstract int |
scan()
This method is used to scan for the terminal token. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected byte[] array
protected int count
protected int chunk
protected boolean done
| Constructor Detail |
|---|
public ArrayConsumer()
ArrayConsumer object. This is
used to create a consumer that will consume all bytes in to an
internal array until a terminal token has been read. If excess
bytes are read by this consumer they are reset in the cursor.
public ArrayConsumer(int size)
ArrayConsumer object. This is
used to create a consumer that will consume all bytes in to an
internal array until a terminal token has been read. If excess
bytes are read by this consumer they are reset in the cursor.
size - this is the initial array and chunk size to use
public ArrayConsumer(int size,
int chunk)
ArrayConsumer object. This is
used to create a consumer that will consume all bytes in to an
internal array until a terminal token has been read. If excess
bytes are read by this consumer they are reset in the cursor.
size - this is the initial array size that is to be usedchunk - this is the chunk size to read bytes as| Method Detail |
|---|
public void consume(ByteCursor cursor)
throws IOException
ByteCursor object. After each read the byte
array is scanned for the terminal token. When the terminal
token is found the bytes are processed by the implementation.
consume in interface ByteConsumercursor - this is the cursor to consume the bytes from
IOException
protected void resize(int size)
throws IOException
size - this is the minimum size to expand the array to
IOExceptionpublic boolean isFinished()
scan method is used to determine the
terminal token. It is invoked after each read, when the scan
method returns a non-zero value then excess bytes are reset
and the consumer has finished.
isFinished in interface ByteConsumer
protected abstract void process()
throws IOException
IOException
protected abstract int scan()
throws IOException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||