Package org.simpleframework.http.parse
Class PathParser.TokenList
java.lang.Object
org.simpleframework.http.parse.PathParser.TokenList
- Enclosing class:
PathParser
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 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Constructor for theTokenList
is used to create a scalable list to store tokens. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int off, int len) This is used to add a new token to the list.private String[]
build()
This is used to retrieve the list of tokens inserted to this list using theadd
method.void
clear()
This is used to clear all tokens previously stored in the list.String[]
list()
This is used to retrieve the list of tokens inserted to this list using theadd
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.
-
Field Details
-
cache
This is used to cache the segments that are created. -
list
private int[] listContains the offsets and lengths of the tokens. -
count
private int countDetermines the write offset into the array.
-
-
Constructor Details
-
TokenList
private TokenList()Constructor for theTokenList
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
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
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 pathtotal
- 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 thelist
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 bufferlen
- the number of characters within the token
-
list
This is used to retrieve the list of tokens inserted to this list using theadd
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
This is used to retrieve the list of tokens inserted to this list using theadd
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 theinit
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
-