Class RMDateParser
- java.lang.Object
-
- com.inductiveautomation.rm.parsing.RMDateParser
-
- All Implemented Interfaces:
RMDateParserConstants
public class RMDateParser extends java.lang.Object implements RMDateParserConstants
-
-
Field Summary
Fields Modifier and Type Field Description Tokenjj_ntNext token.TokentokenCurrent token.RMDateParserTokenManagertoken_sourceGenerated Token Manager.-
Fields inherited from interface com.inductiveautomation.rm.parsing.RMDateParserConstants
A, AFTER, AGO, AM, AMPM, APR, APRILFOOLS, AT, AUG, BASTILLEDAY, BDAY, BEFORE, BLACKTUESDAY, BOXINGDAY, CHRISTMAS, CINCODEMAYO, COLON, DASH, DAY, DDAY, DEC, DECIMAL, DEFAULT, EOF, EOL, EVE, FEB, FIRST, FOURDIGIT, FOURTH, FRI, GMT, GROUNDHOGDAY, HALLOWEEN, HENCE, INDEPENDENCEDAY, INITLOCALE, ISO8601GMT, ISO8601SEPARATOR, JAN, JEFFSDAY, JILLSDAY, JOSHSDAY, JUL, JUN, LAST, LOCAL_DATEFIELD, LOCAL_SEPARATOR, MAR, MAY, MINSEC, MON, MONTH, NEVER, NEWYEARS, NEXT, NOV, NOW, OCT, ONEDIGIT, PEARLHARBOR, PERIOD, PM, SAINT, SAT, SECOND, SEP, SLASH, STPATTYSDAY, SUN, THE, THIRD, THIS, THISCOMING, THISPAST, THU, TIME, TIMEZONE, TIMEZONEOFFSET, TODAY, tokenImage, TOMORROW, TUE, TWODIGIT, TZ, VALENTINESDAY, VEDAY, VJDAY, WED, WEEK, YEAR, YESTERDAY
-
-
Constructor Summary
Constructors Constructor Description RMDateParser()RMDateParser(RMDateParserTokenManager tm)Constructor with generated Token Manager.RMDateParser(java.io.InputStream stream)Constructor with InputStream.RMDateParser(java.io.InputStream stream, java.lang.String encoding)Constructor with InputStream and supplied encodingRMDateParser(java.io.Reader stream)Constructor.RMDateParser(java.util.Locale l)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabsolute_date()intcalendarField()java.util.Datedate()voiddate_expression()simple expressions, like "3 weeks from this past christmas" or "a year ago", "3 months from now", " Doesn't do things like "8/13/99 + 3 days", but that seems really stupid Some other interesting cases that we don't handle might be : "the 4th thursday in November", "the saturday after christmas" "the last monday in may" "a week ago this friday"voiddatePartsSeparator()intdayOrdinal()voiddisable_tracing()Disable tracing.voidenable_tracing()Enable tracing.intfourDigitInt()doublefraction()ParseExceptiongenerateParseException()Generate ParseException.java.util.DategetDate(java.lang.String aString)Main entry point.TokengetNextToken()Get the next Token.TokengetToken(int index)Get the specific Token.voidholiday(int modifier)int[]initLocale()intintInRange(int lo, int hi)voidiso_8601_date()intlocalField()voidlong_date()static voidmain(java.lang.String[] args)intmodifier()intmonth()java.util.Dateone_line()voidReInit(RMDateParserTokenManager tm)Reinitialise.voidReInit(java.io.InputStream stream)Reinitialise.voidReInit(java.io.InputStream stream, java.lang.String encoding)Reinitialise.voidReInit(java.io.Reader stream)Reinitialise.voidrelative_date()voidresetLocale(java.util.Locale l)Set the locale.voidsetAcceptsTwoDigitYears(int earliest)Y2K handling - accept 2 digit years.voidsetiso_8601_time()voidsetiso_8601_timezone()voidsetRejectsTwoDigitYears()Y2K handling - call this to make the parser throw an error when it encounters a 2 digit yearvoidsettime()voidsettimezone()voidsimple_date()voidspecific_day()inttwoOrFourDigitDateField(boolean isYear)inttwoOrFourDigitYear()intweekday()
-
-
-
Field Detail
-
token_source
public RMDateParserTokenManager token_source
Generated Token Manager.
-
token
public Token token
Current token.
-
jj_nt
public Token jj_nt
Next token.
-
-
Constructor Detail
-
RMDateParser
public RMDateParser()
-
RMDateParser
public RMDateParser(java.util.Locale l)
-
RMDateParser
public RMDateParser(java.io.InputStream stream)
Constructor with InputStream.
-
RMDateParser
public RMDateParser(java.io.InputStream stream, java.lang.String encoding)Constructor with InputStream and supplied encoding
-
RMDateParser
public RMDateParser(java.io.Reader stream)
Constructor.
-
RMDateParser
public RMDateParser(RMDateParserTokenManager tm)
Constructor with generated Token Manager.
-
-
Method Detail
-
resetLocale
public void resetLocale(java.util.Locale l)
Set the locale. Currently just uses the DateFormat to figure out how to interpret "3/4/05"
-
setRejectsTwoDigitYears
public void setRejectsTwoDigitYears()
Y2K handling - call this to make the parser throw an error when it encounters a 2 digit year
-
setAcceptsTwoDigitYears
public void setAcceptsTwoDigitYears(int earliest)
Y2K handling - accept 2 digit years.'earliest' can be anything, and is the earliest possible year that would be representable by 2 digits. setAcceptsTwoDigitYears(1920) : 00->2000, 01->2001,...,19->2019, 20->1920, 21-1921... setAcceptsTwoDigitYears(1700) : 00->1700, ... 99->1799 This is similar to DateFormatter, but they let you pick the earliest day: eg. {8/13/1920 - 8/13/2019} which seems like overkill.
-
getDate
public java.util.Date getDate(java.lang.String aString)
Main entry point. Parses aString as best it can.
-
main
public static void main(java.lang.String[] args)
-
one_line
public final java.util.Date one_line() throws ParseException- Throws:
ParseException
-
date
public final java.util.Date date() throws ParseException- Throws:
ParseException
-
localField
public final int localField() throws ParseException- Throws:
ParseException
-
initLocale
public final int[] initLocale() throws ParseException- Throws:
ParseException
-
month
public final int month() throws ParseException- Throws:
ParseException
-
weekday
public final int weekday() throws ParseException- Throws:
ParseException
-
modifier
public final int modifier() throws ParseException- Throws:
ParseException
-
calendarField
public final int calendarField() throws ParseException- Throws:
ParseException
-
intInRange
public final int intInRange(int lo, int hi) throws ParseException- Throws:
ParseException
-
date_expression
public final void date_expression() throws ParseExceptionsimple expressions, like "3 weeks from this past christmas" or "a year ago", "3 months from now", " Doesn't do things like "8/13/99 + 3 days", but that seems really stupid Some other interesting cases that we don't handle might be : "the 4th thursday in November", "the saturday after christmas" "the last monday in may" "a week ago this friday"- Throws:
ParseException
-
dayOrdinal
public final int dayOrdinal() throws ParseException- Throws:
ParseException
-
twoOrFourDigitYear
public final int twoOrFourDigitYear() throws ParseException- Throws:
ParseException
-
twoOrFourDigitDateField
public final int twoOrFourDigitDateField(boolean isYear) throws ParseException- Throws:
ParseException
-
fourDigitInt
public final int fourDigitInt() throws ParseException- Throws:
ParseException
-
relative_date
public final void relative_date() throws ParseException- Throws:
ParseException
-
holiday
public final void holiday(int modifier) throws ParseException- Throws:
ParseException
-
specific_day
public final void specific_day() throws ParseException- Throws:
ParseException
-
datePartsSeparator
public final void datePartsSeparator() throws ParseException- Throws:
ParseException
-
simple_date
public final void simple_date() throws ParseException- Throws:
ParseException
-
absolute_date
public final void absolute_date() throws ParseException- Throws:
ParseException
-
long_date
public final void long_date() throws ParseException- Throws:
ParseException
-
settime
public final void settime() throws ParseException- Throws:
ParseException
-
settimezone
public final void settimezone() throws ParseException- Throws:
ParseException
-
fraction
public final double fraction() throws ParseException- Throws:
ParseException
-
iso_8601_date
public final void iso_8601_date() throws ParseException- Throws:
ParseException
-
setiso_8601_time
public final void setiso_8601_time() throws ParseException- Throws:
ParseException
-
setiso_8601_timezone
public final void setiso_8601_timezone() throws ParseException- Throws:
ParseException
-
ReInit
public void ReInit(java.io.InputStream stream)
Reinitialise.
-
ReInit
public void ReInit(java.io.InputStream stream, java.lang.String encoding)Reinitialise.
-
ReInit
public void ReInit(java.io.Reader stream)
Reinitialise.
-
ReInit
public void ReInit(RMDateParserTokenManager tm)
Reinitialise.
-
getNextToken
public final Token getNextToken()
Get the next Token.
-
getToken
public final Token getToken(int index)
Get the specific Token.
-
generateParseException
public ParseException generateParseException()
Generate ParseException.
-
enable_tracing
public final void enable_tracing()
Enable tracing.
-
disable_tracing
public final void disable_tracing()
Disable tracing.
-
-