KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > util > validators > ValidatorFactory


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cms.util.validators;
25
26 /**
27  * <todo>Should only return a Validator interface</todo>
28  * <todo>
29  * Time is running out, the illusion fades away...
30  * This package will be refactored/extended after iteration 1.
31  * - move to com.holigrow.yoda.util.validators ?
32  * - interfaces + factory
33  * - constructor madness (setXXX instead of N constructors?)
34  * - more validators
35  * - more fun
36  * </todo>
37  *
38  * @@author <a HREF="meat_for_the_butcher@@yahoo.com">Patrik Nyborg</a>
39  */

40 public class ValidatorFactory {
41   // --- [Constants] -----------------------------------------------------------
42
// --- [Attributes] ----------------------------------------------------------
43
// --- [Static] --------------------------------------------------------------
44
// --- [Constructors] --------------------------------------------------------
45

46   /**
47    *
48    */

49   private ValidatorFactory() {}
50
51
52
53   // --- [Public] --------------------------------------------------------------
54

55   /**
56    *
57    */

58   public static final StringValidator createStringValidator(String JavaDoc fieldName, boolean isRequired, int upperLengthLimit) {
59     return new StringValidator(fieldName, isRequired, upperLengthLimit);
60   }
61
62   /**
63    *
64    */

65   public static final StringValidator createStringValidator(String JavaDoc fieldName, boolean isRequired, int lowerLengthLimit, int upperLengthLimit) {
66     return new StringValidator(fieldName, isRequired, lowerLengthLimit, upperLengthLimit);
67   }
68
69   public static final StringValidator createStringValidator(String JavaDoc fieldName,boolean isRequired, int lowerLengthLimit, int upperLengthLimit,boolean mustBeUnique,Class JavaDoc objectClass, Integer JavaDoc excludeId, Object JavaDoc excludedObject) {
70     return new StringValidator(fieldName, isRequired, lowerLengthLimit, upperLengthLimit, mustBeUnique, objectClass, excludeId, excludedObject);
71   }
72
73   public static final StringValidator createStringValidator(String JavaDoc fieldName,boolean isRequired,boolean mustBeUnique,Class JavaDoc objectClass, Integer JavaDoc excludeId, Object JavaDoc excludedObject) {
74     return new StringValidator(fieldName, isRequired, mustBeUnique, objectClass, excludeId, excludedObject);
75   }
76
77
78   /**
79    *
80    */

81   public static final EmailValidator createEmailValidator(String JavaDoc fieldName, boolean isRequired, int upperLengthLimit) {
82     return new EmailValidator(fieldName, isRequired, upperLengthLimit);
83   }
84
85   /**
86    *
87    */

88   public static final IntegerValidator createNonNegativeIntegerValidator(String JavaDoc fieldName, boolean isRequired) {
89     return new IntegerValidator(fieldName, isRequired, 0, Integer.MAX_VALUE);
90   }
91
92   /**
93    *
94    */

95   public static final FloatValidator createNonNegativeFloatValidator(String JavaDoc fieldName, boolean isRequired) {
96     return new FloatValidator(fieldName, isRequired, new Float JavaDoc(0.0).floatValue(), Float.MAX_VALUE);
97   }
98
99
100
101   // --- [X implementation] ----------------------------------------------------
102
// --- [X Overrides] ---------------------------------------------------------
103
// --- [Package protected] ---------------------------------------------------
104
// --- [Private] -------------------------------------------------------------
105
// --- [Protected] -----------------------------------------------------------
106
// --- [Inner classes] -------------------------------------------------------
107
}
Popular Tags