|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.atlassian.scheduler.caesium.cron.parser.CronExpressionParser
public class CronExpressionParser
Parser for cron expressions.
Strictly speaking, "names" are only permitted in the month and day-of-week fields; however, to simplify the parser, they are accepted by the parser and the field type fails to resolve them, instead.
Tokens are collected by CronLexer
. Although a few special cases exist to help maintain compatibility
with Quartz, the EBNF looks
something like this:
(* ========================================================= *)
(* Basic syntax available to all fields, like 2-7,9 or */3 *)
(* English names and ranges, like MON,WED,FRI or APR-SEP *)
(* are also included here. *)
(* ========================================================= *)
slash_interval = SLASH , NUMBER
number_range = NUMBER , HYPHEN , NUMBER , [ slash_interval ]
name_range = NAME , HYPHEN , NAME , [ slash_interval ]
number_expression = number_range , [ slash_interval ]
| NUMBER , [ slash_interval ]
name_expression = name_range
| NAME , [ slash_interval ]
asterisk_expression = ASTERISK , [ slash_interval ]
simple_expression = name_expression
| number_expression
| asterisk_expression
| slash_interval (* implied asterisk *)
simple_field = simple_expression , { COMMA , simple_expression }
(* ========================================================= *)
(* Special syntax for day-of-month, like 15W or L-3W *)
(* ========================================================= *)
special_dom_last_offset_number = NUMBER , [ FLAG_W ]
special_dom_last_offset = special_dom_last_offset_number
special_dom_last_weekday = FLAG_W
special_dom_last = FLAG_L , HYPHEN , special_dom_last_offset
| FLAG_L , special_dom_last_weekday
| FLAG_L
special_dom_weekday = FLAG_W
special_dom_field = special_dom_last
| special_dom_weekday
(* ========================================================= *)
(* Special syntax for day-of-week, like 6#3 or 4L *)
(* ========================================================= *)
special_dow_nth = HASH , NUMBER
special_dow_name = NAME , special_dow_nth
special_dow_number = NUMBER , special_dow_nth
| NUMBER , FLAG_L
special_dow_field = special_dow_name
| special_dow_number
| FLAG_L (* Synonymous with "7" when by itself like this *)
(* ========================================================= *)
(* Field definitions *)
(* ========================================================= *)
second_field = simple_field
minute_field = simple_field
hour_field = simple_field
dom_field = special_dom_field
| simple_field
month_field = simple_field
dow_field = special_dow_field
| simple_field
year_field = [ simple_field , [ WHITESPACE , { (* any sequence of unparsed tokens *) } ]
(* ========================================================= *)
(* Full expression grammar *)
(* ========================================================= *)
second_minute_hour = second_field , WHITESPACE, minute_field , WHITESPACE , hour_field , WHITESPACE
qm_month_dow = QUESTION_MARK , WHITESPACE , month_field , WHITESPACE , dow_field
dom_month_qm = dom_field , WHITESPACE , month_field, WHITESPACE , QUESTION_MARK
dom_month_dow = qm_month_dow
| dom_month_qm
cron_expression = [ WHITESPACE ] , second_minute_hour , dom_month_dow , [ WHITESPACE , year_field ] ;
Method Summary | |
---|---|
static boolean |
isValid(String cronExpression)
Returns true if parse(String) will succeed; false if it will report a syntax error. |
static CronExpression |
parse(String cronExpression)
Parses the supplied cron expression into a form that can evaluate it against candidate dates or find the next time that it matches. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static CronExpression parse(String cronExpression) throws com.atlassian.scheduler.cron.CronSyntaxException
cronExpression
- the cron expression to parse
com.atlassian.scheduler.cron.CronSyntaxException
- if there is a problem with the cron expressionpublic static boolean isValid(String cronExpression)
true
if parse(String)
will succeed; false
if it will report a syntax error.
cronExpression
- the cron expression to parse
true
if parse(String)
will succeed; false
if it will report a syntax error.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |