1 7 package org.jahia.security.license; 8 9 16 public class RangeLimitValue extends LimitValue { 17 18 private final static String RANGE_SEPERATOR = " to "; 19 20 private String fromValue = null; 21 private String toValue = null; 22 23 public RangeLimitValue(String value) { 24 super(value); 25 int rangeSepPos = value.indexOf(RANGE_SEPERATOR); 26 if (rangeSepPos == -1) { 27 this.fromValue = value; 28 this.toValue = null; 29 } else { 30 this.fromValue = value.substring(0, rangeSepPos).trim(); 31 this.toValue = value.substring(rangeSepPos + RANGE_SEPERATOR.length()).trim(); 32 } 33 } 34 35 public static boolean isRangeValue(String value) { 36 return (value.indexOf(RANGE_SEPERATOR) != -1); 37 } 38 39 42 public String getFromValue() { 43 return fromValue; 44 } 45 46 49 public String getToValue() { 50 return toValue; 51 } 52 53 public boolean check(Validator validator) { 54 return validator.assertInRange(fromValue, toValue); 55 } 56 57 } 58 | Popular Tags |