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

class TimeTokenextends Object
Token representation for time specification parsing.

This class represents individual tokens produced by the lexical scanner during time specification parsing. Each token contains both the original text value and a token type identifier that categorizes the token's meaning in the time specification grammar.

Token categories include:
- Time markers: Specific times like midnight, noon, teatime
- Relative references: yesterday, today, tomorrow, now
- Time units: seconds, minutes, hours, days, weeks, months, years
- Calendar units: Month names (JAN-DEC) and day names (SUN-SAT)
- Operators: Plus, minus, dot, colon, slash
- Special tokens: Numbers, identifiers, end-of-file marker

The token system supports both abbreviated and full forms where applicable, providing flexibility in time specification syntax. For example, both "January" and "Jan" map to the same JAN token type.

Tokens are immutable objects created by the TimeScanner and consumed by the TimeParser during the parsing process.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Token for "am" - morning times for 0-12 hour clock
    static final int
    Token for "apr", "april" - fourth month
    static final int
    Token for "aug", "august" - eighth month
    static final int
    Token for ":" - time separator
    static final int
    Token for "day", "days", "d" - days multiplier
    static final int
    Token for "dec", "december" - twelfth month
    static final int
    Token for "." - decimal point or date separator
    static final int
    Token for "end" or "e" - end of time range
    static final int
    Token for end of input - no more tokens available
    static final int
    Token for "feb", "february" - second month
    static final int
    Token for "fri", "friday" - sixth day of week
    static final int
    Token for "hour", "hours", "hr", "h" - hours multiplier
    static final int
    Token for unrecognized identifiers - unknown words
    static final int
    Token for "jan", "january" - first month
    static final int
    Token for "jul", "july" - seventh month
    static final int
    Token for "jun", "june" - sixth month
    static final int
    Token for invalid/unparseable input
    static final int
    Token for "mar", "march" - third month
    static final int
    Token for "may" - fifth month
    static final int
    Token for "midnight" - represents 00:00:00 of today or tomorrow
    static final int
    Token for "-" - subtraction operator
    static final int
    Token for "minute", "minutes", "min" - minutes multiplier
    static final int
    Token for "mon", "monday" - second day of week
    static final int
    Token for "month", "months", "mon" - months multiplier
    static final int
    Token for ambiguous "m" - requires context resolution to months or minutes
    static final int
    Token for "noon" - represents 12:00:00 of today or tomorrow
    static final int
    Token for "nov", "november" - eleventh month
    static final int
    Token for "now" or "n" - current timestamp
    static final int
    Token for numeric values - sequences of digits
    static final int
    Token for "oct", "october" - tenth month
    static final int
    Token for "+" - addition operator
    static final int
    Token for "pm" - evening times for 0-12 hour clock
    static final int
    Token for "sat", "saturday" - seventh day of week
    static final int
    Token for "second", "seconds", "sec", "s" - seconds multiplier
    static final int
    Token for "sep", "september" - ninth month
    static final int
    Token for "/" - date separator
    static final int
    Token for "start" or "s" - beginning of time range
    static final int
    Token for "sun", "sunday" - first day of week
    static final int
    Token for "teatime" - represents 16:00:00 of today or tomorrow
    static final int
    Token for "thu", "thursday" - fifth day of week
    static final int
    Token for "today" - current date
    (package private) final int
    The token type identifier
    static final int
    Token for "tomorrow" - one day after current date
    static final int
    Token for "tue", "tuesday" - third day of week
    (package private) final String
    The original text value of this token
    static final int
    Token for "wed", "wednesday" - fourth day of week
    static final int
    Token for "week", "weeks", "wk", "w" - weeks multiplier
    static final int
    Token for "year", "years", "yr", "y" - years multiplier
    static final int
    Token for "yesterday" - one day before current date
  • Constructor Summary

    Constructors
    Constructor
    Description
    TimeToken(String value, int token_id)
    Creates a new TimeToken with the specified value and type.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    Returns a string representation of this token for debugging.

    Methods inherited from class Object

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

    • MIDNIGHT

      public static final int MIDNIGHT
      Token for "midnight" - represents 00:00:00 of today or tomorrow
      See Also:
    • NOON

      public static final int NOON
      Token for "noon" - represents 12:00:00 of today or tomorrow
      See Also:
    • TEATIME

      public static final int TEATIME
      Token for "teatime" - represents 16:00:00 of today or tomorrow
      See Also:
    • PM

      public static final int PM
      Token for "pm" - evening times for 0-12 hour clock
      See Also:
    • AM

      public static final int AM
      Token for "am" - morning times for 0-12 hour clock
      See Also:
    • YESTERDAY

      public static final int YESTERDAY
      Token for "yesterday" - one day before current date
      See Also:
    • TODAY

      public static final int TODAY
      Token for "today" - current date
      See Also:
    • TOMORROW

      public static final int TOMORROW
      Token for "tomorrow" - one day after current date
      See Also:
    • NOW

      public static final int NOW
      Token for "now" or "n" - current timestamp
      See Also:
    • START

      public static final int START
      Token for "start" or "s" - beginning of time range
      See Also:
    • END

      public static final int END
      Token for "end" or "e" - end of time range
      See Also:
    • SECONDS

      public static final int SECONDS
      Token for "second", "seconds", "sec", "s" - seconds multiplier
      See Also:
    • MINUTES

      public static final int MINUTES
      Token for "minute", "minutes", "min" - minutes multiplier
      See Also:
    • HOURS

      public static final int HOURS
      Token for "hour", "hours", "hr", "h" - hours multiplier
      See Also:
    • DAYS

      public static final int DAYS
      Token for "day", "days", "d" - days multiplier
      See Also:
    • WEEKS

      public static final int WEEKS
      Token for "week", "weeks", "wk", "w" - weeks multiplier
      See Also:
    • MONTHS

      public static final int MONTHS
      Token for "month", "months", "mon" - months multiplier
      See Also:
    • YEARS

      public static final int YEARS
      Token for "year", "years", "yr", "y" - years multiplier
      See Also:
    • MONTHS_MINUTES

      public static final int MONTHS_MINUTES
      Token for ambiguous "m" - requires context resolution to months or minutes
      See Also:
    • NUMBER

      public static final int NUMBER
      Token for numeric values - sequences of digits
      See Also:
    • PLUS

      public static final int PLUS
      Token for "+" - addition operator
      See Also:
    • MINUS

      public static final int MINUS
      Token for "-" - subtraction operator
      See Also:
    • DOT

      public static final int DOT
      Token for "." - decimal point or date separator
      See Also:
    • COLON

      public static final int COLON
      Token for ":" - time separator
      See Also:
    • SLASH

      public static final int SLASH
      Token for "/" - date separator
      See Also:
    • ID

      public static final int ID
      Token for unrecognized identifiers - unknown words
      See Also:
    • JUNK

      public static final int JUNK
      Token for invalid/unparseable input
      See Also:
    • JAN

      public static final int JAN
      Token for "jan", "january" - first month
      See Also:
    • FEB

      public static final int FEB
      Token for "feb", "february" - second month
      See Also:
    • MAR

      public static final int MAR
      Token for "mar", "march" - third month
      See Also:
    • APR

      public static final int APR
      Token for "apr", "april" - fourth month
      See Also:
    • MAY

      public static final int MAY
      Token for "may" - fifth month
      See Also:
    • JUN

      public static final int JUN
      Token for "jun", "june" - sixth month
      See Also:
    • JUL

      public static final int JUL
      Token for "jul", "july" - seventh month
      See Also:
    • AUG

      public static final int AUG
      Token for "aug", "august" - eighth month
      See Also:
    • SEP

      public static final int SEP
      Token for "sep", "september" - ninth month
      See Also:
    • OCT

      public static final int OCT
      Token for "oct", "october" - tenth month
      See Also:
    • NOV

      public static final int NOV
      Token for "nov", "november" - eleventh month
      See Also:
    • DEC

      public static final int DEC
      Token for "dec", "december" - twelfth month
      See Also:
    • SUN

      public static final int SUN
      Token for "sun", "sunday" - first day of week
      See Also:
    • MON

      public static final int MON
      Token for "mon", "monday" - second day of week
      See Also:
    • TUE

      public static final int TUE
      Token for "tue", "tuesday" - third day of week
      See Also:
    • WED

      public static final int WED
      Token for "wed", "wednesday" - fourth day of week
      See Also:
    • THU

      public static final int THU
      Token for "thu", "thursday" - fifth day of week
      See Also:
    • FRI

      public static final int FRI
      Token for "fri", "friday" - sixth day of week
      See Also:
    • SAT

      public static final int SAT
      Token for "sat", "saturday" - seventh day of week
      See Also:
    • EOF

      public static final int EOF
      Token for end of input - no more tokens available
      See Also:
    • value

      final String value
      The original text value of this token
    • token_id

      final int token_id
      The token type identifier
  • Constructor Details

    • TimeToken

      public TimeToken(String value, int token_id)
      Creates a new TimeToken with the specified value and type.
      Parameters:
      value - the original text value of the token (may be null for EOF)
      token_id - the token type identifier from the constant definitions
  • Method Details

    • toString

      public String toString()
      Returns a string representation of this token for debugging.

      The format is "value [token_id]" which makes it easy to see both the original text and the token type during parsing and debugging.

      Overrides:
      toString in class Object
      Returns:
      a formatted string containing the token value and type identifier