com.x1seven.hydrogen.validation
Class ValidationException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by com.x1seven.hydrogen.validation.ValidationException
All Implemented Interfaces:
java.io.Serializable

public class ValidationException
extends java.lang.Exception

Indicates that one or more rules failed during validation. For the actual failure messages, retrieve the Messages object using the getMessages() method.

Note that the ValidationException should never have a root cause. It is thrown in response to a breach of some validation rule.

Since:
1.0.0
Version:
1.3
Author:
Brendon Matheson
See Also:
Serialized Form

Constructor Summary
ValidationException()
           Constructs a new empty ValidationException.
ValidationException(Messages messages)
           Constructs a new ValidationException containing the supplied Messages collection.
 
Method Summary
 int count()
           Convenience method to return the number of messages in this ValidationException.
 java.util.Iterator get()
           Convenience method to get the iterator for the full collection of Messages held by this ValidationException.
 java.util.Iterator get(java.lang.String property)
           Convenience method to get an iterator for the Message objects that have been registered against the specified property.
 Messages getMessages()
           Retrieves the Messages collection that contains the actual messages for this ValidationException.
 boolean hasMessages()
           Convenience method to find out if the Messages collection held by this ValidationException contains objects.
 boolean isEmpty()
           Convenience method to find out if the Messages collection held by this ValidationException is empty.
 void setMessages(Messages messages)
           Sets the Messages collection for this ValidationException.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ValidationException

public ValidationException()

Constructs a new empty ValidationException.


ValidationException

public ValidationException(Messages messages)

Constructs a new ValidationException containing the supplied Messages collection.

Parameters:
messages - the Messages collection to use for this ValidationException
Method Detail

getMessages

public Messages getMessages()

Retrieves the Messages collection that contains the actual messages for this ValidationException.

Returns:
the Messages collection held by this ValidationException

setMessages

public void setMessages(Messages messages)

Sets the Messages collection for this ValidationException.

Parameters:
messages - Messages collection containing validation messages for this ValidationException

get

public java.util.Iterator get()

Convenience method to get the iterator for the full collection of Messages held by this ValidationException.

Returns:
an Iterator for the Message objects within the Messages collection held by this ValidationException

get

public java.util.Iterator get(java.lang.String property)

Convenience method to get an iterator for the Message objects that have been registered against the specified property.

Parameters:
property - the property for which Messages should
Returns:
an Iterator for the Message objects that have been registered for the specified property

count

public int count()

Convenience method to return the number of messages in this ValidationException.

Returns:
the number of Message objects in the Messages object held by this ValidationException

hasMessages

public boolean hasMessages()

Convenience method to find out if the Messages collection held by this ValidationException contains objects.

Returns:
true if the Messages collection held by this ValidationException contains Message objects and false otherwise

isEmpty

public boolean isEmpty()

Convenience method to find out if the Messages collection held by this ValidationException is empty.

Returns:
true if the Messages collection held by this ValidationException is empty and false otherwise