public class

CronExpressionParser

extends Object
java.lang.Object
   ↳ com.atlassian.jira.web.component.cron.parser.CronExpressionParser

Class Overview

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:

  1. Daily Mode
  2. Days Per Week Mode
  3. Days Per Month Mode
  4. 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.

Summary

Constants
String DEFAULT_CRONSTRING Cron string that puts the editor into the default state.
Public Constructors
CronExpressionParser()
Creates a parser in default state using DEFAULT_CRONSTRING.
CronExpressionParser(String cronString)
Parses the given cronString to establish the state of this CronExpressionParser.
Public Methods
CronEditorBean getCronEditorBean()
Will provide the CronEditorBean which represents the state of the form for the configured cron string.
String getCronString()
Returns the cron string that the object was constructed with.
String getDayOfMonth()
Gets the day of month field specified in the cron string.
CronDayOfWeekEntry getDaysOfWeekEntry()
Gets the CronDayOfWeekEntry that represents the day of week cron field.
CronHoursEntry getHoursEntry()
Gets the CronHoursEntry that represents the hours cron field.
int getIncrementInMinutes()
Used to determine the total increment in minutes that are implied by the crons hour and minutes field.
CronMinutesEntry getMinutesEntry()
Gets the CronMinutesEntry that represents the minutes cron field.
boolean isAdvancedMode()
Will return true if the passed in cron string is not valid for the editor.
boolean isDailyMode()
Will return true if the editors daily mode can handle the provided cron string.
boolean isDayOfWeekOfMonth()
Returns true if isDaysPerMonthMode() is true and the string in the days of week field can be handled by the editor.
boolean isDayPerWeekMode()
Will return true if the editors day per week mode can handle the provided cron string.
boolean isDaysPerMonthMode()
Will return true if the editors days per month mode can handle the provided cron string.
boolean isValidForEditor()
Returns true only if the cron string can be handled by the cron editor UI.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String DEFAULT_CRONSTRING

Cron string that puts the editor into the default state.

Constant Value: "0 0 1 ? * *"

Public Constructors

public CronExpressionParser ()

Creates a parser in default state using DEFAULT_CRONSTRING.

public CronExpressionParser (String cronString)

Parses the given cronString to establish the state of this CronExpressionParser.

Parameters
cronString the cron string to parse.

Public Methods

public CronEditorBean getCronEditorBean ()

Will provide the CronEditorBean which represents the state of the form for the configured cron string.

Returns
  • the bean

public String 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

public String getDayOfMonth ()

Gets the day of month field specified in the cron string.

Returns
  • 1-31 or L.

public CronDayOfWeekEntry getDaysOfWeekEntry ()

Gets the CronDayOfWeekEntry that represents the day of week cron field.

Returns
  • the days of the week part of the cronstring.

public CronHoursEntry getHoursEntry ()

Gets the CronHoursEntry that represents the hours cron field.

Returns
  • the hours part of the cron string.

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.

public CronMinutesEntry getMinutesEntry ()

Gets the CronMinutesEntry that represents the minutes cron field.

Returns
  • the minutes part of the cron string.

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.

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.

public boolean isDayOfWeekOfMonth ()

Returns true if isDaysPerMonthMode() 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)

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.

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.

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 but getCronString() will throw an IllegalStateException work properly.

Returns
  • true only if the editor has a state that corresponds to this cron expression.