org.apache.commons.validator
public class ValidatorResources extends Object implements 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 static Locale | defaultLocale
The default locale on our server. |
| protected FastHashMap | hActionsFastHashMap of ValidatorActions with
the name of the ValidatorAction as the key. |
| protected FastHashMap | hConstantsFastHashMap of global constant values with
the name of the constant as the key. |
| protected FastHashMap | hFormSetsFastHashMap of FormSets stored under
a Locale key. |
| protected static Log | log
Logger. |
| static String[] | registrations
The set of public identifiers, and corresponding resource names, for
the versions of the configuration file DTDs that we know about. |
| Constructor Summary | |
|---|---|
| ValidatorResources()
Create an empty ValidatorResources object. | |
| ValidatorResources(InputStream in)
Create a ValidatorResources object from an InputStream.
| |
| ValidatorResources(InputStream[] streams)
Create a ValidatorResources object from an InputStream.
| |
| Method Summary | |
|---|---|
| void | addConstant(Constant c)
Add a global constant to the resource. |
| void | addConstant(String name, String value)
Add a global constant to the resource. |
| void | addConstantParam(String name, String value)
Add a global constant to the resource. |
| void | addFormSet(FormSet fs)
Add a FormSet to this ValidatorResources
object. |
| void | addValidatorAction(ValidatorAction va)
Add a ValidatorAction to the resource. |
| protected String | buildKey(FormSet fs)
Builds a key to store the FormSet under based on it's
language, country, and variant values. |
| String | buildLocale(String lang, String country, String variant)
Assembles a Locale code from the given parts. |
| Form | get(Locale locale, Object formKey) Gets a |
| Form | get(String language, String country, String variant, Object formKey) Gets a |
| protected Field | getClosestLocaleField(FormSet fs, String formKey, String fieldKey)
Retrieves the closest matching Field based
on FormSet's locale. |
| Form | getForm(Locale locale, String formKey) Gets a |
| Form | getForm(String language, String country, String variant, String formKey) Gets a |
| ValidatorAction | getValidatorAction(String key)
Get a ValidatorAction based on it's name. |
| Map | getValidatorActions()
Get an unmodifiable Map of the ValidatorActions. |
| void | internalProcessForms() Process the |
| void | process()
Process the ValidatorResources object. |
| void | processForms() Process the |
| void | put(FormSet fs)
Add a FormSet to this ValidatorResources
object. |
FastHashMap of ValidatorActions with
the name of the ValidatorAction as the key.FastHashMap of global constant values with
the name of the constant as the key.FastHashMap of FormSets stored under
a Locale key.Deprecated: Subclasses should use their own logging instance.
Logger.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.
Since: Validator 1.1
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.
Since: Validator 1.1
Deprecated: Use addConstant(String, String) instead.
Add a global constant to the resource.Deprecated: Use addConstant(String, String) instead.
Add a global constant to the resource.FormSet to this ValidatorResources
object. It will be associated with the Locale of the
FormSet.Since: Validator 1.1
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.FormSet under based on it's
language, country, and variant values.Deprecated: Use getForm() instead.
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:
Deprecated: Use getForm() instead.
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:
Field based
on FormSet's locale. This is used when
constructing a clone, field by field, of partial
FormSet.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:
Since: Validator 1.1
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:
Since: Validator 1.1
ValidatorAction based on it's name.Map of the ValidatorActions.Process the Form objects. This clones the Fields
that don't exist in a FormSet compared to the default
FormSet.
ValidatorResources object. Currently sets the
FastHashMaps 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.Deprecated: This is an internal method that client classes need not call directly.
Process the Form objects. This clones the Fields
that don't exist in a FormSet compared to the default
FormSet.
Deprecated: Use addFormSet() instead.
Add aFormSet to this ValidatorResources
object. It will be associated with the Locale of the
FormSet.