public class CronExpressionFixer extends Object
There are certain error cases that Quartz ignored but that Caesium enforces. This tool attempts to identify these problems and repair the cron expression. The type of repair done is intended to preserve the spirit of the original expression as closely as possible. The following specific cases are handled:
Problem | Example | Repaired | Comment |
---|---|---|---|
Invalid step interval | 0 0/60 * * * ? | 0 0 * * * ? | Quartz ignores the invalid interval, so throwing it away has the same result |
Multiple values with W | 0 0 0 1W,15W * ? | 0 0 0 1,15 * ? | Quartz either ignores all of the W flags or only processes the first value, depending on which came first. Throwing away the W flags is the easiest way to come as close as we can to what they asked for. |
Illegal characters | 0 0 0 ? * *? | 0 0 0 ? * * | Quartz ignores the stray ? at the end. This repair code will try
just deleting the illegal character. |
If the cron expression parser returns an error that is not covered by any of these cases, or if
after 5
attempts to fix the expression it still has problems, we give up.
Modifier and Type | Class and Description |
---|---|
static class |
CronExpressionFixer.Result
Represents the result of an attempt to repair a cron expression.
|
Modifier and Type | Method and Description |
---|---|
static CronExpressionFixer.Result |
repairCronExpression(String cronExpression)
Attempts to repair a possibly broken cron expression.
|
@Nonnull public static CronExpressionFixer.Result repairCronExpression(String cronExpression)
cronExpression
- the cron expression to repairCopyright © 2002-2021 Atlassian. All Rights Reserved.