com.tzavellas.validation
Class ValidationResult

java.lang.Object
  extended by com.tzavellas.validation.ValidationResult

public class ValidationResult
extends Object

The result of a validation.

Author:
Spiros Tzavellas
See Also:
BeanValidator

Constructor Summary
ValidationResult()
           
 
Method Summary
 void addError(ValidationError error)
          Add a validation.
 Map<String,String> getErrorMessages(Locale locale)
          Get a map of [field, error-message] entries for this result, if this result has no errors an empty map is returned.
 Collection<ValidationError> getErrors()
          Get the collection of validation errors for this ValidationResult.
 boolean hasErrors()
          Returns true if this result contains errors.
 boolean isValid()
          Returns true if this result does not contain errors.
 void setMessageResolver(MessageResolver messageResolver)
          Set the MessageResolver to be used for the messages of this ValidationResult.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidationResult

public ValidationResult()
Method Detail

setMessageResolver

public void setMessageResolver(MessageResolver messageResolver)
Set the MessageResolver to be used for the messages of this ValidationResult.

The default MessageResolver always returns the default message of the validation error, ignoring the error's code and the specified locale.

See Also:
MessageResolver, ValidationError

addError

public void addError(ValidationError error)
Add a validation.

Parameters:
error - the error to add

getErrors

public Collection<ValidationError> getErrors()
Get the collection of validation errors for this ValidationResult.

Returns:
the collection of errors, or an empty collection if there are no errors (the object under validation is valid).

getErrorMessages

public Map<String,String> getErrorMessages(Locale locale)
Get a map of [field, error-message] entries for this result, if this result has no errors an empty map is returned.

Parameters:
locale - the locale to use for resolving the messages. May be null, see MessageResolver for more info.

isValid

public boolean isValid()
Returns true if this result does not contain errors.


hasErrors

public boolean hasErrors()
Returns true if this result contains errors.



Copyright © 2007-2009 spiros.blog(). All Rights Reserved.