KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > security > license > RangeLimitValue


1 /*
2  * Created on Sep 14, 2003
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */

7 package org.jahia.security.license;
8
9 /**
10  * Simple range limit
11  * @author loom
12  *
13  * To change the template for this generated type comment go to
14  * Window>Preferences>Java>Code Generation>Code and Comments
15  */

16 public class RangeLimitValue extends LimitValue {
17     
18     private final static String JavaDoc RANGE_SEPERATOR = " to ";
19
20     private String JavaDoc fromValue = null;
21     private String JavaDoc toValue = null;
22     
23     public RangeLimitValue(String JavaDoc 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 JavaDoc value) {
36         return (value.indexOf(RANGE_SEPERATOR) != -1);
37     }
38     
39     /**
40      * @return
41      */

42     public String JavaDoc getFromValue() {
43         return fromValue;
44     }
45
46     /**
47      * @return
48      */

49     public String JavaDoc getToValue() {
50         return toValue;
51     }
52
53     public boolean check(Validator validator) {
54         return validator.assertInRange(fromValue, toValue);
55     }
56     
57 }
58
Popular Tags