Class PathParser.TokenList

java.lang.Object
org.simpleframework.http.parse.PathParser.TokenList
Enclosing class:
PathParser

private class PathParser.TokenList extends Object
The TokenList class is used to store a list of tokens. This provides an add method which can be used to store an offset and length of a token within the buffer. Once the tokens have been added to they can be examined, in the order they were added, using the provided list method. This has a scalable capacity.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String[]
    This is used to cache the segments that are created.
    private int
    Determines the write offset into the array.
    private int[]
    Contains the offsets and lengths of the tokens.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Constructor for the TokenList is used to create a scalable list to store tokens.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int off, int len)
    This is used to add a new token to the list.
    private String[]
    This is used to retrieve the list of tokens inserted to this list using the add method.
    void
    This is used to clear all tokens previously stored in the list.
    This is used to retrieve the list of tokens inserted to this list using the add method.
    private int
    offset(int segment)
    This is used to acquire the offset within the buffer of the specified segment.
    private void
    resize(int size)
    Scales the internal array used should the number of tokens exceed the initial capacity.
    segment(int from)
    This is used to acquire the path from the segment that is specified.
    segment(int from, int total)
    This is used to acquire the path from the segment that is specified.

    Methods inherited from class java.lang.Object

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

    • cache

      private String[] cache
      This is used to cache the segments that are created.
    • list

      private int[] list
      Contains the offsets and lengths of the tokens.
    • count

      private int count
      Determines the write offset into the array.
  • Constructor Details

    • TokenList

      private TokenList()
      Constructor for the TokenList is used to create a scalable list to store tokens. The initial list is created with an array of sixteen ints, which is enough to store eight tokens.
  • Method Details

    • segment

      public String segment(int from)
      This is used to acquire the path from the segment that is specified. This provides an efficient means to get the path without having to perform expensive copy of substring operations.
      Parameters:
      from - this is the path segment to get the path
      Returns:
      the string that is the path segment created
    • segment

      public String segment(int from, int total)
      This is used to acquire the path from the segment that is specified. This provides an efficient means to get the path without having to perform expensive copy of substring operations.
      Parameters:
      from - this is the path segment to get the path
      total - this is the number of segments to use
      Returns:
      the string that is the path segment created
    • offset

      private int offset(int segment)
      This is used to acquire the offset within the buffer of the specified segment. This allows a path to be created that is constructed from a given segment.
      Parameters:
      segment - this is the segment offset to use
      Returns:
      this returns the offset start for the segment
    • add

      public void add(int off, int len)
      This is used to add a new token to the list. Tokens will be available from the list method in the order it was added, so the first to be added will at index zero and the last with be in the last index.
      Parameters:
      off - this is the read offset within the buffer
      len - the number of characters within the token
    • list

      public String[] list()
      This is used to retrieve the list of tokens inserted to this list using the add method. The indexes of the tokens represents the order that the tokens were added to the list.
      Returns:
      returns an ordered list of token strings
    • build

      private String[] build()
      This is used to retrieve the list of tokens inserted to this list using the add method. The indexes of the tokens represents the order that the tokens were added to the list.
      Returns:
      returns an ordered list of token strings
    • clear

      public void clear()
      This is used to clear all tokens previously stored in the list. This is required so that initialization of the parser with the init method can ensure that there are no tokens from previous data.
    • resize

      private void resize(int size)
      Scales the internal array used should the number of tokens exceed the initial capacity. This will just copy across the ints used to represent the token.
      Parameters:
      size - length the capacity is to increase to