throw new ScheduleParameterException("Invalid combination between days of week and days of month fields for timer:at");
}
if (resultMonths != null && resultMonths.size() == 1 && (resultMonths.first() instanceof Integer))
{
// If other arguments are cronParameters, use it for later computations
CronParameter parameter = null;
if (daysOfMonth instanceof CronParameter)
{
parameter = ((CronParameter) daysOfMonth);
}
else if (daysOfWeek instanceof CronParameter)
{
parameter = ((CronParameter) daysOfWeek);
}
if (parameter != null)
{
parameter.setMonth(resultMonths.first());
}
}
SortedSet<Integer> resultDaysOfWeek = computeValues(daysOfWeek, ScheduleUnit.DAYS_OF_WEEK);
SortedSet<Integer> resultDaysOfMonth = computeValues(daysOfMonth, ScheduleUnit.DAYS_OF_MONTH);
if (resultDaysOfWeek != null && resultDaysOfWeek.size() == 1 && (resultDaysOfWeek.first() instanceof Integer))
{
// The result is in the form "last xx of the month
// Days of week is replaced by a wildcard and days of month is updated with
// the computation of "last xx day of month".
// In this case "days of month" parameter has to be a wildcard.
if (resultDaysOfWeek.first() > 6)
{
if (resultDaysOfMonth != null)
{
throw new ScheduleParameterException("Invalid combination between days of week and days of month fields for timer:at");
}
resultDaysOfMonth = resultDaysOfWeek;
resultDaysOfWeek = null;
}
}
if (resultDaysOfMonth != null && resultDaysOfMonth.size() == 1 && (resultDaysOfMonth.first() instanceof Integer))
{
if (resultDaysOfWeek != null)
{
throw new ScheduleParameterException("Invalid combination between days of week and days of month fields for timer:at");
}
}
unitMap.put(ScheduleUnit.DAYS_OF_WEEK, resultDaysOfWeek);
unitMap.put(ScheduleUnit.DAYS_OF_MONTH, resultDaysOfMonth);
unitMap.put(ScheduleUnit.MONTHS, resultMonths);
if (args.length > 5)
{
unitMap.put(ScheduleUnit.SECONDS, computeValues(args[5], ScheduleUnit.SECONDS));
}
String timezone = null;
if (args.length > 6) {
if (!(args[6] instanceof WildcardParameter)) {
if (!(args[6] instanceof String)) {
throw new ScheduleParameterException("Invalid timezone parameter '" + args[6] + "' for timer:at, expected a string-type value");
}
timezone = (String) args[6];
}
}
CronParameter optionalDayOfMonthOp = getOptionalSpecialOp(daysOfMonth);
CronParameter optionalDayOfWeekOp = getOptionalSpecialOp(daysOfWeek);
return new ScheduleSpec(unitMap, timezone, optionalDayOfMonthOp, optionalDayOfWeekOp);
}