| Prev Class | Next Class | Frames | No Frames |
| Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Objectorg.apache.commons.validator.ValidatorResourcespublic class ValidatorResourcesextends java.lang.Objectimplements SerializableFormSet 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 |
|
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
FastHashMapofValidatorActions with the name of theValidatorActionas the key.
protected FastHashMap hConstants
FastHashMapof global constant values with the name of the constant as the key.
protected FastHashMap hFormSets
FastHashMapofFormSets stored under aLocalekey.
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,
SAXExceptionCreate 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,
SAXExceptionCreate 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 aFormSetto thisValidatorResourcesobject. It will be associated with theLocaleof theFormSet.
- Since:
- Validator 1.1
public void addValidatorAction(ValidatorAction va)
Add aValidatorActionto the resource. It also creates an instance of the class based on theValidatorActions classname and retrieves theMethodinstance and sets them in theValidatorAction.
protected String buildKey(FormSet fs)
Builds a key to store theFormSetunder 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 aFormbased on the name of the form and theLocalethat most closely matches theLocalepassed in. The order ofLocalematching 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 aFormbased on the name of the form and theLocalethat most closely matches theLocalepassed in. The order ofLocalematching is:
- language + country + variant
- language + country
- language
- default locale
protected Field getClosestLocaleField(FormSet fs, String formKey, String fieldKey)
Retrieves the closest matchingFieldbased onFormSet's locale. This is used when constructing a clone, field by field, of partialFormSet.
public Form getForm(Locale locale, String formKey)
Gets aFormbased on the name of the form and theLocalethat most closely matches theLocalepassed in. The order ofLocalematching 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 aFormbased on the name of the form and theLocalethat most closely matches theLocalepassed in. The order ofLocalematching is:
- language + country + variant
- language + country
- language
- default locale
- Since:
- Validator 1.1
public ValidatorAction getValidatorAction(String key)
Get aValidatorActionbased on it's name.
public Map getValidatorActions()
Get an unmodifiableMapof theValidatorActions.
private void internalProcessForms()
Process theFormobjects. This clones theFields that don't exist in aFormSetcompared to the defaultFormSet. TODO When processForms() is removed from the public interface, rename this private method back to "processForms".
public void process()
Process theValidatorResourcesobject. Currently sets theFastHashMaps 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 theFormobjects. This clones theFields that don't exist in aFormSetcompared to the defaultFormSet.
public void put(FormSet fs)
Deprecated. Use addFormSet() instead.
Add aFormSetto thisValidatorResourcesobject. It will be associated with theLocaleof theFormSet.