Class TokenConsumer

java.lang.Object
org.simpleframework.http.message.ArrayConsumer
org.simpleframework.http.message.TokenConsumer
All Implemented Interfaces:
ByteConsumer

class TokenConsumer extends ArrayConsumer
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

    Fields
    Modifier and Type
    Field
    Description
    private 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

    Constructors
    Constructor
    Description
    TokenConsumer(Allocator allocator, byte[] token)
    The TokenConsumer object is used to read a token from the cursor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    This is used to append the consumed bytes to a created buffer so that it can be used when he is finished.
    protected int
    This is used to scan the token from the array.

    Methods inherited from class org.simpleframework.http.message.ArrayConsumer

    consume, isFinished, resize

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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 Details

    • TokenConsumer

      public TokenConsumer(Allocator allocator, byte[] token)
      The TokenConsumer 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 buffer
      token - this is the token that is to be consumed
  • Method Details

    • process

      protected void process() throws IOException
      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 class ArrayConsumer
      Throws:
      IOException
    • scan

      protected int scan() throws IOException
      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 class ArrayConsumer
      Returns:
      this returns the number of bytes to be reset
      Throws:
      IOException