Package org.simpleframework.http.parse
Class PathParser.TokenList
- java.lang.Object
-
- org.simpleframework.http.parse.PathParser.TokenList
-
- Enclosing class:
- PathParser
private class PathParser.TokenList extends java.lang.Object
TheTokenList
class is used to store a list of tokens. This provides anadd
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 providedlist
method. This has a scalable capacity.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
TokenList()
Constructor for theTokenList
is used to create a scalable list to store tokens.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int off, int len)
This is used to add a new token to the list.private java.lang.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.java.lang.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.java.lang.String
segment(int from)
This is used to acquire the path from the segment that is specified.java.lang.String
segment(int from, int total)
This is used to acquire the path from the segment that is specified.
-
-
-
Method Detail
-
segment
public java.lang.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 java.lang.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 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
public java.lang.String[] 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
private java.lang.String[] 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
-
-