org.apache.bval.jsr303
Class ConstraintValidationListener<T>

java.lang.Object
  extended by org.apache.bval.jsr303.ConstraintValidationListener<T>
All Implemented Interfaces:
ValidationListener

public final class ConstraintValidationListener<T>
extends Object
implements ValidationListener

Description: JSR-303 ValidationListener implementation; provides ConstraintViolations.

Version:
$Rev: 1166451 $ $Date: 2011-09-08 00:32:26 +0200 (Thu, 08 Sep 2011) $

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.bval.model.ValidationListener
ValidationListener.Error
 
Constructor Summary
ConstraintValidationListener(T aRootBean, Class<T> rootBeanType)
          Create a new ConstraintValidationListener instance.
 
Method Summary
<VL extends ValidationListener>
void
addError(String reason, ValidationContext<VL> context)
          Simple API to add an error reason during validation.
<VL extends ValidationListener>
void
addError(ValidationListener.Error error, ValidationContext<VL> context)
          Alternative method to add a fully initialized ValidationListener.Error object.
 boolean beginReportAsSingle()
          Signify the beginning of a report-as-single-violation composite validation.
 boolean endReportAsSingle()
          Signify the end of a report-as-single-violation composite validation.
 Set<ConstraintViolation<T>> getConstraintViolations()
          Get the ConstraintViolations accumulated by this ConstraintValidationListener.
 T getRootBean()
          Get the root bean.
 Class<T> getRootBeanType()
          Get the root bean type of this ConstraintValidationListener.
 boolean hasViolations()
          Learn whether there are violations available.
 boolean isEmpty()
          Learn whether no violations were found.
 int violationsSize()
          Get the count of encountered violations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstraintValidationListener

public ConstraintValidationListener(T aRootBean,
                                    Class<T> rootBeanType)
Create a new ConstraintValidationListener instance.

Parameters:
aRootBean -
rootBeanType -
Method Detail

addError

public <VL extends ValidationListener> void addError(String reason,
                                                     ValidationContext<VL> context)
Simple API to add an error reason during validation. Error notification added from a Validation with context information taken from the given ValidationContext.

Specified by:
addError in interface ValidationListener
Parameters:
reason - a constant describing the reason. This is normally the key of the feature that was violated in the object 'owner' for property 'propertyName'
context - - contains bean = the object that contains the error (owner) propertyName = the Name of the attribute that caused the error

addError

public <VL extends ValidationListener> void addError(ValidationListener.Error error,
                                                     ValidationContext<VL> context)
Alternative method to add a fully initialized ValidationListener.Error object.

Specified by:
addError in interface ValidationListener

getConstraintViolations

public Set<ConstraintViolation<T>> getConstraintViolations()
Get the ConstraintViolations accumulated by this ConstraintValidationListener.

Returns:
Set of ConstraintViolation

isEmpty

public boolean isEmpty()
Learn whether no violations were found.

Returns:
boolean

getRootBean

public T getRootBean()
Get the root bean.

Returns:
T

getRootBeanType

public Class<T> getRootBeanType()
Get the root bean type of this ConstraintValidationListener.

Returns:
Class

violationsSize

public int violationsSize()
Get the count of encountered violations.

Returns:
int

hasViolations

public boolean hasViolations()
Learn whether there are violations available. If in report-as-single-violation mode, the result is scoped accordingly. Note that this means you must check before exiting report-as-single-violation mode

Returns:
boolean

beginReportAsSingle

public boolean beginReportAsSingle()
Signify the beginning of a report-as-single-violation composite validation.

Returns:
true as this call caused the listener to enter report-as-single-violation mode

endReportAsSingle

public boolean endReportAsSingle()
Signify the end of a report-as-single-violation composite validation.

Returns:
true as this call caused the listener to exit report-as-single-violation mode


Copyright © 2010-2012 Apache Software Foundation. All Rights Reserved.