public class ValidatorResources
extends java.lang.Object
implements java.io.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 |
|---|---|
private static java.lang.String |
argsPattern |
protected FormSet |
defaultFormSet
This is the default
FormSet (without locale). |
protected static java.util.Locale |
defaultLocale
The default locale on our server.
|
protected FastHashMap |
hActions
Deprecated.
Subclasses should use getActions() instead.
|
protected FastHashMap |
hConstants
Deprecated.
Subclasses should use getConstants() instead.
|
protected FastHashMap |
hFormSets
Deprecated.
Subclasses should use getFormSets() instead.
|
private static Log |
log |
private static java.lang.String[] |
registrations
The set of public identifiers, and corresponding resource names, for
the versions of the configuration file DTDs that we know about.
|
| Constructor and Description |
|---|
ValidatorResources()
Create an empty ValidatorResources object.
|
ValidatorResources(java.io.InputStream in)
Create a ValidatorResources object from an InputStream.
|
ValidatorResources(java.io.InputStream[] streams)
Create a ValidatorResources object from an InputStream.
|
ValidatorResources(java.lang.String uri)
Create a ValidatorResources object from an uri
|
ValidatorResources(java.lang.String[] uris)
Create a ValidatorResources object from several uris
|
| Modifier and Type | Method and Description |
|---|---|
void |
addConstant(java.lang.String name,
java.lang.String value)
Add a global constant to the resource.
|
void |
addFormSet(FormSet fs)
Add a
FormSet to this ValidatorResources
object. |
private void |
addOldArgRules(Digester digester)
Create a
Rule to handle arg0-arg3
elements. |
void |
addValidatorAction(ValidatorAction va)
Add a
ValidatorAction to the resource. |
protected java.lang.String |
buildKey(FormSet fs)
Builds a key to store the
FormSet under based on it's
language, country, and variant values. |
private java.lang.String |
buildLocale(java.lang.String lang,
java.lang.String country,
java.lang.String variant)
Assembles a Locale code from the given parts.
|
protected java.util.Map |
getActions()
Returns a Map of String ValidatorAction names to their ValidatorAction.
|
protected java.util.Map |
getConstants()
Returns a Map of String constant names to their String values.
|
Form |
getForm(java.util.Locale locale,
java.lang.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(java.lang.String language,
java.lang.String country,
java.lang.String variant,
java.lang.String formKey)
Gets a
Form based on the name of the form and the
Locale that most closely matches the Locale
passed in. |
(package private) FormSet |
getFormSet(java.lang.String language,
java.lang.String country,
java.lang.String variant)
Gets a
FormSet based on the language, country
and variant. |
protected java.util.Map |
getFormSets()
Returns a Map of String locale keys to Lists of their FormSets.
|
private FormSet |
getParent(FormSet fs)
Finds the given formSet's parent.
|
ValidatorAction |
getValidatorAction(java.lang.String key)
Get a
ValidatorAction based on it's name. |
java.util.Map |
getValidatorActions()
Get an unmodifiable
Map of the ValidatorActions. |
private Digester |
initDigester()
Initialize the digester.
|
void |
process()
Process the
ValidatorResources object. |
private void |
processForms()
Process the
Form objects. |
private static final java.lang.String[] registrations
private static final Log log
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 java.util.Locale defaultLocale
protected FormSet defaultFormSet
FormSet (without locale). (We probably don't need
the defaultLocale anymore.)private static final java.lang.String argsPattern
public ValidatorResources()
public ValidatorResources(java.io.InputStream in)
throws java.io.IOException,
org.xml.sax.SAXException
in - InputStream to a validation.xml configuration file. It's the client's
responsibility to close this stream.java.io.IOExceptionorg.xml.sax.SAXException - if the validation XML files are not valid or well
formed.public ValidatorResources(java.io.InputStream[] streams)
throws java.io.IOException,
org.xml.sax.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.java.io.IOExceptionorg.xml.sax.SAXException - if the validation XML files are not valid or well
formed.public ValidatorResources(java.lang.String uri)
throws java.io.IOException,
org.xml.sax.SAXException
uri - The location of a validation.xml configuration file.java.io.IOExceptionorg.xml.sax.SAXException - if the validation XML files are not valid or well
formed.public ValidatorResources(java.lang.String[] uris)
throws java.io.IOException,
org.xml.sax.SAXException
uris - An array of uris to several validation.xml
configuration files that will be read in order and merged into this object.java.io.IOExceptionorg.xml.sax.SAXException - if the validation XML files are not valid or well
formed.private Digester initDigester()
private void addOldArgRules(Digester digester)
Rule to handle arg0-arg3
elements. This will allow validation.xml files that use the
versions of the DTD prior to Validator 1.2.0 to continue
working.public 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(java.lang.String name,
java.lang.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 ValidatorActions
classname and retrieves the Method instance and sets them
in the ValidatorAction.va - The validator action.public ValidatorAction getValidatorAction(java.lang.String key)
ValidatorAction based on it's name.key - The validator action key.public java.util.Map getValidatorActions()
Map of the ValidatorActions.protected java.lang.String buildKey(FormSet fs)
FormSet under based on it's
language, country, and variant values.fs - The Form Set.private java.lang.String buildLocale(java.lang.String lang,
java.lang.String country,
java.lang.String variant)
public Form getForm(java.util.Locale locale, java.lang.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(java.lang.String language, java.lang.String country, java.lang.String variant, java.lang.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.private void processForms()
Process the Form objects. This clones the Fields
that don't exist in a FormSet compared to its parent
FormSet.
private FormSet getParent(FormSet fs)
fs - the formSet we want to get the parent fromFormSet getFormSet(java.lang.String language, java.lang.String country, java.lang.String variant)
Gets a FormSet based on the language, country
and variant.
language - The locale's language.country - The locale's country.variant - The locale's language variant.protected java.util.Map getFormSets()
protected java.util.Map getConstants()
protected java.util.Map getActions()
Copyright (c) 2001-2004 Apache Software Foundation