nl.openedge.baritus.validation.impl
Class RegexValidator

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

public class RegexValidator
extends AbstractFieldValidator

Tests for a match against a regex pattern. if property 'mode' is MODE_VALID_IF_MATCHES (which is the default), isValid returns true if the input matches the pattern. If property mode is MODE_INVALID_IF_MATCHES (i.e. else), isValid returns false if the input matches the pattern.

Author:
Eelco Hillenius

Field Summary
static int MODE_INVALID_IF_MATCHES
          when in this mode, isValid will return false if the input matches the pattern
static int MODE_VALID_IF_MATCHES
          when in this mode, isValid will return true if the input matches the pattern
 
Constructor Summary
RegexValidator()
          construct without parameters
RegexValidator(java.util.regex.Pattern pattern)
          construct with pattern
RegexValidator(java.util.regex.Pattern pattern, int mode)
          construct with pattern and mode
RegexValidator(java.lang.String errorMessageKey, java.util.regex.Pattern pattern)
          construct with errorMessageKey and pattern
RegexValidator(java.lang.String errorMessageKey, java.util.regex.Pattern pattern, int mode)
          construct with message prefix, pattern and mode
RegexValidator(java.lang.String errorMessageKey, ValidationActivationRule rule, java.util.regex.Pattern pattern)
          construct with errorMessageKey, rule and pattern
RegexValidator(java.lang.String errorMessageKey, ValidationActivationRule rule, java.util.regex.Pattern pattern, int mode)
          construct with errorMessageKey, rule, pattern and mode
 
Method Summary
 java.lang.String getErrorMessageKey()
          Get key of error message.
 int getMode()
          get mode
 java.util.regex.Pattern getPattern()
          get pattern
 boolean isValid(org.infohazard.maverick.flow.ControllerContext cctx, FormBeanContext formBeanContext, java.lang.String fieldName, java.lang.Object value)
          Checks if value is valid.
 void setErrorMessageKey(java.lang.String string)
          Set key of error message.
 void setMode(int i)
          set mode
 void setPattern(java.util.regex.Pattern pattern)
          set pattern
 
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

MODE_VALID_IF_MATCHES

public static final int MODE_VALID_IF_MATCHES
when in this mode, isValid will return true if the input matches the pattern

See Also:
Constant Field Values

MODE_INVALID_IF_MATCHES

public static final int MODE_INVALID_IF_MATCHES
when in this mode, isValid will return false if the input matches the pattern

See Also:
Constant Field Values
Constructor Detail

RegexValidator

public RegexValidator()
construct without parameters


RegexValidator

public RegexValidator(java.util.regex.Pattern pattern)
construct with pattern

Parameters:
pattern -

RegexValidator

public RegexValidator(java.lang.String errorMessageKey,
                      java.util.regex.Pattern pattern)
construct with errorMessageKey and pattern

Parameters:
errorMessageKey -
pattern -

RegexValidator

public RegexValidator(java.lang.String errorMessageKey,
                      ValidationActivationRule rule,
                      java.util.regex.Pattern pattern)
construct with errorMessageKey, rule and pattern

Parameters:
errorMessageKey -
rule -
pattern -

RegexValidator

public RegexValidator(java.util.regex.Pattern pattern,
                      int mode)
construct with pattern and mode

Parameters:
pattern -
mode -

RegexValidator

public RegexValidator(java.lang.String errorMessageKey,
                      java.util.regex.Pattern pattern,
                      int mode)
construct with message prefix, pattern and mode

Parameters:
errorMessageKey -
pattern -
mode -

RegexValidator

public RegexValidator(java.lang.String errorMessageKey,
                      ValidationActivationRule rule,
                      java.util.regex.Pattern pattern,
                      int mode)
construct with errorMessageKey, rule, pattern and mode

Parameters:
errorMessageKey -
rule -
pattern -
mode -
Method Detail

isValid

public boolean isValid(org.infohazard.maverick.flow.ControllerContext cctx,
                       FormBeanContext formBeanContext,
                       java.lang.String fieldName,
                       java.lang.Object value)
Description copied from interface: FieldValidator
Checks if value is valid. This method should return true if validation succeeded or false otherwise. For error handling you have two options:

Parameters:
cctx - maverick context
formBeanContext - context with bean for this currentRequest
fieldName - field name of parameter
value - the value of this parameter
Returns:
true if valid, false if not.
See Also:
FieldValidator.isValid(org.infohazard.maverick.flow.ControllerContext, nl.openedge.baritus.FormBeanContext, java.lang.String, java.lang.Object)

getMode

public int getMode()
get mode

Returns:
int

getPattern

public java.util.regex.Pattern getPattern()
get pattern

Returns:
Pattern

setMode

public void setMode(int i)
set mode

Parameters:
i - mode

setPattern

public void setPattern(java.util.regex.Pattern pattern)
set pattern

Parameters:
pattern - regex pattern

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.