Class TokenConsumer
java.lang.Object
org.simpleframework.http.message.ArrayConsumer
org.simpleframework.http.message.TokenConsumer
- All Implemented Interfaces:
ByteConsumer
The
TokenConsumer object is used to consume a token
from the cursor. Once the token has been consumed the consumer
is finished and the contents of the consumed token is appended
to an allocated buffer so that it can be extracted.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AllocatorThis is used to allocate a buffer to append the contents.private BufferThis is used to append the contents of consumed token.private intThis is the length of the token that is to be consumed.private intThis tracks the number of bytes that are read from the token.private byte[]This is the token that is to be consumed from the cursor.Fields inherited from class ArrayConsumer
array, chunk, count, done -
Constructor Summary
ConstructorsConstructorDescriptionTokenConsumer(Allocator allocator, byte[] token) TheTokenConsumerobject is used to read a token from the cursor. -
Method Summary
Methods inherited from class ArrayConsumer
consume, isFinished, resize
-
Field Details
-
allocator
This is used to allocate a buffer to append the contents. -
buffer
This is used to append the contents of consumed token. -
token
private byte[] tokenThis is the token that is to be consumed from the cursor. -
seek
private int seekThis tracks the number of bytes that are read from the token. -
length
private int lengthThis is the length of the token that is to be consumed.
-
-
Constructor Details
-
TokenConsumer
TheTokenConsumerobject is used to read a token from the cursor. This tracks the bytes read from the cursor, when it has fully read the token bytes correctly it will finish and append the consumed bytes to a buffer.- Parameters:
allocator- the allocator used to create a buffertoken- this is the token that is to be consumed
-
-
Method Details
-
process
This is used to append the consumed bytes to a created buffer so that it can be used when he is finished. This allows the contents to be read from an input stream or as a string.- Specified by:
processin classArrayConsumer- Throws:
IOException
-
scan
This is used to scan the token from the array. Once the bytes have been read from the consumed bytes this will return the number of bytes that need to be reset within the buffer.- Specified by:
scanin classArrayConsumer- Returns:
- this returns the number of bytes to be reset
- Throws:
IOException
-