| | |
| | | */ |
| | | @Override |
| | | public void validateValue(Integer value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | if (!allowUnlimited && value < lowerLimit) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | |
| | | // unlimited allowed |
| | | } else if (value >= 0 && value < lowerLimit) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | if ((upperLimit != null) && (value > upperLimit)) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public String encodeValue(Integer value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | // Make sure that we correctly encode negative values as "unlimited". |
| | |
| | | */ |
| | | @Override |
| | | public Integer decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | if (allowUnlimited) { |
| | |
| | | try { |
| | | i = Integer.valueOf(value); |
| | | } catch (NumberFormatException e) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | try { |
| | | validateValue(i); |
| | | } catch (IllegalPropertyValueException e) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | } catch (PropertyException e) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | return i; |