Class SegmentConsumer.Token

  • Enclosing class:
    SegmentConsumer

    private class SegmentConsumer.Token
    extends java.lang.Object
    This is used to track the boundaries of a token so that it can be converted in to a usable string. This will track the length and offset within the consumed array of the token. When the token is to be used it can be converted in to a string.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int off
      This is used to mark the start offset within the array.
      int size
      This is used to track the number of bytes within the array.
    • Constructor Summary

      Constructors 
      Constructor Description
      Token​(int off, int size)
      Constructor for the Token object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String text()
      This is used to convert the byte range to a string.
      java.lang.String text​(java.lang.String charset)
      This is used to convert the byte range to a string.
      • Methods inherited from class java.lang.Object

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

      • size

        public int size
        This is used to track the number of bytes within the array.
      • off

        public int off
        This is used to mark the start offset within the array.
    • Constructor Detail

      • Token

        public Token​(int off,
                     int size)
        Constructor for the Token object. This is used to create a new token to track the range of bytes that will be used to create a string representing the parsed value.
        Parameters:
        off - the starting offset for the token range
        size - the number of bytes used for the token
    • Method Detail

      • text

        public java.lang.String text()
        This is used to convert the byte range to a string. This will use UTF-8 encoding for the string which is compatible with the HTTP default header encoding of ISO-8859-1.
        Returns:
        the encoded string representing the token
      • text

        public java.lang.String text​(java.lang.String charset)
        This is used to convert the byte range to a string. This will use specified encoding, if that encoding is not supported then this will return null for the token value.
        Returns:
        the encoded string representing the token