Package org.simpleframework.http.message
Class TokenConsumer
- java.lang.Object
-
- org.simpleframework.http.message.ArrayConsumer
-
- org.simpleframework.http.message.TokenConsumer
-
- All Implemented Interfaces:
ByteConsumer
class TokenConsumer extends ArrayConsumer
TheTokenConsumerobject 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
Fields Modifier and Type Field Description private AllocatorallocatorThis is used to allocate a buffer to append the contents.private BufferbufferThis is used to append the contents of consumed token.private intlengthThis is the length of the token that is to be consumed.private intseekThis tracks the number of bytes that are read from the token.private byte[]tokenThis 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
Constructors Constructor Description TokenConsumer(Allocator allocator, byte[] token)TheTokenConsumerobject is used to read a token from the cursor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidprocess()This is used to append the consumed bytes to a created buffer so that it can be used when he is finished.protected intscan()This is used to scan the token from the array.-
Methods inherited from class org.simpleframework.http.message.ArrayConsumer
consume, isFinished, resize
-
-
-
-
Field Detail
-
allocator
private Allocator allocator
This is used to allocate a buffer to append the contents.
-
buffer
private Buffer buffer
This is used to append the contents of consumed token.
-
token
private byte[] token
This is the token that is to be consumed from the cursor.
-
seek
private int seek
This tracks the number of bytes that are read from the token.
-
length
private int length
This is the length of the token that is to be consumed.
-
-
Constructor Detail
-
TokenConsumer
public TokenConsumer(Allocator allocator, byte[] token)
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 Detail
-
process
protected void process() throws java.io.IOExceptionThis 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:
java.io.IOException
-
scan
protected int scan() throws java.io.IOExceptionThis 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:
java.io.IOException
-
-