org.millstone.base.data.validator
Class StringLengthValidator

java.lang.Object
  |
  +--org.millstone.base.data.validator.StringLengthValidator
All Implemented Interfaces:
Validator

public class StringLengthValidator
extends java.lang.Object
implements Validator

This validator is used to validate the lenght of strings.

Since:
3.0
Version:
3.0.3
Author:
IT Mill Ltd.

Nested Class Summary
 
Nested classes inherited from class org.millstone.base.data.Validator
Validator.InvalidValueException, Validator.Suggestive
 
Constructor Summary
StringLengthValidator(java.lang.String errorMessage)
          Create a new StringLengthValidator with a given error message.
StringLengthValidator(java.lang.String errorMessage, int minLength, int maxLength, boolean allowNull)
          Create a new StringLenghtValidator with a given error message, permissable lenghts and null-string allowance.
 
Method Summary
 java.lang.String getErrorMessage()
          Gets the message to be displayed in case the value does not validate.
 int getMaxLength()
          Get the maximum permissable length of the string.
 int getMinLength()
          Get the minimum permissable lenght of the string.
 boolean isNullAllowed()
          True if null strings are allowed.
 boolean isValid(java.lang.Object value)
          True if the value is valid.
 void setErrorMessage(java.lang.String errorMessage)
          Sets the message to be displayer in case the value does not validate.
 void setMaxLength(int maxLength)
          Set the maximum permissable length of the string.
 void setMinLength(int minLength)
          Sets the minimum permissable lenght.
 void setNullAllowed(boolean allowNull)
          Sets wheter null-strings are to be allowed.
 void validate(java.lang.Object value)
          Validate the value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringLengthValidator

public StringLengthValidator(java.lang.String errorMessage)
Create a new StringLengthValidator with a given error message.

Parameters:
errorMessage - - The message to display in case the value does not validate.

StringLengthValidator

public StringLengthValidator(java.lang.String errorMessage,
                             int minLength,
                             int maxLength,
                             boolean allowNull)
Create a new StringLenghtValidator with a given error message, permissable lenghts and null-string allowance.

Parameters:
errorMessage - - The message to display in case the value does not validate.
allowNull - - Are null strings permissable?
Method Detail

validate

public void validate(java.lang.Object value)
              throws Validator.InvalidValueException
Validate the value.

Specified by:
validate in interface Validator
Parameters:
value - - The value to validate.
Throws:
Validator.InvalidValueException - if the value is not valid

isValid

public boolean isValid(java.lang.Object value)
True if the value is valid.

Specified by:
isValid in interface Validator
Parameters:
value - - The value to validate.

isNullAllowed

public final boolean isNullAllowed()
True if null strings are allowed.


getMaxLength

public final int getMaxLength()
Get the maximum permissable length of the string.


getMinLength

public final int getMinLength()
Get the minimum permissable lenght of the string.


setNullAllowed

public void setNullAllowed(boolean allowNull)
Sets wheter null-strings are to be allowed.


setMaxLength

public void setMaxLength(int maxLength)
Set the maximum permissable length of the string.


setMinLength

public void setMinLength(int minLength)
Sets the minimum permissable lenght.


getErrorMessage

public java.lang.String getErrorMessage()
Gets the message to be displayed in case the value does not validate.


setErrorMessage

public void setErrorMessage(java.lang.String errorMessage)
Sets the message to be displayer in case the value does not validate.



Copyright © 2000,2001,2002 IT Mill Ltd. All Rights Reserved.