- All Known Implementing Classes:
ListCssTokenizer,StreamCssTokenizer
public interface CssTokenizer
Defines the API of a CSS Tokenizer.
- Author:
- Werner Randelshofer
-
Method Summary
Modifier and TypeMethodDescriptiondefault ParseExceptioncreateParseException(String message) Creates a parse exception which contains the specified message, the token that was found, and the current position of the tokenizier.intcurrent()Returns the current token type.default booleanInvokescurrent()and checks if it is a "none" identifier.@Nullable Numberdefault Number@Nullable StringReturns the current string value.default Stringdefault @Nullable StringReturns the current value converted to a string.intintintGets the current position.@Nullable SourceLocatorintgetToken()intnext()Gets the next token skipping whitespaces and comments.default booleanInvokesnext()and checks if it is a "none" identifier.intGets the next token without skipping whitespaces and comments.voidpushBack()Pushes the current token back.default voidrequireNextNoSkip(int ttype, String message) Fetches the next token and throws a parse exception if it is not of the required type.default voidrequireNextToken(int ttype, String message) Fetches the next token and throws a parse exception if it is not of the required type.default voidskipIfPresent(int ttype) Skips the next token if it is of typettype.Scans the remaining tokens and adds them to a list.
-
Method Details
-
currentValue
Returns the current value converted to a string. The returned value can be used for String comparisons of the value.- Returns:
- the current value
-
currentNumber
@Nullable Number currentNumber() -
currentNumberNonNull
-
currentString
@Nullable String currentString()Returns the current string value.- Returns:
- the current string value
-
currentStringNonNull
-
current
int current()Returns the current token type.- Returns:
- the current token type
-
getLineNumber
int getLineNumber() -
getSourceLocator
@Nullable SourceLocator getSourceLocator() -
getStartPosition
int getStartPosition() -
getEndPosition
int getEndPosition() -
getNextPosition
int getNextPosition()Gets the current position.- Returns:
- the start position of the token if a token has been pushed back, the end position of the token otherwise
-
next
Gets the next token skipping whitespaces and comments.- Returns:
- the next non-whitespace token
- Throws:
IOException- on io exception
-
nextNoSkip
Gets the next token without skipping whitespaces and comments.- Returns:
- the next token
- Throws:
IOException- on io exception
-
skipIfPresent
Skips the next token if it is of typettype.- Parameters:
ttype- the token type t skip- Throws:
IOException
-
nextIsIdentNone
Invokesnext()and checks if it is a "none" identifier.- Returns:
- true if "none"
- Throws:
IOException- on io error
-
currentIsIdentNone
default boolean currentIsIdentNone()Invokescurrent()and checks if it is a "none" identifier.- Returns:
- true if "none"
-
requireNextToken
Fetches the next token and throws a parse exception if it is not of the required type.- Parameters:
ttype- the required token typemessage- the error message- Throws:
ParseException- if the token is not of the required typeIOException- on IO exception
-
createParseException
Creates a parse exception which contains the specified message, the token that was found, and the current position of the tokenizier.- Parameters:
message- the message- Returns:
- a new parse exception
-
requireNextNoSkip
Fetches the next token and throws a parse exception if it is not of the required type.- Parameters:
ttype- the required token typemessage- the error message- Throws:
ParseException- if the token is not of the required typeIOException- on IO exception
-
pushBack
void pushBack()Pushes the current token back. -
getToken
CssToken getToken() -
toTokenList
Scans the remaining tokens and adds them to a list.- Returns:
- a new list
- Throws:
IOException- on io exception
-