Class CronExpressionParser
java.lang.Object
com.atlassian.jira.web.component.cron.parser.CronExpressionParser
Represents a cron string with accessor methods to get at the individual fields. This is only used to back our
Cron editor. This will tell you via the
isValidForEditor()
method whether the cron string this is constructed
with will be parseable via the editor. To populate the editor use the getCronEditorBean()
method.
There are four modes that the editor supports:
- Daily Mode
- Days Per Week Mode
- Days Per Month Mode
- Advanced Mode
If a cron string is not valid for the editor then the only available mode will be the advanced mode and the editor
state methods (e.g. getDayOfMonth()
, getHoursEntry()
) will return details of the default state
represented by DEFAULT_CRONSTRING
as they are not able to represent the advanced cron string.
The validation that this object performs is in the context of valid cron strings that will fit into the editor. This object does not validate that the over all string is a valid cron string.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Cron string that puts the editor into the default state. -
Constructor Summary
ConstructorDescriptionCreates a parser in default state usingDEFAULT_CRONSTRING
.CronExpressionParser
(String cronString) Parses the given cronString to establish the state of this CronExpressionParser. -
Method Summary
Modifier and TypeMethodDescriptionWill provide theCronEditorBean
which represents the state of the form for the configured cron string.Returns the cron string that the object was constructed with.Gets the day of month field specified in the cron string.Gets theCronDayOfWeekEntry
that represents the day of week cron field.Gets theCronHoursEntry
that represents the hours cron field.int
Used to determine the total increment in minutes that are implied by the crons hour and minutes field.Gets theCronMinutesEntry
that represents the minutes cron field.boolean
Will return true if the passed in cron string is not valid for the editor.boolean
Will return true if the editors daily mode can handle the provided cron string.boolean
Returns true ifisDaysPerMonthMode()
is true and the string in the days of week field can be handled by the editor.boolean
Will return true if the editors day per week mode can handle the provided cron string.boolean
Will return true if the editors days per month mode can handle the provided cron string.boolean
Returns true only if the cron string can be handled by the cron editor UI.
-
Field Details
-
DEFAULT_CRONSTRING
Cron string that puts the editor into the default state.- See Also:
-
-
Constructor Details
-
CronExpressionParser
public CronExpressionParser()Creates a parser in default state usingDEFAULT_CRONSTRING
. -
CronExpressionParser
Parses the given cronString to establish the state of this CronExpressionParser.- Parameters:
cronString
- the cron string to parse.
-
-
Method Details
-
getCronEditorBean
Will provide theCronEditorBean
which represents the state of the form for the configured cron string.- Returns:
- the bean
-
getCronString
Returns the cron string that the object was constructed with. This method does not guarantee that the returned cron string is valid.- Returns:
- unmodified cronString passed into the constructor
-
isValidForEditor
public boolean isValidForEditor()Returns true only if the cron string can be handled by the cron editor UI. If this method returns false then all method butgetCronString()
will throw an IllegalStateException work properly.- Returns:
- true only if the editor has a state that corresponds to this cron expression.
-
isAdvancedMode
public boolean isAdvancedMode()Will return true if the passed in cron string is not valid for the editor.- Returns:
- true if the cron string can not be handled, false otherwise.
-
isDailyMode
public boolean isDailyMode()Will return true if the editors daily mode can handle the provided cron string.- Returns:
- true only if the mode is daily.
-
isDayPerWeekMode
public boolean isDayPerWeekMode()Will return true if the editors day per week mode can handle the provided cron string.- Returns:
- true only if we are in day per week mode.
-
isDaysPerMonthMode
public boolean isDaysPerMonthMode()Will return true if the editors days per month mode can handle the provided cron string.- Returns:
- true only if we are in days per month mode.
-
isDayOfWeekOfMonth
public boolean isDayOfWeekOfMonth()Returns true ifisDaysPerMonthMode()
is true and the string in the days of week field can be handled by the editor.- Returns:
- true only if we are in the Nth Xday of the month mode (where N is a week in month number and X is mon,tue etc)
-
getDayOfMonth
Gets the day of month field specified in the cron string.- Returns:
- 1-31 or L.
-
getMinutesEntry
Gets theCronMinutesEntry
that represents the minutes cron field.- Returns:
- the minutes part of the cron string.
-
getHoursEntry
Gets theCronHoursEntry
that represents the hours cron field.- Returns:
- the hours part of the cron string.
-
getDaysOfWeekEntry
Gets theCronDayOfWeekEntry
that represents the day of week cron field.- Returns:
- the days of the week part of the cronstring.
-
getIncrementInMinutes
public int getIncrementInMinutes()Used to determine the total increment in minutes that are implied by the crons hour and minutes field. If the hours and minutes field have an increment then the increment will come into play. An increment of 0 implies that the increment is once per day.- Returns:
- the increment of repetition in minutes or 0 if there is no repetition.
-