Package org.simpleframework.http.message
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 Allocator
This is used to allocate a buffer to append the contents.private Buffer
This is used to append the contents of consumed token.private int
This is the length of the token that is to be consumed.private int
This 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 org.simpleframework.http.message.ArrayConsumer
array, chunk, count, done
-
Constructor Summary
ConstructorsConstructorDescriptionTokenConsumer
(Allocator allocator, byte[] token) TheTokenConsumer
object is used to read a token from the cursor. -
Method Summary
Methods inherited from class org.simpleframework.http.message.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
TheTokenConsumer
object 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:
process
in 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:
scan
in classArrayConsumer
- Returns:
- this returns the number of bytes to be reset
- Throws:
IOException
-