mikeh 01/05/15 15:21:23
Modified: src/java/org/apache/turbine/util/validation
InputValidator.java NotEmpty.java
Log:
changed the NotNull semantics to mean what you would think it would mean
Revision Changes Path
1.3 +17 -17
jakarta-turbine/src/java/org/apache/turbine/util/validation/InputValidator.java
Index: InputValidator.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/validation/InputValidator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InputValidator.java 2001/05/15 21:45:24 1.2
+++ InputValidator.java 2001/05/15 22:21:14 1.3
@@ -57,23 +57,23 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Mike Haberman</a>
- * @version $Id: InputValidator.java,v 1.2 2001/05/15 21:45:24 mikeh Exp $
+ * @version $Id: InputValidator.java,v 1.3 2001/05/15 22:21:14 mikeh Exp $
*
*
*/
public abstract class InputValidator extends Object
{
- public static final boolean AllowEmptyInput = true;// allow null
- public static final int NoMaxSize = -1; // no size restrictions
- public static final String EmptyArgv = ""; // no optional arguments
+ public static final boolean AllowNullInput = true;// allow null
+ public static final int NoMaxSize = -1; // no size restrictions
+ public static final String EmptyArgv = ""; // no optional arguments
// default error messages
- private static String EmptyInputError = "Empty Input Not Allowed";
+ private static String NullInputError = "Null Input Not Allowed";
private static String MaxSizeExceededError = "Maximum Size Exceeded";
- private boolean allowEmptyInput;
+ private boolean allowNullInput;
private int maxSize;
private String argv;
@@ -82,30 +82,30 @@
*/
public InputValidator()
{
- this(AllowEmptyInput, NoMaxSize, EmptyArgv);
+ this(AllowNullInput, NoMaxSize, EmptyArgv);
}
/**
* Constructor,
- * @param boolean allowEmptyInput
+ * @param boolean allowNullInput
* @param int maxSize
* @param String argv
*/
- public InputValidator(boolean allowEmptyInput,
+ public InputValidator(boolean allowNullInput,
int maxSize,
String argv)
{
- this.allowEmptyInput = allowEmptyInput;
+ this.allowNullInput = allowNullInput;
this.maxSize = maxSize;
this.argv = argv;
}
/**
- * @param boolean allowEmptyInput, set allowEmptyInput
+ * @param boolean allowNullInput, set allowNullInput
*/
- public void setAllowEmptyInput(boolean allowEmptyInput)
+ public void setAllowNullInput(boolean allowNullInput)
{
- this.allowEmptyInput = allowEmptyInput;
+ this.allowNullInput = allowNullInput;
}
/**
@@ -175,14 +175,14 @@
size = value.length();
}
- if (maxSize != NoMaxSize && size > maxSize)
+ if (! allowNullInput && value == null)
{
- throw new Exception(MaxSizeExceededError);
+ throw new Exception(NullInputError);
}
- if (! allowEmptyInput && (value == null || size == 0))
+ if (maxSize != NoMaxSize && size > maxSize)
{
- throw new Exception(EmptyInputError);
+ throw new Exception(MaxSizeExceededError);
}
// allow the subclass to check specifics
1.2 +3 -3
jakarta-turbine/src/java/org/apache/turbine/util/validation/NotEmpty.java
Index: NotEmpty.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/validation/NotEmpty.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NotEmpty.java 2001/05/15 21:52:58 1.1
+++ NotEmpty.java 2001/05/15 22:21:16 1.2
@@ -57,7 +57,7 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Mike Haberman</a>
- * @version $Id: NotEmpty.java,v 1.1 2001/05/15 21:52:58 mikeh Exp $
+ * @version $Id: NotEmpty.java,v 1.2 2001/05/15 22:21:16 mikeh Exp $
*
*
*/
@@ -85,7 +85,7 @@
if (size == 0)
{
- throw new Exception("No Input is not allowed");
+ throw new Exception("input is required");
}
}
@@ -94,6 +94,6 @@
*/
public String getExpectedFormat()
{
- return "anything but the empty string";
+ return "anything but the null or empty string";
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]