Save This Page
Home » commons-validator-1.3.1-src » org.apache.commons » validator » [javadoc | source]
org.apache.commons.validator
public class: ValidatorResources [javadoc | source]
java.lang.Object
   org.apache.commons.validator.ValidatorResources

All Implemented Interfaces:
    Serializable

General purpose class for storing FormSet objects based on their associated Locale. Instances of this class are usually configured through a validation.xml file that is parsed in a constructor.

Note - Classes that extend this class must be Serializable so that instances may be used in distributable application server environments.

The use of FastHashMap is deprecated and will be replaced in a future release.

Field Summary
protected  FastHashMap hFormSets    Map of FormSets stored under a Locale key.
     
    protected  FastHashMap hConstants    Map of global constant values with the name of the constant as the key.
       
      protected  FastHashMap hActions    Map of ValidatorActions with the name of the ValidatorAction as the key.
         
        protected static  Locale defaultLocale    The default locale on our server. 
        protected  FormSet defaultFormSet    This is the default FormSet (without locale). (We probably don't need the defaultLocale anymore.) 
        Constructor:
         public ValidatorResources() 
         public ValidatorResources(InputStream in) throws IOException, SAXException 
          Create a ValidatorResources object from an InputStream.
          Parameters:
          in - InputStream to a validation.xml configuration file. It's the client's responsibility to close this stream.
          Throws:
          IOException -
          SAXException - if the validation XML files are not valid or well formed.
          IOException - if an I/O error occurs processing the XML files
          since: Validator - 1.1
         public ValidatorResources(InputStream[] streams) throws IOException, SAXException 
          Create a ValidatorResources object from an InputStream.
          Parameters:
          streams - An array of InputStreams to several validation.xml configuration files that will be read in order and merged into this object. It's the client's responsibility to close these streams.
          Throws:
          IOException -
          SAXException - if the validation XML files are not valid or well formed.
          IOException - if an I/O error occurs processing the XML files
          since: Validator - 1.1
         public ValidatorResources(String uri) throws IOException, SAXException 
          Create a ValidatorResources object from an uri
          Parameters:
          uri - The location of a validation.xml configuration file.
          Throws:
          IOException -
          SAXException - if the validation XML files are not valid or well formed.
          IOException - if an I/O error occurs processing the XML files
          since: Validator - 1.2
         public ValidatorResources(String[] uris) throws IOException, SAXException 
          Create a ValidatorResources object from several uris
          Parameters:
          uris - An array of uris to several validation.xml configuration files that will be read in order and merged into this object.
          Throws:
          IOException -
          SAXException - if the validation XML files are not valid or well formed.
          IOException - if an I/O error occurs processing the XML files
          since: Validator - 1.2
         public ValidatorResources(URL url) throws IOException, SAXException 
          Create a ValidatorResources object from a URL.
          Parameters:
          url - The URL for the validation.xml configuration file that will be read into this object.
          Throws:
          IOException -
          SAXException - if the validation XML file are not valid or well formed.
          IOException - if an I/O error occurs processing the XML files
          since: Validator - 1.3.1
         public ValidatorResources(URL[] urls) throws IOException, SAXException 
          Create a ValidatorResources object from several URL.
          Parameters:
          urls - An array of URL to several validation.xml configuration files that will be read in order and merged into this object.
          Throws:
          IOException -
          SAXException - if the validation XML files are not valid or well formed.
          IOException - if an I/O error occurs processing the XML files
          since: Validator - 1.3.1
        Method from org.apache.commons.validator.ValidatorResources Summary:
        addConstant,   addFormSet,   addValidatorAction,   buildKey,   getActions,   getConstants,   getForm,   getForm,   getFormSet,   getFormSets,   getValidatorAction,   getValidatorActions,   process
        Methods from java.lang.Object:
        equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
        Method from org.apache.commons.validator.ValidatorResources Detail:
         public  void addConstant(String name,
            String value) 
          Add a global constant to the resource.
         public  void addFormSet(FormSet fs) 
          Add a FormSet to this ValidatorResources object. It will be associated with the Locale of the FormSet.
         public  void addValidatorAction(ValidatorAction va) 
          Add a ValidatorAction to the resource. It also creates an instance of the class based on the ValidatorActions classname and retrieves the Method instance and sets them in the ValidatorAction.
         protected String buildKey(FormSet fs) 
          Builds a key to store the FormSet under based on it's language, country, and variant values.
         protected Map getActions() 
          Returns a Map of String ValidatorAction names to their ValidatorAction.
         protected Map getConstants() 
          Returns a Map of String constant names to their String values.
         public Form getForm(Locale locale,
            String formKey) 

          Gets a Form based on the name of the form and the Locale that most closely matches the Locale passed in. The order of Locale matching is:

          1. language + country + variant
          2. language + country
          3. language
          4. default locale
         public Form getForm(String language,
            String country,
            String variant,
            String formKey) 

          Gets a Form based on the name of the form and the Locale that most closely matches the Locale passed in. The order of Locale matching is:

          1. language + country + variant
          2. language + country
          3. language
          4. default locale
         FormSet getFormSet(String language,
            String country,
            String variant) 

          Gets a FormSet based on the language, country and variant.

         protected Map getFormSets() 
          Returns a Map of String locale keys to Lists of their FormSets.
         public ValidatorAction getValidatorAction(String key) 
          Get a ValidatorAction based on it's name.
         public Map getValidatorActions() 
          Get an unmodifiable Map of the ValidatorActions.
         public  void process() 
          Process the ValidatorResources object. Currently sets the FastHashMap s to the 'fast' mode and call the processes all other resources. Note : The framework calls this automatically when ValidatorResources is created from an XML file. If you create an instance of this class by hand you must call this method when finished.