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
FieldsModifier and TypeFieldDescriptionstatic final intToken for "am" - morning times for 0-12 hour clockstatic final intToken for "apr", "april" - fourth monthstatic final intToken for "aug", "august" - eighth monthstatic final intToken for ":" - time separatorstatic final intToken for "day", "days", "d" - days multiplierstatic final intToken for "dec", "december" - twelfth monthstatic final intToken for "." - decimal point or date separatorstatic final intToken for "end" or "e" - end of time rangestatic final intToken for end of input - no more tokens availablestatic final intToken for "feb", "february" - second monthstatic final intToken for "fri", "friday" - sixth day of weekstatic final intToken for "hour", "hours", "hr", "h" - hours multiplierstatic final intToken for unrecognized identifiers - unknown wordsstatic final intToken for "jan", "january" - first monthstatic final intToken for "jul", "july" - seventh monthstatic final intToken for "jun", "june" - sixth monthstatic final intToken for invalid/unparseable inputstatic final intToken for "mar", "march" - third monthstatic final intToken for "may" - fifth monthstatic final intToken for "midnight" - represents 00:00:00 of today or tomorrowstatic final intToken for "-" - subtraction operatorstatic final intToken for "minute", "minutes", "min" - minutes multiplierstatic final intToken for "mon", "monday" - second day of weekstatic final intToken for "month", "months", "mon" - months multiplierstatic final intToken for ambiguous "m" - requires context resolution to months or minutesstatic final intToken for "noon" - represents 12:00:00 of today or tomorrowstatic final intToken for "nov", "november" - eleventh monthstatic final intToken for "now" or "n" - current timestampstatic final intToken for numeric values - sequences of digitsstatic final intToken for "oct", "october" - tenth monthstatic final intToken for "+" - addition operatorstatic final intToken for "pm" - evening times for 0-12 hour clockstatic final intToken for "sat", "saturday" - seventh day of weekstatic final intToken for "second", "seconds", "sec", "s" - seconds multiplierstatic final intToken for "sep", "september" - ninth monthstatic final intToken for "/" - date separatorstatic final intToken for "start" or "s" - beginning of time rangestatic final intToken for "sun", "sunday" - first day of weekstatic final intToken for "teatime" - represents 16:00:00 of today or tomorrowstatic final intToken for "thu", "thursday" - fifth day of weekstatic final intToken for "today" - current date(package private) final intThe token type identifierstatic final intToken for "tomorrow" - one day after current datestatic final intToken for "tue", "tuesday" - third day of week(package private) final StringThe original text value of this tokenstatic final intToken for "wed", "wednesday" - fourth day of weekstatic final intToken for "week", "weeks", "wk", "w" - weeks multiplierstatic final intToken for "year", "years", "yr", "y" - years multiplierstatic final intToken for "yesterday" - one day before current dateConstructor Summary
Method Summary
All Methods
Field Details
MIDNIGHT
public static final int MIDNIGHTToken for "midnight" - represents 00:00:00 of today or tomorrow- See Also:
NOON
public static final int NOONToken for "noon" - represents 12:00:00 of today or tomorrow- See Also:
TEATIME
public static final int TEATIMEToken for "teatime" - represents 16:00:00 of today or tomorrow- See Also:
PM
public static final int PMToken for "pm" - evening times for 0-12 hour clock- See Also:
AM
public static final int AMToken for "am" - morning times for 0-12 hour clock- See Also:
YESTERDAY
public static final int YESTERDAYToken for "yesterday" - one day before current date- See Also:
TODAY
TOMORROW
public static final int TOMORROWToken for "tomorrow" - one day after current date- See Also:
NOW
START
public static final int STARTToken for "start" or "s" - beginning of time range- See Also:
END
SECONDS
public static final int SECONDSToken for "second", "seconds", "sec", "s" - seconds multiplier- See Also:
MINUTES
public static final int MINUTESToken for "minute", "minutes", "min" - minutes multiplier- See Also:
HOURS
public static final int HOURSToken for "hour", "hours", "hr", "h" - hours multiplier- See Also:
DAYS
public static final int DAYSToken for "day", "days", "d" - days multiplier- See Also:
WEEKS
public static final int WEEKSToken for "week", "weeks", "wk", "w" - weeks multiplier- See Also:
MONTHS
public static final int MONTHSToken for "month", "months", "mon" - months multiplier- See Also:
YEARS
public static final int YEARSToken for "year", "years", "yr", "y" - years multiplier- See Also:
MONTHS_MINUTES
public static final int MONTHS_MINUTESToken for ambiguous "m" - requires context resolution to months or minutes- See Also:
NUMBER
public static final int NUMBERToken for numeric values - sequences of digits- See Also:
PLUS
MINUS
DOT
public static final int DOTToken for "." - decimal point or date separator- See Also:
COLON
SLASH
ID
public static final int IDToken for unrecognized identifiers - unknown words- See Also:
JUNK
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
public static final int NOVToken for "nov", "november" - eleventh month- See Also:
DEC
public static final int DECToken for "dec", "december" - twelfth month- See Also:
SUN
public static final int SUNToken for "sun", "sunday" - first day of week- See Also:
MON
public static final int MONToken for "mon", "monday" - second day of week- See Also:
TUE
public static final int TUEToken for "tue", "tuesday" - third day of week- See Also:
WED
public static final int WEDToken for "wed", "wednesday" - fourth day of week- See Also:
THU
public static final int THUToken for "thu", "thursday" - fifth day of week- See Also:
FRI
public static final int FRIToken for "fri", "friday" - sixth day of week- See Also:
SAT
public static final int SATToken for "sat", "saturday" - seventh day of week- See Also:
EOF
public static final int EOFToken for end of input - no more tokens available- See Also:
value
The original text value of this tokentoken_id
final int token_idThe token type identifier
Constructor Details
TimeToken
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
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.