java.lang.Object
io.helidon.common.http.Tokenizer
String tokenizer for parsing headers.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionchar
consumeCharacter
(char c) Get the one character at the current position and matches it with the specified character and update the position to the next character.char
consumeCharacter
(CharMatcher matcher) Get the one character at the current position and matches it with the specified matcher, then update the position to the next character.consumeToken
(CharMatcher matcher) Get the token represented by the specified matcher and advance the position the to next character.consumeTokenIfPresent
(CharMatcher matcher) Get the token represented by the specified matcher and advance the position the to next character if matched.boolean
hasMore()
Test if there are more characters to process.static String
normalize
(CharMatcher matcher, String token) Verify that the given token matches the specified matcher and return a lower case only token string.char
Get the character at the current position.
-
Constructor Details
-
Tokenizer
Create a new instance.- Parameters:
input
- string to parse
-
-
Method Details
-
consumeTokenIfPresent
Get the token represented by the specified matcher and advance the position the to next character if matched.- Parameters:
matcher
- matcher to use- Returns:
- token matched, or
null
if not matched - Throws:
IllegalStateException
- ifhasMore()
returnsfalse
-
consumeToken
Get the token represented by the specified matcher and advance the position the to next character.- Parameters:
matcher
- matcher to use- Returns:
- IllegalStateException if
hasMore()
returnsfalse
or if the matcher wasn't matched.
-
consumeCharacter
Get the one character at the current position and matches it with the specified matcher, then update the position to the next character.- Parameters:
matcher
- matcher to use- Returns:
- consumed character
- Throws:
IllegalStateException
- ifhasMore()
returnsfalse
or if the specified matcher does not match the character at the current position
-
consumeCharacter
public char consumeCharacter(char c) Get the one character at the current position and matches it with the specified character and update the position to the next character.- Parameters:
c
- character to match- Returns:
- matched character
- Throws:
IllegalStateException
- ifhasMore()
returnsfalse
or if the specified character does not match the character at the current position
-
previewChar
public char previewChar()Get the character at the current position.- Returns:
- char
- Throws:
IllegalStateException
- ifhasMore()
returnsfalse
-
hasMore
public boolean hasMore()Test if there are more characters to process.- Returns:
true
if there are more characters to process,false
otherwise
-
normalize
Verify that the given token matches the specified matcher and return a lower case only token string.- Parameters:
matcher
- matcher to usetoken
- input token- Returns:
- normalized token string (lower case only)
-