FileDocCategorySizeDatePackage
AndConstraint.javaAPI DocGlassfish v2 API5848Fri May 04 22:34:58 BST 2007com.sun.enterprise.tools.common.validation.constraints

AndConstraint

public class AndConstraint extends ConstraintUtils implements Constraint
AndConstraint is a logical And {@link Constraint}. It validates the given value by performing logical And of validations of the value against its constituent leftConstraint and rightConstraint.

It implements Constraint interface and extends {@link ConstraintUtils} class. match method of this object returns empty collection if the value being validated satisfies both the leftConstraint and the rightConstraint; else it returns a Collection with {@link ConstraintFailure} objects in it for the failed Constraints. ConstraintUtils class provides utility methods for formating failure messages and a print method to print this object.

author
Rajeshwar Patil
version
%I%, %G%

Fields Summary
private Constraint
leftConstraint
The left Constraint of this AndCosntraint This AndConstraint is logical AND of its left Constraint and right Constraint.
private Constraint
rightConstraint
The right Constraint of this AndCosntraint This AndConstraint is logical AND of its left Constraint and right Constraint.
Constructors Summary
public AndConstraint()
Creates a new instance of AndConstraint



           
      
        Constraint leftConstraint = null;
        Constraint rightConstraint = null;
    
public AndConstraint(Constraint leftConstraint, Constraint rightConstraint)
Creates a new instance of AndConstraint

        this.leftConstraint = leftConstraint;
        this.rightConstraint = rightConstraint;
    
Methods Summary
public java.util.Collectionmatch(java.lang.String value, java.lang.String name)
Validates the given value against this Constraint.

param
value the value to be validated
param
name the element name, value of which is being validated. It is used only in case of Constraint failure, to construct the failure message.
return
Collection the Collection of ConstraintFailure Objects. Collection is empty if there are no failures.

        Collection failed_constrained_list = new ArrayList();
        failed_constrained_list.addAll(leftConstraint.match(value, name));
        failed_constrained_list.addAll(rightConstraint.match(value, name));
        return failed_constrained_list;
    
public voidprint()
Prints this Constraint.

        super.print();
        ((ConstraintUtils)leftConstraint).print();
        ((ConstraintUtils)rightConstraint).print();
    
public voidsetLeftConstraint(Constraint constraint)
Sets the given Constraint as the leftConstraint of this object.

param
constraint the Constraint to be set as leftConstraint of this object

        leftConstraint = constraint;
    
public voidsetRightConstraint(Constraint constraint)
Sets the given Constraint as the rightConstraint of this object.

param
constraint the Constraint to be set as rightConstraint of this object

        rightConstraint = constraint;