01: // @@
02: // @@
03: /*
04: * Wi.Ser Framework
05: *
06: * Version: 1.8.1, 20-September-2007
07: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
08: *
09: * This library is free software; you can redistribute it and/or
10: * modify it under the terms of the GNU Lesser General Public
11: * License as published by the Free Software Foundation; either
12: * version 2 of the License, or (at your option) any later version.
13: *
14: * This library is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: * Lesser General Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser General Public
20: * License along with this library located in LGPL.txt in the
21: * license directory; if not, write to the
22: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23: * Boston, MA 02111-1307, USA.
24: *
25: * If this agreement does not cover your requirements, please contact us
26: * via email to get detailed information about the commercial license
27: * or our service offerings!
28: *
29: */
30: // @@
31: package de.ug2t.unifiedGui.validator;
32:
33: import de.ug2t.kernel.*;
34:
35: public final class UnRangeValidator extends AUnValidator {
36: private double pem_start = Double.MIN_VALUE;
37: private double pem_end = Double.MAX_VALUE;
38: private String pem_nir = null;
39:
40: private static final String NO_VALID_NUMBER = "No Valid Number";
41: private static final String NOT_IN_RANGE = "Number must be in range[$S-$E]";
42:
43: /**
44: *
45: */
46: public UnRangeValidator(double xStart, double xEnd) {
47: this .pem_start = xStart;
48: this .pem_end = xEnd;
49:
50: this .pem_nir = KeTools.pcmf_stringSingleSubst(NOT_IN_RANGE,
51: "$S", Double.toString(this .pem_start));
52: this .pem_nir = KeTools.pcmf_stringSingleSubst(this .pem_nir,
53: "$E", Double.toString(this .pem_end));
54:
55: return;
56: }
57:
58: public UnRangeValidator(double xStart, double xEnd, String xMessage) {
59: this .pem_start = xStart;
60: this .pem_end = xEnd;
61:
62: this .pem_nir = KeTools.pcmf_stringSingleSubst(xMessage, "$S",
63: Double.toString(this .pem_start));
64: this .pem_nir = KeTools.pcmf_stringSingleSubst(this .pem_nir,
65: "$E", Double.toString(this .pem_end));
66:
67: return;
68: }
69:
70: public UnRangeValidator() {
71: return;
72: }
73:
74: /**
75: * <p>
76: * Does...
77: * </p>
78: * <p>
79: *
80: * @return a Type with
81: * </p>
82: * <p>
83: * @param
84: * </p>
85: */
86: public String pcmf_validateMethod(Object xtoValidate) {
87: try {
88: double i = Double.parseDouble(xtoValidate.toString());
89: if (i >= this .pem_start && i <= this .pem_end)
90: return (null);
91: else
92: return (this .pem_nir);
93: } catch (Exception e) {
94: return (UnRangeValidator.NO_VALID_NUMBER);
95: }
96: }
97: }
|