protected void processListValue(ListValue list) { for (String listItem : list.getValues()) { this.processListItem(listItem); } }
/** * Creates a {@link RangeValue} by parsing the passed <code>value</code>. * <p> * Upon successfully parsing the passed <code>value</code>, this constructor * sets the start and the end value of this {@link RangeValue} * </p> * * @param range The value to be parsed * @throws IllegalArgumentException If the passed <code>value</code> cannot be * represented as an {@link RangeValue} */ public RangeValue(String range) { String[] values = getRangeValues(range); if (values == null || values.length != 2) { throw EjbLogger.EJB3_TIMER_LOGGER.invalidRange(range); } this.rangeStart = values[0].trim(); this.rangeEnd = values[1].trim(); }
/** * Returns the corresponding {@link org.jboss.as.ejb3.timerservice.schedule.value.ScheduleExpressionType} for the passed value * * @param value The value to be parsed * @return */ public static ScheduleExpressionType getType(String value) { if (value == null) { throw EjbLogger.EJB3_TIMER_LOGGER.valueIsNull(); } // Order of check is important. // TODO: Explain why this order is important if (value.trim().equals("*")) { return ScheduleExpressionType.WILDCARD; } if (value.contains(",")) { return ScheduleExpressionType.LIST; } if (value.contains("-") && RangeValue.accepts(value)) { return ScheduleExpressionType.RANGE; } if (value.contains("/")) { return ScheduleExpressionType.INCREMENT; } return ScheduleExpressionType.SINGLE_VALUE; } }
throw EjbLogger.EJB3_TIMER_LOGGER.invalidScheduleExpressionType(value, this.getClass().getName(), this.scheduleExpressionType.toString()); RangeValue range = new RangeValue(value); ListValue list = new ListValue(value); IncrementValue incrValue = new IncrementValue(value); SingleValue singleValue = new SingleValue(value);
if (relativeValue instanceof SingleValue) { SingleValue singleValue = (SingleValue) relativeValue; String value = singleValue.getValue(); Integer absoluteDayOfMonth = this.getAbsoluteDayOfMonth(cal, value); eligibleDaysOfMonth.add(absoluteDayOfMonth); } else if (relativeValue instanceof RangeValue) { RangeValue range = (RangeValue) relativeValue; String start = range.getStart(); String end = range.getEnd();
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); } }
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; } }
var RangeValue = function (name, startVal, stopVal) { var self = this; self.rangeName = name; self.rangeStartVal = startVal; self.rangeStopVal = stopVal; }; function myVm() { var self = this; self.dateranges = ko.observableArray([ new RangeValue("Today", "2014-04-28", "2014-04-28"), new RangeValue("Yesterday", "2014-04-27", "2014-04-27"), new RangeValue("This Week", "2014-04-28", "2014-05-04"), new RangeValue("Last Week", "2014-04-21", "2014-04-27")]); self.selectedRange = ko.observable(); } var viewModel = new myVm(); ko.applyBindings(viewModel);
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); } }
throw MESSAGES.invalidScheduleExpressionType(value,this.getClass().getName(),this.scheduleExpressionType.toString()); RangeValue range = new RangeValue(value); ListValue list = new ListValue(value); IncrementValue incrValue = new IncrementValue(value); SingleValue singleValue = new SingleValue(value);
if (relativeValue instanceof SingleValue) { SingleValue singleValue = (SingleValue) relativeValue; String value = singleValue.getValue(); Integer absoluteDayOfMonth = this.getAbsoluteDayOfMonth(cal, value); eligibleDaysOfMonth.add(absoluteDayOfMonth); } else if (relativeValue instanceof RangeValue) { RangeValue range = (RangeValue) relativeValue; String start = range.getStart(); String end = range.getEnd();
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); } }
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 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); } }
/** * Creates a {@link RangeValue} by parsing the passed <code>value</code>. * <p> * Upon successfully parsing the passed <code>value</code>, this constructor * sets the start and the end value of this {@link RangeValue} * </p> * * @param range The value to be parsed * @throws IllegalArgumentException If the passed <code>value</code> cannot be * represented as an {@link RangeValue} */ public RangeValue(String range) { String[] values = getRangeValues(range); if (values == null || values.length != 2) { throw MESSAGES.invalidRange(range); } this.rangeStart = values[0].trim(); this.rangeEnd = values[1].trim(); }
/** * Returns the corresponding {@link org.jboss.as.ejb3.timerservice.schedule.value.ScheduleExpressionType} for the passed value * * @param value The value to be parsed * @return */ public static ScheduleExpressionType getType(String value) { if (value == null) { throw MESSAGES.valueIsNull(); } // Order of check is important. // TODO: Explain why this order is important if (value.trim().equals("*")) { return ScheduleExpressionType.WILDCARD; } if (value.contains(",")) { return ScheduleExpressionType.LIST; } if (value.contains("-") && RangeValue.accepts(value)) { return ScheduleExpressionType.RANGE; } if (value.contains("/")) { return ScheduleExpressionType.INCREMENT; } return ScheduleExpressionType.SINGLE_VALUE; } }