KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.jahia.utils.Version;
10 import org.jahia.resourcebundle.ResourceMessage;
11
12 /**
13  * @author loom
14  *
15  * To change the template for this generated type comment go to
16  * Window>Preferences>Java>Code Generation>Code and Comments
17  */

18 public class VersionValidator extends AbstractValidator {
19
20     protected Version internalVersion = new Version("1.0");
21
22     public VersionValidator(String JavaDoc name, String JavaDoc value, License license) {
23         super(name, value, license);
24     }
25
26     public boolean assertEquals(String JavaDoc value) {
27         Version licenseVersion = new Version(value);
28         if (licenseVersion.equals(internalVersion)) {
29             return true;
30         } else {
31             errorMessage = new ResourceMessage("org.jahia.security.license.VersionValidator.invalidVersion.label", internalVersion, value);
32             return false;
33         }
34     }
35
36     public boolean assertInRange(String JavaDoc fromValue, String JavaDoc toValue) {
37         Version fromVersion = new Version(fromValue);
38         Version toVersion = new Version(toValue);
39         if ((fromVersion.compareTo(internalVersion) <= 0) &&
40             (toVersion.compareTo(internalVersion) > 0)) {
41             return true;
42         }
43         errorMessage = new ResourceMessage("org.jahia.security.license.VersionValidator.versionNotInRange.label", internalVersion, fromValue, toValue);
44         return false;
45     }
46
47 }
48
Popular Tags