Class 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 allocator
      This is used to allocate a buffer to append the contents.
      private Buffer buffer
      This is used to append the contents of consumed token.
      private int length
      This is the length of the token that is to be consumed.
      private int seek
      This tracks the number of bytes that are read from the token.
      private byte[] token
      This is the token that is to be consumed from the cursor.
    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void process()
      This is used to append the consumed bytes to a created buffer so that it can be used when he is finished.
      protected int scan()
      This is used to scan the token from the array.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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)
        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 Detail

      • process

        protected void process()
                        throws java.io.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:
        java.io.IOException
      • scan

        protected int scan()
                    throws java.io.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:
        java.io.IOException