com.finalist.util.ejb.validation
Class ModelErrors

java.lang.Object
  extended bycom.finalist.util.ejb.validation.ModelErrors
All Implemented Interfaces:
java.io.Serializable

public class ModelErrors
extends java.lang.Object
implements java.io.Serializable

A class that encapsulates the error messages being reported by the validate() method of an ActionForm. Validation errors are either global to the entire ActionForm bean they are associated with, or they are specific to a particular bean property (and, therefore, a particular input field on the corresponding form).

Each individual error is described by an ModelError object, which contains a message key (to be looked up in an appropriate message resources database), and up to four placeholder arguments used for parametric substitution in the resulting message.

IMPLEMENTATION NOTE - It is assumed that these objects are created and manipulated only within the context of a single thread. Therefore, no synchronization is required for access to internal collections.

Version:
$Revision: 1.1 $ $Date: 2004/03/01 19:29:19 $
Author:
David Geary (copied), Craig R. McClanahan (copied)
See Also:
Serialized Form

Field Summary
protected  java.util.HashMap errors
          The accumulated set of ModelError objects (represented as an ArrayList) for each property, keyed by property name.
static java.lang.String GLOBAL_ERROR
          "Property" name to store global error under...
 
Constructor Summary
ModelErrors()
           
 
Method Summary
 void add(java.lang.String property, ModelError error)
          Add an error message to the set of errors for the specified property.
 void addGenericError(ModelError error)
          Add an error message to the set of errors for the specified property.
 void clear()
          Clear all error messages recorded by this object.
 boolean empty()
          Return true if there are no error messages recorded in this collection, or false otherwise.
 java.util.Iterator get()
          Return the set of all recorded error messages, without distinction by which property the messages are associated with.
 java.util.Iterator get(java.lang.String property)
          Return the set of error messages related to a specific property.
 java.util.Iterator properties()
          Return the set of property names for which at least one error has been recorded.
 int size()
          Return the number of errors recorded for all properties (including global errors).
 int size(java.lang.String property)
          Return the number of errors associated with the specified property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GLOBAL_ERROR

public static final java.lang.String GLOBAL_ERROR
"Property" name to store global error under...

See Also:
Constant Field Values

errors

protected java.util.HashMap errors
The accumulated set of ModelError objects (represented as an ArrayList) for each property, keyed by property name.

Constructor Detail

ModelErrors

public ModelErrors()
Method Detail

add

public void add(java.lang.String property,
                ModelError error)
Add an error message to the set of errors for the specified property.

Parameters:
property - Property name (or 4.GLOBAL_ERROR)
error - The error message to be added

addGenericError

public void addGenericError(ModelError error)
Add an error message to the set of errors for the specified property.

Parameters:
error - The error message to be added

clear

public void clear()
Clear all error messages recorded by this object.


empty

public boolean empty()
Return true if there are no error messages recorded in this collection, or false otherwise.


get

public java.util.Iterator get()
Return the set of all recorded error messages, without distinction by which property the messages are associated with. If there are no error messages recorded, an empty enumeration is returned.


get

public java.util.Iterator get(java.lang.String property)
Return the set of error messages related to a specific property. If there are no such errors, an empty enumeration is returned.

Parameters:
property - Property name (or ModelErrors.GLOBAL_ERROR)

properties

public java.util.Iterator properties()
Return the set of property names for which at least one error has been recorded. If there are no errors, an empty Iterator is returned. If you have recorded global errors, the String value of ModelErrors.GLOBAL_ERROR will be one of the returned property names.


size

public int size()
Return the number of errors recorded for all properties (including global errors). NOTE - it is more efficient to call empty() if all you care about is whether or not there are any error messages at all.


size

public int size(java.lang.String property)
Return the number of errors associated with the specified property.

Parameters:
property - Property name (or ModelErrors.GLOBAL_ERROR)


Copyright © 2003-2004 SourceForge. All Rights Reserved.