if (this.accepts(scheduleExpressionType) == false) { throw EjbLogger.EJB3_TIMER_LOGGER.invalidScheduleExpressionType(value, this.getClass().getName(), this.scheduleExpressionType.toString()); RangeValue range = new RangeValue(value); this.processRangeValue(range); break; ListValue list = new ListValue(value); this.processListValue(list); break; IncrementValue incrValue = new IncrementValue(value); this.processIncrement(incrValue); break; SingleValue singleValue = new SingleValue(value); this.processSingleValue(singleValue); break;
protected void processRangeValue(RangeValue range) { String start = range.getStart(); String end = range.getEnd(); if (this.isRelativeValue(start) || this.isRelativeValue(end)) { this.relativeValues.add(range); return; Integer rangeStart = this.parseInt(start); Integer rangeEnd = this.parseInt(end); this.assertValid(rangeStart); this.assertValid(rangeEnd); for (int i = rangeStart; i <= this.getMaxValue(); i++) { this.absoluteValues.add(i); for (int i = this.getMinValue(); i <= rangeEnd; i++) { this.absoluteValues.add(i);
protected void processListValue(ListValue list) { for (String listItem : list.getValues()) { this.processListItem(listItem); } }
protected void processSingleValue(SingleValue singleValue) { String value = singleValue.getValue(); if (this.isRelativeValue(value)) { this.relativeValues.add(singleValue); } else { Integer val = this.parseInt(value); this.assertValid(val); this.absoluteValues.add(val); } }
protected void processIncrement(IncrementValue incr) { String startValue = incr.getStart(); Integer start = startValue.equals("*") ? 0 : this.parseInt(startValue); // make sure it's a valid value this.assertValid(start); Integer interval = this.parseInt(incr.getInterval()); this.absoluteValues.add(start); int next = start + interval; int maxValue = this.getMaxValue(); while (next <= maxValue) { this.absoluteValues.add(next); next = next + interval; } }
protected void assertValid(Integer value) throws IllegalArgumentException { if (value == null) { throw EjbLogger.EJB3_TIMER_LOGGER.couldNotParseScheduleExpression(this.origValue); } int max = this.getMaxValue(); int min = this.getMinValue(); if (value > max || value < min) { throw EjbLogger.EJB3_TIMER_LOGGER.invalidValuesRange(value, min, max); } }
protected void processListItem(String listItem) { // check what type of a value the list item is. // Each item in the list must be an individual attribute value or a range. // List items can not themselves be lists, wild-cards, or increments. ScheduleExpressionType listItemType = ScheduleExpressionTypeUtil.getType(listItem); switch (listItemType) { case SINGLE_VALUE: SingleValue singleVal = new SingleValue(listItem); this.processSingleValue(singleVal); return; case RANGE: RangeValue range = new RangeValue(listItem); this.processRangeValue(range); return; default: throw EjbLogger.EJB3_TIMER_LOGGER.invalidListValue(listItem); } }
@Override protected Integer parseInt(String alias) { try { return super.parseInt(alias); } catch (NumberFormatException nfe) { if (MONTH_ALIAS != null) { String lowerCaseAlias = alias.toLowerCase(Locale.ENGLISH); return MONTH_ALIAS.get(lowerCaseAlias); } } return null; }
@Override protected void assertValid(Integer value) throws IllegalArgumentException { if (value != null && value == 0) { throw EjbLogger.EJB3_TIMER_LOGGER.invalidValueDayOfMonth(value); } super.assertValid(value); }
protected void processSingleValue(SingleValue singleValue) { String value = singleValue.getValue(); if (this.isRelativeValue(value)) { this.relativeValues.add(singleValue); } else { Integer val = this.parseInt(value); this.assertValid(val); this.absoluteValues.add(val); } }
protected void processIncrement(IncrementValue incr) { String startValue = incr.getStart(); Integer start = startValue.equals("*") ? 0 : this.parseInt(startValue); // make sure it's a valid value this.assertValid(start); Integer interval = this.parseInt(incr.getInterval()); this.absoluteValues.add(start); int next = start + interval; int maxValue = this.getMaxValue(); while (next <= maxValue) { this.absoluteValues.add(next); next = next + interval; } }
protected void assertValid(Integer value) throws IllegalArgumentException { if (value == null) { throw MESSAGES.couldNotParseScheduleExpression(this.origValue); } int max = this.getMaxValue(); int min = this.getMinValue(); if (value > max || value < min) { throw MESSAGES.invalidValuesRange(value,min,max); } }
protected void processListItem(String listItem) { // check what type of a value the list item is. // Each item in the list must be an individual attribute value or a range. // List items can not themselves be lists, wild-cards, or increments. ScheduleExpressionType listItemType = ScheduleExpressionTypeUtil.getType(listItem); switch (listItemType) { case SINGLE_VALUE: SingleValue singleVal = new SingleValue(listItem); this.processSingleValue(singleVal); return; case RANGE: RangeValue range = new RangeValue(listItem); this.processRangeValue(range); return; default: throw MESSAGES.invalidListValue(listItem); } }
@Override protected Integer parseInt(String alias) { try { return super.parseInt(alias); } catch (NumberFormatException nfe) { if (DAY_OF_WEEK_ALIAS != null) { String lowerCaseAlias = alias.toLowerCase(Locale.ENGLISH); return DAY_OF_WEEK_ALIAS.get(lowerCaseAlias); } } return null; }
@Override protected void assertValid(Integer value) throws IllegalArgumentException { if (value != null && value == 0) { throw MESSAGES.invalidValueDayOfMonth(value); } super.assertValid(value); }
protected void processRangeValue(RangeValue range) { String start = range.getStart(); String end = range.getEnd(); if (this.isRelativeValue(start) || this.isRelativeValue(end)) { this.relativeValues.add(range); return; Integer rangeStart = this.parseInt(start); Integer rangeEnd = this.parseInt(end); this.assertValid(rangeStart); this.assertValid(rangeEnd); for (int i = rangeStart; i <= this.getMaxValue(); i++) { this.absoluteValues.add(i); for (int i = this.getMinValue(); i <= rangeEnd; i++) { this.absoluteValues.add(i);
if (this.accepts(scheduleExpressionType) == false) { throw MESSAGES.invalidScheduleExpressionType(value,this.getClass().getName(),this.scheduleExpressionType.toString()); RangeValue range = new RangeValue(value); this.processRangeValue(range); break; ListValue list = new ListValue(value); this.processListValue(list); break; IncrementValue incrValue = new IncrementValue(value); this.processIncrement(incrValue); break; SingleValue singleValue = new SingleValue(value); this.processSingleValue(singleValue); break;
@Override protected Integer parseInt(String alias) { try { return super.parseInt(alias); } catch (NumberFormatException nfe) { if (DAY_OF_MONTH_ALIAS != null) { String lowerCaseAlias = alias.toLowerCase(Locale.ENGLISH); return DAY_OF_MONTH_ALIAS.get(lowerCaseAlias); } } return null; } }
protected void processListValue(ListValue list) { for (String listItem : list.getValues()) { this.processListItem(listItem); } }
@Override protected Integer parseInt(String alias) { try { return super.parseInt(alias); } catch (NumberFormatException nfe) { if (MONTH_ALIAS != null) { String lowerCaseAlias = alias.toLowerCase(Locale.ENGLISH); return MONTH_ALIAS.get(lowerCaseAlias); } } return null; }