java.lang.Object
org.rrd4j.core.timespec.TimeScanner
Tokenizes at-style time specification strings into tokens.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe text being scanned for a time.(package private) static final TimeToken[]Multiplier tokens for relative time offsetsprivate intWhere the scanner is in the text, and where it was before the last token.private intWhere the scanner is in the text, and where it was before the last token.(package private) TimeToken[]Token table the scanner currently matches against, switched between WORDS and MULTIPLIERS by setContextprivate TimeTokenThe token just read, and the one before it.private TimeTokenThe token just read, and the one before it.(package private) static final TimeToken[]Keyword tokens for time specification parsingConstructor Summary
ConstructorsMethod Summary
Private MethodsModifier and TypeMethodDescription(package private) TimeTokenNext token from the date string.private intparseToken(String arg) Recognizes one word of the date text.(package private) TimeTokenresolveMonthsMinutes(int newId) Resolve ambiguous MONTHS_MINUTES token to months or minutes.(package private) TimeTokenRestore previously saved tokenizer position.(package private) voidSave current tokenizer position for backtracking.(package private) voidsetContext(boolean parsingWords) Switch token context between words and multipliers
Field Details
dateString
The text being scanned for a time.pos
private int posWhere the scanner is in the text, and where it was before the last token.pos_save
private int pos_saveWhere the scanner is in the text, and where it was before the last token.token
The token just read, and the one before it.token_save
The token just read, and the one before it.WORDS
Keyword tokens for time specification parsingMULTIPLIERS
Multiplier tokens for relative time offsetsspecials
TimeToken[] specialsToken table the scanner currently matches against, switched between WORDS and MULTIPLIERS by setContext
Constructor Details
TimeScanner
At-style time specification string to tokenize.- Parameters:
dateString- at-style time specification string to tokenize
Method Details
setContext
void setContext(boolean parsingWords) Switch token context between words and multipliers- Parameters:
parsingWords- true to look up word tokens, false to look up multipliers
nextToken
TimeToken nextToken()Next token from the date string.- Returns:
- the next token, EOF once the string is exhausted
resolveMonthsMinutes
Resolve ambiguous MONTHS_MINUTES token to months or minutes.- Parameters:
newId- the MONTHS or MINUTES token id the surrounding context implies- Returns:
- the same token value re-tagged with the resolved id
saveState
void saveState()Save current tokenizer position for backtracking.restoreState
TimeToken restoreState()Restore previously saved tokenizer position.- Returns:
- the token that was current when the state was saved
parseToken
Recognizes one word of the date text.- Parameters:
arg- the word to recognize- Returns:
- the token's type