org.barracudamvc.core.forms
Class And

java.lang.Object
  extended by org.barracudamvc.core.forms.AbstractFormValidator
      extended by org.barracudamvc.core.forms.And
All Implemented Interfaces:
FormValidator

public class And
extends AbstractFormValidator

This validator ensures that all of the given validators are valid, (effectively acting as an "AND" or "&&") or a ValidationException will be generated.

The sub-validators can be specified as array, list or by using the convenience constructors.


Field Summary
protected  FormValidator[] _fv
           
 
Fields inherited from class org.barracudamvc.core.forms.AbstractFormValidator
localLogger
 
Constructor Summary
And(FormValidator[] fv)
          Public constructor.
And(FormValidator[] fv, String ierrmsg)
          Public constructor.
And(FormValidator fv1, FormValidator fv2)
          Public constructor.
And(FormValidator fv1, FormValidator fv2, FormValidator fv3)
          Public constructor.
And(FormValidator fv1, FormValidator fv2, FormValidator fv3, FormValidator fv4)
          Public constructor.
And(FormValidator fv1, FormValidator fv2, FormValidator fv3, FormValidator fv4, String ierrmsg)
          Public constructor.
And(FormValidator fv1, FormValidator fv2, FormValidator fv3, String ierrmsg)
          Public constructor.
And(FormValidator fv1, FormValidator fv2, String ierrmsg)
          Public constructor.
And(List fv)
          Public constructor.
And(List fv, String ierrmsg)
          Public constructor.
 
Method Summary
 FormValidator[] getSubValidators()
          Return the sub-validators that are or'ed together Do not assume this array is of length 2, in order to allow for future use.
 void validate(FormElement element, FormMap map, boolean deferExceptions)
          Rather than calling all the sub validate methods, we make sure at least one of the sub-validators is valid
 
Methods inherited from class org.barracudamvc.core.forms.AbstractFormValidator
generateException, getErrorMessage, isNull, setErrorMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_fv

protected FormValidator[] _fv
Constructor Detail

And

public And(List fv)
Public constructor.

Parameters:
fv - the list of validators

And

public And(List fv,
           String ierrmsg)
Public constructor.

Parameters:
fv - the list of validators
ierrmsg - the message associated with this error

And

public And(FormValidator[] fv)
Public constructor.

Parameters:
fv - the array of validators

And

public And(FormValidator[] fv,
           String ierrmsg)
Public constructor.

Parameters:
fv - the array of validators
ierrmsg - the message associated with this error

And

public And(FormValidator fv1,
           FormValidator fv2)
Public constructor.

Parameters:
fv1 - the first subvalidator
fv2 - the second subvalidator

And

public And(FormValidator fv1,
           FormValidator fv2,
           String ierrmsg)
Public constructor.

Parameters:
fv1 - the first subvalidator
fv2 - the second subvalidator
ierrmsg - the message associated with this error

And

public And(FormValidator fv1,
           FormValidator fv2,
           FormValidator fv3)
Public constructor.

Parameters:
fv1 - the first subvalidator
fv2 - the second subvalidator
fv3 - the third subvalidator

And

public And(FormValidator fv1,
           FormValidator fv2,
           FormValidator fv3,
           String ierrmsg)
Public constructor.

Parameters:
fv1 - the first subvalidator
fv2 - the second subvalidator
fv3 - the third subvalidator
ierrmsg - the message associated with this error

And

public And(FormValidator fv1,
           FormValidator fv2,
           FormValidator fv3,
           FormValidator fv4)
Public constructor.

Parameters:
fv1 - the first subvalidator
fv2 - the second subvalidator
fv3 - the third subvalidator
fv4 - the fourth subvalidator

And

public And(FormValidator fv1,
           FormValidator fv2,
           FormValidator fv3,
           FormValidator fv4,
           String ierrmsg)
Public constructor.

Parameters:
fv1 - the first subvalidator
fv2 - the second subvalidator
fv3 - the third subvalidator
fv4 - the fourth subvalidator
ierrmsg - the message associated with this error
Method Detail

getSubValidators

public FormValidator[] getSubValidators()
Return the sub-validators that are or'ed together Do not assume this array is of length 2, in order to allow for future use. Also, do not change the returned array, as it maybe cached in the future.

Returns:
Sub-validators as an array

validate

public void validate(FormElement element,
                     FormMap map,
                     boolean deferExceptions)
              throws ValidationException
Rather than calling all the sub validate methods, we make sure at least one of the sub-validators is valid

Parameters:
element - the form element to be validated (null indicates we want to perform form level validation)
map - the map to which the element belongs (sometimes necessary to validate elements by comparing them with other elements)
deferExceptions - do we want to deferValidation exceptions and attempt to validate all elements so that we can process all the exceptions at once
Throws:
ValidationException - if the element is not valid


Copyright © 2006 BarracudaMVC.org All Rights Reserved.