ehsbe CommonsTM
Version 1.1.0rc3

com.ehsbe.commons.util
Class MultiValidator<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<Validator<E>>
              extended by com.ehsbe.commons.util.MultiValidator<E>
Type Parameters:
E - type of input to validate
All Implemented Interfaces:
Validator<E>, Serializable, Cloneable, Iterable<Validator<E>>, Collection<Validator<E>>, List<Validator<E>>, RandomAccess

public class MultiValidator<E>
extends ArrayList<Validator<E>>
implements Validator<E>

A Validator, which consist of several other validators of the same kind to verify a certain input.

The order of the validators is important, since shortcut outcome combination is always done on accept.

Version:
$Revision: 432 $
Author:
Jens Elkner
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
MultiValidator()
          Create a new Validator AND validator.
MultiValidator(boolean and)
          Create a new Validator.
 
Method Summary
 boolean accept(E input)
          Check, whether the given input is valid and would be accepted.
 void setValidationType(boolean and)
          Set the method for the combination of all validator outcomes.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

MultiValidator

public MultiValidator()
Create a new Validator AND validator.


MultiValidator

public MultiValidator(boolean and)
Create a new Validator.

Parameters:
and - If true combine the outcome of the validators with AND. Otherwise combine it with OR.
Method Detail

accept

public boolean accept(E input)
Check, whether the given input is valid and would be accepted.

Specified by:
accept in interface Validator<E>
Parameters:
input - the value to check. Might be null.
Returns:
true if the input should is accepted.

setValidationType

public void setValidationType(boolean and)
Set the method for the combination of all validator outcomes.

Parameters:
and - if true, combine the outcome of the validators with AND, otherwise combine them with OR.

ehsbe CommonsTM
Version 1.1.0rc3

Copyright ©2005-2009 EHSBE, Walther-Rathenau-Str. 58, 39104 Magdeburg, Sachsen-Anhalt, Germany. All Rights Reserved.