nl.openedge.baritus.validation.impl
Class MaximumFieldLengthValidator

java.lang.Object
  extended bynl.openedge.baritus.validation.AbstractValidator
      extended bynl.openedge.baritus.validation.AbstractFieldValidator
          extended bynl.openedge.baritus.validation.impl.MaximumFieldLengthValidator
All Implemented Interfaces:
FieldValidator, ValidationRuleDependend

public final class MaximumFieldLengthValidator
extends AbstractFieldValidator

This validator checks on maximum length. If the type of the value is a String, the string length is checked. If the type of the value is a Number, the actual number is used. E.g. if property maxLength is 4, "hello" will fail, but "hi" will pass, and number 5 will fail, but 2 will pass.

Author:
Eelco Hillenius

Field Summary
static int NO_MAXIMUM
          special value that indicates there's no maximum value to check on
 
Constructor Summary
MaximumFieldLengthValidator()
          construct with 'invalid.field.input.size' as message prefix.
MaximumFieldLengthValidator(int maxLength)
          Construct with maxLength.
MaximumFieldLengthValidator(java.lang.String errorMessageKey)
          Construct with errorMessageKey for error message keys.
MaximumFieldLengthValidator(java.lang.String errorMessageKey, int maxLength)
          Construct with message prefix for error message keys and set checking on maximum length with given length of fields only.
MaximumFieldLengthValidator(java.lang.String errorMessageKey, ValidationActivationRule rule)
          Construct with errorMessageKey and activation rule.
MaximumFieldLengthValidator(ValidationActivationRule rule)
          Construct with activation rule.
 
Method Summary
 java.lang.String getErrorMessageKey()
          Get key of error message.
 int getMaxLength()
          Get maximum length that is checked on.
 boolean isValid(org.infohazard.maverick.flow.ControllerContext cctx, FormBeanContext formBeanContext, java.lang.String fieldName, java.lang.Object value)
          Checks whether the provided value is less than the maximum.
 void setErrorMessageKey(java.lang.String string)
          Set key of error message.
 void setMaxLength(int i)
          Set maximum length that is checked on .
 
Methods inherited from class nl.openedge.baritus.validation.AbstractFieldValidator
getOverrideValue
 
Methods inherited from class nl.openedge.baritus.validation.AbstractValidator
getFieldName, getLocalizedMessage, getLocalizedMessage, getLocalizedMessage, getLocalizedMessage, getValidationActivationRule, removeValidationActivationRule, setErrorMessage, setValidationRule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nl.openedge.baritus.validation.ValidationRuleDependend
getValidationActivationRule, removeValidationActivationRule, setValidationRule
 

Field Detail

NO_MAXIMUM

public static final int NO_MAXIMUM
special value that indicates there's no maximum value to check on

See Also:
Constant Field Values
Constructor Detail

MaximumFieldLengthValidator

public MaximumFieldLengthValidator()
construct with 'invalid.field.input.size' as message prefix.


MaximumFieldLengthValidator

public MaximumFieldLengthValidator(java.lang.String errorMessageKey)
Construct with errorMessageKey for error message keys.

Parameters:
errorMessageKey -

MaximumFieldLengthValidator

public MaximumFieldLengthValidator(java.lang.String errorMessageKey,
                                   int maxLength)
Construct with message prefix for error message keys and set checking on maximum length with given length of fields only.

Parameters:
errorMessageKey - message key
maxLength - maximum length allowed for values; use -1 for no maximum

MaximumFieldLengthValidator

public MaximumFieldLengthValidator(ValidationActivationRule rule)
Construct with activation rule.

Parameters:
rule - activation rule

MaximumFieldLengthValidator

public MaximumFieldLengthValidator(java.lang.String errorMessageKey,
                                   ValidationActivationRule rule)
Construct with errorMessageKey and activation rule.

Parameters:
errorMessageKey - error message key
rule - activation rule

MaximumFieldLengthValidator

public MaximumFieldLengthValidator(int maxLength)
Construct with maxLength.

Parameters:
maxLength - maximum length allowed for values; use -1 for no maximum
Method Detail

isValid

public boolean isValid(org.infohazard.maverick.flow.ControllerContext cctx,
                       FormBeanContext formBeanContext,
                       java.lang.String fieldName,
                       java.lang.Object value)
Checks whether the provided value is less than the maximum. In case the value is an instance of string: checks whether the length of the string is equal to or smaller than the maximumLength property. In case the value is an instance of number: checks whether the length of the integer value is equal to or smaller than the maximumLength property.

Parameters:
cctx - maverick context
formBeanContext - context with bean for this currentRequest
fieldName - field name of parameter
value - the value of this parameter
Returns:
boolean true if the length of value is equal to or less than the maxLength property, false otherwise
See Also:
FieldValidator.isValid(org.infohazard.maverick.flow.ControllerContext, nl.openedge.baritus.FormBeanContext, java.lang.String, java.lang.Object)

getMaxLength

public int getMaxLength()
Get maximum length that is checked on.

Returns:
int maximum length that is checked on

setMaxLength

public void setMaxLength(int i)
Set maximum length that is checked on .

Parameters:
i - maximum length that is checked on

getErrorMessageKey

public java.lang.String getErrorMessageKey()
Get key of error message.

Returns:
String key of error message

setErrorMessageKey

public void setErrorMessageKey(java.lang.String string)
Set key of error message.

Parameters:
string - key of error message


Copyright © 2003-2004 Open Edge. All Rights Reserved.