org.formaria.aria.validation
Class ValidationFactory

java.lang.Object
  extended by org.formaria.aria.validation.ValidationFactory
Direct Known Subclasses:
EditorValidationFactory, FormValidationFactory

public class ValidationFactory
extends java.lang.Object

Constucts validations be reading rules from a configuration file

Copyright: Copyright (c) Formaria Ltd., 2008
License: see license.txt

$Revision: 2.4 $


Field Summary
protected static int changeCounter
          A counter for changes to the registry.
protected static java.util.Hashtable configFiles
          The config files used to build the set of component adapters.
protected  Project currentProject
           
protected  int localChangeCounter
          Used for tracking changes to the registry spec.
protected  java.util.Hashtable validations
          Hashtable of validation generated from the file referenced by the 'Validations' property in startup.properties
 
Constructor Summary
ValidationFactory(Project project)
          Constructor which reads validations from the reader
 
Method Summary
static void addConfigFile(java.lang.String key, java.lang.Object resource, boolean overwrite)
          Add a configuration file.
 void checkRegistration()
          Check that all the registered components are loaded
protected  void doRead(java.lang.String key, java.lang.Object configFile)
          Read the component registry.
protected  void doRead(java.lang.String key, java.lang.String configFile)
          Read the component registry.
protected  void doRead(java.lang.String key, java.net.URL configFileURL)
          Read the component registry.
 Validator getValidation(java.lang.String validationName, int mask, java.lang.Object page, XmlElement instanceConfig)
          Gets the validation for the validationName.
 Validator getValidation(java.lang.String validationName, java.lang.reflect.Method m, int mask, java.lang.Object page, XmlElement instanceConfig)
          Creates an Validation object which validates against a value returned from a function call
protected  void read()
          Read the component registry.
 void read(java.lang.String key, java.io.Reader reader)
          Read the component registry.
protected  void read(java.lang.String key, java.lang.String configFile)
          Read the component registry.
 void updateConfig()
          Signal that the configuration has been updated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configFiles

protected static java.util.Hashtable configFiles
The config files used to build the set of component adapters. Stores the file names


changeCounter

protected static int changeCounter
A counter for changes to the registry. Used to indicate if the registry needs to be rebuilt


localChangeCounter

protected int localChangeCounter
Used for tracking changes to the registry spec.


currentProject

protected Project currentProject

validations

protected java.util.Hashtable validations
Hashtable of validation generated from the file referenced by the 'Validations' property in startup.properties

Constructor Detail

ValidationFactory

public ValidationFactory(Project project)
Constructor which reads validations from the reader

Method Detail

getValidation

public Validator getValidation(java.lang.String validationName,
                               java.lang.reflect.Method m,
                               int mask,
                               java.lang.Object page,
                               XmlElement instanceConfig)
Creates an Validation object which validates against a value returned from a function call

Parameters:
validationName - The name of the validation
m - The Method to call in order to get the value to validate against
mask - The event mask to be applied to the validation
page - The page object which contains the function
instanceConfig - the XML element which is declared in the page
Returns:
The new Validator

getValidation

public Validator getValidation(java.lang.String validationName,
                               int mask,
                               java.lang.Object page,
                               XmlElement instanceConfig)
Gets the validation for the validationName. Checks first to see if the validation is a predefined type in which case it reads it's required attributes. If the validation type is custom we just need to create a validator from the class attribute

Parameters:
page - The page object which contains the function
validationName - The name of the validation
mask - The event mask to be applied to the validation
Returns:
The new Validator

addConfigFile

public static void addConfigFile(java.lang.String key,
                                 java.lang.Object resource,
                                 boolean overwrite)
Add a configuration file. If the files have already been loaded then the new file will be loaded

Parameters:
key - the name by which the configuration file is referenced
resource - the name/path of the configuration file or the URL for the file
overwrite - true to overwrite and existing entry matching the specified key

updateConfig

public void updateConfig()
Signal that the configuration has been updated.


read

protected void read()
Read the component registry. The format is described in the components.xsd schema.


read

protected void read(java.lang.String key,
                    java.lang.String configFile)
Read the component registry. The format is described in the components.xsd schema. The config file is also registered.

Parameters:
configFile - the name of the configuration file
key - the name by which the configuration file is referenced

doRead

protected void doRead(java.lang.String key,
                      java.lang.Object configFile)
Read the component registry. The format is described in the components.xsd schema.

Parameters:
configFile - the name of the configuration file
key - the name by which the configuration file is referenced

doRead

protected void doRead(java.lang.String key,
                      java.lang.String configFile)
Read the component registry. The format is described in the components.xsd schema.

Parameters:
configFile - the name of the configuration file
key - the name by which the configuration file is referenced

doRead

protected void doRead(java.lang.String key,
                      java.net.URL configFileURL)
Read the component registry. The format is described in the components.xsd schema.

Parameters:
configFileURL - the URL of the configuration file
key - the name by which the configuration file is referenced

read

public void read(java.lang.String key,
                 java.io.Reader reader)
Read the component registry. The format is described in the components.xsd schema.

Parameters:
key - the name by which the configuration file is referenced
reader - the reader from which to read the file

checkRegistration

public void checkRegistration()
Check that all the registered components are loaded