Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.commons.validator.ValidatorResources
public class ValidatorResources
extends java.lang.Object
implements Serializable
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.
Nested Class Summary |
Field Summary | |
protected static Locale |
|
protected FastHashMap |
|
protected FastHashMap |
|
protected FastHashMap |
|
protected static Log |
|
private static String[] |
|
Constructor Summary | |
| |
| |
|
Method Summary | |
void |
|
void |
|
void |
|
void |
|
void |
|
protected String | |
private String |
|
Form |
|
Form |
|
protected Field |
|
Form |
|
Form |
|
ValidatorAction |
|
Map |
|
private void |
|
void |
|
void |
|
void |
protected static Locale defaultLocale
The default locale on our server.
protected FastHashMap hActions
FastHashMap
ofValidatorAction
s with the name of theValidatorAction
as the key.
protected FastHashMap hConstants
FastHashMap
of global constant values with the name of the constant as the key.
protected FastHashMap hFormSets
FastHashMap
ofFormSet
s stored under aLocale
key.
protected static Log log
Deprecated. Subclasses should use their own logging instance.
Logger.
private static final String[] registrations
The set of public identifiers, and corresponding resource names, for the versions of the configuration file DTDs that we know about. There MUST be an even number of Strings in this list!
public ValidatorResources()
Create an empty ValidatorResources object.
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.
- 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.
- Since:
- Validator 1.1
public void addConstant(String name, String value)
Add a global constant to the resource.
public void addConstant(Constant c)
Deprecated. Use addConstant(String, String) instead.
Add a global constant to the resource.
public void addConstantParam(String name, String value)
Deprecated. Use addConstant(String, String) instead.
Add a global constant to the resource.
public void addFormSet(FormSet fs)
Add aFormSet
to thisValidatorResources
object. It will be associated with theLocale
of theFormSet
.
- Since:
- Validator 1.1
public void addValidatorAction(ValidatorAction va)
Add aValidatorAction
to the resource. It also creates an instance of the class based on theValidatorAction
s classname and retrieves theMethod
instance and sets them in theValidatorAction
.
protected String buildKey(FormSet fs)
Builds a key to store theFormSet
under based on it's language, country, and variant values.
private String buildLocale(String lang, String country, String variant)
Assembles a Locale code from the given parts.
public Form get(Locale locale, Object formKey)
Deprecated. Use getForm() instead.
Gets aForm
based on the name of the form and theLocale
that most closely matches theLocale
passed in. The order ofLocale
matching is:
- language + country + variant
- language + country
- language
- default locale
public Form get(String language, String country, String variant, Object formKey)
Deprecated. Use getForm() instead.
Gets aForm
based on the name of the form and theLocale
that most closely matches theLocale
passed in. The order ofLocale
matching is:
- language + country + variant
- language + country
- language
- default locale
protected Field getClosestLocaleField(FormSet fs, String formKey, String fieldKey)
Retrieves the closest matchingField
based onFormSet
's locale. This is used when constructing a clone, field by field, of partialFormSet
.
public Form getForm(Locale locale, String formKey)
Gets aForm
based on the name of the form and theLocale
that most closely matches theLocale
passed in. The order ofLocale
matching is:
- language + country + variant
- language + country
- language
- default locale
- Since:
- Validator 1.1
public Form getForm(String language, String country, String variant, String formKey)
Gets aForm
based on the name of the form and theLocale
that most closely matches theLocale
passed in. The order ofLocale
matching is:
- language + country + variant
- language + country
- language
- default locale
- Since:
- Validator 1.1
public ValidatorAction getValidatorAction(String key)
Get aValidatorAction
based on it's name.
public Map getValidatorActions()
Get an unmodifiableMap
of theValidatorAction
s.
private void internalProcessForms()
Process theForm
objects. This clones theField
s that don't exist in aFormSet
compared to the defaultFormSet
. TODO When processForms() is removed from the public interface, rename this private method back to "processForms".
public void process()
Process theValidatorResources
object. Currently sets theFastHashMap
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.
public void processForms()
Deprecated. This is an internal method that client classes need not call directly.
Process theForm
objects. This clones theField
s that don't exist in aFormSet
compared to the defaultFormSet
.
public void put(FormSet fs)
Deprecated. Use addFormSet() instead.
Add aFormSet
to thisValidatorResources
object. It will be associated with theLocale
of theFormSet
.