use of org.pentaho.platform.scheduler2.recur.QualifiedDayOfMonth in project pentaho-platform by pentaho.
the class QuartzScheduler method parseRecurrence.
private static List<ITimeRecurrence> parseRecurrence(String cronExpression, int tokenIndex) {
List<ITimeRecurrence> timeRecurrence = new ArrayList<ITimeRecurrence>();
// $NON-NLS-1$
String delims = "[ ]+";
String[] tokens = cronExpression.split(delims);
if (tokens.length > tokenIndex) {
String timeTokens = tokens[tokenIndex];
// $NON-NLS-1$
tokens = timeTokens.split(",");
if ((tokens.length > 1) || !(tokens[0].equals("*") || tokens[0].equals("?"))) {
// $NON-NLS-1$ //$NON-NLS-2$
RecurrenceList timeList = null;
for (String token : tokens) {
if (listPattern.matcher(token).matches()) {
if (timeList == null) {
timeList = new RecurrenceList();
}
timeList.getValues().add(Integer.parseInt(token));
} else {
if (timeList != null) {
timeRecurrence.add(timeList);
timeList = null;
}
if (sequencePattern.matcher(token).matches()) {
// $NON-NLS-1$
String[] days = token.split("-");
timeRecurrence.add(new SequentialRecurrence(Integer.parseInt(days[0]), Integer.parseInt(days[1])));
} else if (intervalPattern.matcher(token).matches()) {
// $NON-NLS-1$
String[] days = token.split("/");
timeRecurrence.add(new IncrementalRecurrence(Integer.parseInt(days[0]), Integer.parseInt(days[1])));
} else if ("L".equalsIgnoreCase(token)) {
timeRecurrence.add(new QualifiedDayOfMonth());
} else {
throw new IllegalArgumentException(Messages.getInstance().getErrorString(// $NON-NLS-1$
"ComplexJobTrigger.ERROR_0001_InvalidCronExpression"));
}
}
}
if (timeList != null) {
timeRecurrence.add(timeList);
}
}
} else {
throw new IllegalArgumentException(Messages.getInstance().getErrorString(// $NON-NLS-1$
"ComplexJobTrigger.ERROR_0001_InvalidCronExpression"));
}
return timeRecurrence;
}
Aggregations