toolbox.web.validation
Class FieldValidator

Package class diagram package FieldValidator
java.lang.Object
  extended by toolbox.web.validation.FieldValidator
All Implemented Interfaces:
Validator

public class FieldValidator
extends java.lang.Object
implements Validator

Validator implementation that makes use of Field implementations to perform validations.

This implementation obtains the validation configuration from an XML configuration document.


Constructor Summary
FieldValidator()
          Default constructor
 
Method Summary
 java.util.List getFields(java.lang.String form)
          Return the List of Field instances supported by this Validator for the given "form" grouping.
 java.util.ResourceBundle getResource(java.util.Locale locale)
          Return the ResourceBundle used to obtain validation messages.
 void init(java.lang.String name, XMLProperties xmlProps)
          Initialises the validator by initialising all the forms configured in the given XML configuration.
 java.util.Map validate(java.lang.String form, javax.servlet.ServletRequest request)
          Validate the given request and return a Map containing the validated values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldValidator

public FieldValidator()
Default constructor

Method Detail

init

public void init(java.lang.String name,
                 XMLProperties xmlProps)
          throws ValidationException
Initialises the validator by initialising all the forms configured in the given XML configuration.

Specified by:
init in interface Validator
Parameters:
name - String containing the name of this validator.
xmlProps - XML configuration properties.
Throws:
ValidationException - if this validator cannot be initialised.

getResource

public java.util.ResourceBundle getResource(java.util.Locale locale)
                                     throws ValidationException
Return the ResourceBundle used to obtain validation messages.

Specified by:
getResource in interface Validator
Parameters:
locale - Locale to use.
Returns:
ResourceBundle
Throws:
ValidationException

getFields

public java.util.List getFields(java.lang.String form)
Return the List of Field instances supported by this Validator for the given "form" grouping.

Specified by:
getFields in interface Validator
Parameters:
form - String containing form grouping name.
Returns:
List containing Field instances for grouping.

validate

public java.util.Map validate(java.lang.String form,
                              javax.servlet.ServletRequest request)
                       throws ValidationException
Validate the given request and return a Map containing the validated values.

Specified by:
validate in interface Validator
Parameters:
form - String containing the name of the form to validate against.
request - ServletRequest containing data to be validated.
Returns:
Map containing validated values.
Throws:
ValidationException - if the request could not be validated.