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.
Modifier and Type | Field and Description |
---|---|
protected FormSet |
defaultFormSet
This is the default
FormSet (without locale). |
protected static Locale |
defaultLocale
The default locale on our server.
|
protected org.apache.commons.collections.FastHashMap |
hActions
Deprecated.
Subclasses should use getActions() instead.
|
protected org.apache.commons.collections.FastHashMap |
hConstants
Deprecated.
Subclasses should use getConstants() instead.
|
protected org.apache.commons.collections.FastHashMap |
hFormSets
Deprecated.
Subclasses should use getFormSets() instead.
|
Constructor and Description |
---|
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.
|
ValidatorResources(String uri)
Create a ValidatorResources object from an uri
|
ValidatorResources(String[] uris)
Create a ValidatorResources object from several uris
|
ValidatorResources(URL url)
Create a ValidatorResources object from a URL.
|
ValidatorResources(URL[] urls)
Create a ValidatorResources object from several URL.
|
Modifier and Type | Method and Description |
---|---|
void |
addConstant(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. |
protected Map<String,ValidatorAction> |
getActions()
Returns a Map of String ValidatorAction names to their ValidatorAction.
|
protected Map<String,String> |
getConstants()
Returns a Map of String constant names to their String values.
|
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. |
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. |
protected Map<String,FormSet> |
getFormSets()
Returns a Map of String locale keys to Lists of their FormSets.
|
ValidatorAction |
getValidatorAction(String key)
Get a
ValidatorAction based on it's name. |
Map<String,ValidatorAction> |
getValidatorActions()
Get an unmodifiable
Map of the ValidatorAction s. |
void |
process()
Process the
ValidatorResources object. |
protected org.apache.commons.collections.FastHashMap hFormSets
Map
of FormSet
s stored under
a Locale
key (expressed as a String).protected org.apache.commons.collections.FastHashMap hConstants
Map
of global constant values with
the name of the constant as the key.protected org.apache.commons.collections.FastHashMap hActions
Map
of ValidatorAction
s with
the name of the ValidatorAction
as the key.protected static Locale defaultLocale
protected FormSet defaultFormSet
FormSet
(without locale). (We probably don't need
the defaultLocale anymore.)public ValidatorResources()
public ValidatorResources(InputStream in) throws IOException, SAXException
in
- InputStream to a validation.xml configuration file. It's the client's
responsibility to close this stream.SAXException
- if the validation XML files are not valid or well
formed.IOException
- if an I/O error occurs processing the XML filespublic ValidatorResources(InputStream[] streams) throws IOException, SAXException
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.SAXException
- if the validation XML files are not valid or well
formed.IOException
- if an I/O error occurs processing the XML filespublic ValidatorResources(String uri) throws IOException, SAXException
uri
- The location of a validation.xml configuration file.SAXException
- if the validation XML files are not valid or well
formed.IOException
- if an I/O error occurs processing the XML filespublic ValidatorResources(String[] uris) throws IOException, SAXException
uris
- An array of uris to several validation.xml
configuration files that will be read in order and merged into this object.SAXException
- if the validation XML files are not valid or well
formed.IOException
- if an I/O error occurs processing the XML filespublic ValidatorResources(URL url) throws IOException, SAXException
url
- The URL for the validation.xml
configuration file that will be read into this object.SAXException
- if the validation XML file are not valid or well
formed.IOException
- if an I/O error occurs processing the XML filespublic ValidatorResources(URL[] urls) throws IOException, SAXException
urls
- An array of URL to several validation.xml
configuration files that will be read in order and merged into this object.SAXException
- if the validation XML files are not valid or well
formed.IOException
- if an I/O error occurs processing the XML filespublic void addFormSet(FormSet fs)
FormSet
to this ValidatorResources
object. It will be associated with the Locale
of the
FormSet
.fs
- The form set to add.public void addConstant(String name, String value)
name
- The constant name.value
- The constant value.public void addValidatorAction(ValidatorAction va)
ValidatorAction
to the resource. It also creates an
instance of the class based on the ValidatorAction
s
classname and retrieves the Method
instance and sets them
in the ValidatorAction
.va
- The validator action.public ValidatorAction getValidatorAction(String key)
ValidatorAction
based on it's name.key
- The validator action key.public Map<String,ValidatorAction> getValidatorActions()
Map
of the ValidatorAction
s.protected String buildKey(FormSet fs)
FormSet
under based on it's
language, country, and variant values.fs
- The Form Set.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:
locale
- The Locale.formKey
- The key for the Form.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:
language
- The locale's language.country
- The locale's country.variant
- The locale's language variant.formKey
- The key for the Form.public void process()
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.protected Map<String,FormSet> getFormSets()
protected Map<String,String> getConstants()
protected Map<String,ValidatorAction> getActions()
Copyright © 2002–2017 The Apache Software Foundation. All rights reserved.