KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jahia.security.license;
2
3 import org.jahia.bin.JahiaInterface;
4 import org.jahia.resourcebundle.ResourceMessage;
5
6 /**
7  * <p>Title: </p>
8  * <p>Description: </p>
9  * <p>Copyright: Copyright (c) 2002</p>
10  * <p>Company: Jahia Ltd</p>
11  * @author Serge Huber
12  * @version 1.0
13  */

14
15 public class BuildNumberValidator extends AbstractValidator {
16     public BuildNumberValidator (String JavaDoc name, String JavaDoc value, License license) {
17         super(name, value, license);
18     }
19
20     public boolean assertEquals (String JavaDoc value) {
21         int licenseBuildNumber = Integer.parseInt(value);
22         if (licenseBuildNumber == JahiaInterface.BUILD_NUMBER) {
23             return true;
24         } else {
25             errorMessage = new ResourceMessage("org.jahia.security.license.BuildNumberValidator.invalidBuildNumber.label", new Integer JavaDoc(JahiaInterface.BUILD_NUMBER), new Integer JavaDoc(licenseBuildNumber));
26             return false;
27         }
28     }
29
30     public boolean assertInRange (String JavaDoc fromValue, String JavaDoc toValue) {
31         int minBuildNumber = Integer.parseInt(fromValue);
32         int maxBuildNumber = Integer.parseInt(toValue);
33         if ( (JahiaInterface.BUILD_NUMBER >= minBuildNumber) &&
34              (JahiaInterface.BUILD_NUMBER < maxBuildNumber) ) {
35             return true;
36         } else {
37             errorMessage = new ResourceMessage("org.jahia.security.license.BuildNumberValidator.buildNumberNotInRange.label", new Integer JavaDoc(JahiaInterface.BUILD_NUMBER), new Integer JavaDoc(minBuildNumber), new Integer JavaDoc(maxBuildNumber));
38             return false;
39         }
40     }
41
42 }
Popular Tags