java.lang.Object
org.rrd4j.core.timespec.TimeScanner

class TimeScannerextends Object
Tokenizes at-style time specification strings into tokens.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String
    The text being scanned for a time.
    (package private) static final TimeToken[]
    Multiplier tokens for relative time offsets
    private int
    Where the scanner is in the text, and where it was before the last token.
    private int
    Where 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 setContext
    private TimeToken
    The token just read, and the one before it.
    private TimeToken
    The token just read, and the one before it.
    (package private) static final TimeToken[]
    Keyword tokens for time specification parsing
  • Constructor Summary

    Constructors
    Constructor
    Description
    TimeScanner(String dateString)
    At-style time specification string to tokenize.
  • Method Summary

    Private Methods
    Modifier and Type
    Method
    Description
    (package private) TimeToken
    Next token from the date string.
    private int
    Recognizes one word of the date text.
    (package private) TimeToken
    Resolve ambiguous MONTHS_MINUTES token to months or minutes.
    (package private) TimeToken
    Restore previously saved tokenizer position.
    (package private) void
    Save current tokenizer position for backtracking.
    (package private) void
    setContext(boolean parsingWords)
    Switch token context between words and multipliers

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • dateString

      private final String dateString
      The text being scanned for a time.
    • pos

      private int pos
      Where the scanner is in the text, and where it was before the last token.
    • pos_save

      private int pos_save
      Where the scanner is in the text, and where it was before the last token.
    • token

      private TimeToken token
      The token just read, and the one before it.
    • token_save

      private TimeToken token_save
      The token just read, and the one before it.
    • WORDS

      static final TimeToken[] WORDS
      Keyword tokens for time specification parsing
    • MULTIPLIERS

      static final TimeToken[] MULTIPLIERS
      Multiplier tokens for relative time offsets
    • specials

      TimeToken[] specials
      Token table the scanner currently matches against, switched between WORDS and MULTIPLIERS by setContext
  • Constructor Details

    • TimeScanner

      public TimeScanner(String dateString)
      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

      TimeToken resolveMonthsMinutes(int newId)
      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

      private int parseToken(String arg)
      Recognizes one word of the date text.
      Parameters:
      arg - the word to recognize
      Returns:
      the token's type