org.apache.bval
Class ValidationResults

java.lang.Object
  extended by org.apache.bval.ValidationResults
All Implemented Interfaces:
Serializable, ValidationListener

public class ValidationResults
extends Object
implements ValidationListener, Serializable

Description: Implements a contains to hold and transport validation results

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.bval.model.ValidationListener
ValidationListener.Error
 
Constructor Summary
ValidationResults()
           
 
Method Summary
 void addError(String reason, Object bean, String propertyName)
          Old API to add an error to the validation results when no context is available.
<T extends ValidationListener>
void
addError(String reason, ValidationContext<T> context)
          API to add an error to the validation results.
<T extends ValidationListener>
void
addError(ValidationListener.Error error, ValidationContext<T> context)
          API to add an error to the validation results.
protected  void addToOwnerBucket(ValidationListener.Error error)
          Add an Error to the property-keyed map of Errors maintained for this Error's owner.
protected  void addToReasonBucket(ValidationListener.Error error)
          Add an Error to the set of Errors shared by a particular "reason."
protected  ValidationListener.Error createError(String reason, Object owner, String propertyName)
          Create an Error object.
 Map<Object,Map<String,List<ValidationListener.Error>>> getErrorsByOwner()
          Get the map of Errors by owner; key = owner, value = map with:
   key = propertyName, value = list of errors for this owner.propertyName
 Map<String,List<ValidationListener.Error>> getErrorsByReason()
          Get the map of Errors by reason; key = reason, value = list of errors for this reason
 boolean hasError(Object bean, String propertyName)
          Learn whether bean has any errors keyed to property propertyName.
 boolean hasErrorForReason(String reason)
          Learn whether there is an Error keyed to a specified reason description.
protected  void initialize()
          initialize the error-buckets now when needed and not on instance creation to save memory garbage.
 boolean isEmpty()
          Learn whether these results are empty/error-free.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ValidationResults

public ValidationResults()
Method Detail

addError

public <T extends ValidationListener> void addError(String reason,
                                                    ValidationContext<T> context)
API to add an error to the validation results.

Specified by:
addError in interface ValidationListener
Parameters:
reason - - Features from Features.Property or custom reason of validation error
context - - context information (bean, propertyName, value, ...)

addError

public <T extends ValidationListener> void addError(ValidationListener.Error error,
                                                    ValidationContext<T> context)
API to add an error to the validation results.

Specified by:
addError in interface ValidationListener
Parameters:
error - - holding the description of reason and object to describe the validation error
context - - null or the context to provide additional information

addError

public void addError(String reason,
                     Object bean,
                     String propertyName)
Old API to add an error to the validation results when no context is available.

Parameters:
reason - - Features from Features.Property or custom validation reason
bean - - (optional) owner bean or null
propertyName - - (optional) propertyName where valiation error occurred or null

createError

protected ValidationListener.Error createError(String reason,
                                               Object owner,
                                               String propertyName)
Create an Error object.

Parameters:
reason -
owner -
propertyName -
Returns:
new Error

initialize

protected void initialize()
initialize the error-buckets now when needed and not on instance creation to save memory garbage.


addToReasonBucket

protected void addToReasonBucket(ValidationListener.Error error)
Add an Error to the set of Errors shared by a particular "reason."

Parameters:
error -
See Also:
Error#getReason()}

addToOwnerBucket

protected void addToOwnerBucket(ValidationListener.Error error)
Add an Error to the property-keyed map of Errors maintained for this Error's owner.

Parameters:
error -
See Also:
Error#getOwner()}

getErrorsByReason

public Map<String,List<ValidationListener.Error>> getErrorsByReason()
Get the map of Errors by reason; key = reason, value = list of errors for this reason

Returns:
map

getErrorsByOwner

public Map<Object,Map<String,List<ValidationListener.Error>>> getErrorsByOwner()
Get the map of Errors by owner; key = owner, value = map with:
   key = propertyName, value = list of errors for this owner.propertyName

Returns:
map

isEmpty

public boolean isEmpty()
Learn whether these results are empty/error-free.

Returns:
true when there are NO errors in this validation result

hasErrorForReason

public boolean hasErrorForReason(String reason)
Learn whether there is an Error keyed to a specified reason description.

Parameters:
reason -
Returns:
boolean
See Also:
Error#getReason()}

hasError

public boolean hasError(Object bean,
                        String propertyName)
Learn whether bean has any errors keyed to property propertyName.

Parameters:
bean -
propertyName - - may be null: any property is checked OR the name of the property to check
Returns:
boolean

toString

public String toString()

Overrides:
toString in class Object


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