Package org.apache.commons.validator
Class FormSet
- java.lang.Object
-
- org.apache.commons.validator.FormSet
-
- All Implemented Interfaces:
java.io.Serializable
public class FormSet extends java.lang.Object implements java.io.SerializableHolds a set ofForms stored associated with aLocalebased on the country, language, and variant specified. Instances of this class are configured with a <formset> xml element.- Version:
- $Revision: 1713331 $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.String>constantsAMapofConstants using the name field of theConstantas the key.private java.lang.StringcountryCountry component ofLocale(optional).protected static intCOUNTRY_FORMSETThis is the type ofFormSets where only language and country locale are specified.private java.util.Map<java.lang.String,Form>formsAMapofForms using the name field of theFormas the key.protected static intGLOBAL_FORMSETThis is the type ofFormSets where no locale is specified.private java.lang.StringlanguageLanguage component ofLocale(required).protected static intLANGUAGE_FORMSETThis is the type ofFormSets where only language locale is specified.private org.apache.commons.logging.LoglogLoggingprivate booleanmergedFlag indicating if this formSet has been merged with its parent (higher rank in Locale hierarchy).private booleanprocessedWhether or not the thisFormSetwas processed for replacing variables in strings with their values.private static longserialVersionUIDprivate java.lang.StringvariantVariant component ofLocale(optional).protected static intVARIANT_FORMSETThis is the type ofFormSets where full locale has been set.
-
Constructor Summary
Constructors Constructor Description FormSet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConstant(java.lang.String name, java.lang.String value)Add aConstantto the locale level.voidaddForm(Form f)Add aFormto theFormSet.java.lang.StringdisplayKey()Returns a string representation of the object's key.java.lang.StringgetCountry()Gets the equivalent of the country component ofLocale.FormgetForm(java.lang.String formName)Retrieve aFormbased on the form name.java.util.Map<java.lang.String,Form>getForms()AMapofForms is returned as an unmodifiableMapwith the key based on the form name.java.lang.StringgetLanguage()Gets the equivalent of the language component ofLocale.private org.apache.commons.logging.LoggetLog()Accessor method for Log instance.protected intgetType()Returns the type ofFormSet:GLOBAL_FORMSET,LANGUAGE_FORMSET,COUNTRY_FORMSETorVARIANT_FORMSET.java.lang.StringgetVariant()Gets the equivalent of the variant component ofLocale.protected booleanisMerged()Has this formSet been merged?booleanisProcessed()Whether or not the thisFormSetwas processed for replacing variables in strings with their values.protected voidmerge(FormSet depends)Merges the givenFormSetinto this one.(package private) voidprocess(java.util.Map<java.lang.String,java.lang.String> globalConstants)Processes all of theForms.voidsetCountry(java.lang.String country)Sets the equivalent of the country component ofLocale.voidsetLanguage(java.lang.String language)Sets the equivalent of the language component ofLocale.voidsetVariant(java.lang.String variant)Sets the equivalent of the variant component ofLocale.java.lang.StringtoString()Returns a string representation of the object.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
log
private transient org.apache.commons.logging.Log log
Logging
-
processed
private boolean processed
Whether or not the thisFormSetwas processed for replacing variables in strings with their values.
-
language
private java.lang.String language
Language component ofLocale(required).
-
country
private java.lang.String country
Country component ofLocale(optional).
-
variant
private java.lang.String variant
Variant component ofLocale(optional).
-
forms
private final java.util.Map<java.lang.String,Form> forms
AMapofForms using the name field of theFormas the key.
-
constants
private final java.util.Map<java.lang.String,java.lang.String> constants
AMapofConstants using the name field of theConstantas the key.
-
GLOBAL_FORMSET
protected static final int GLOBAL_FORMSET
This is the type ofFormSets where no locale is specified.- See Also:
- Constant Field Values
-
LANGUAGE_FORMSET
protected static final int LANGUAGE_FORMSET
This is the type ofFormSets where only language locale is specified.- See Also:
- Constant Field Values
-
COUNTRY_FORMSET
protected static final int COUNTRY_FORMSET
This is the type ofFormSets where only language and country locale are specified.- See Also:
- Constant Field Values
-
VARIANT_FORMSET
protected static final int VARIANT_FORMSET
This is the type ofFormSets where full locale has been set.- See Also:
- Constant Field Values
-
merged
private boolean merged
Flag indicating if this formSet has been merged with its parent (higher rank in Locale hierarchy).
-
-
Method Detail
-
isMerged
protected boolean isMerged()
Has this formSet been merged?- Returns:
- true if it has been merged
- Since:
- Validator 1.2.0
-
getType
protected int getType()
Returns the type ofFormSet:GLOBAL_FORMSET,LANGUAGE_FORMSET,COUNTRY_FORMSETorVARIANT_FORMSET.- Returns:
- The type value
- Throws:
java.lang.NullPointerException- if there is inconsistency in the locale definition (not sure about this)- Since:
- Validator 1.2.0
-
merge
protected void merge(FormSet depends)
Merges the givenFormSetinto this one. If any ofdependssFormsare not in thisFormSetthen, include them, else merge bothForms. Theoretically we should only merge a "parent" formSet.- Parameters:
depends- FormSet to be merged- Since:
- Validator 1.2.0
-
isProcessed
public boolean isProcessed()
Whether or not the thisFormSetwas processed for replacing variables in strings with their values.- Returns:
- The processed value
-
getLanguage
public java.lang.String getLanguage()
Gets the equivalent of the language component ofLocale.- Returns:
- The language value
-
setLanguage
public void setLanguage(java.lang.String language)
Sets the equivalent of the language component ofLocale.- Parameters:
language- The new language value
-
getCountry
public java.lang.String getCountry()
Gets the equivalent of the country component ofLocale.- Returns:
- The country value
-
setCountry
public void setCountry(java.lang.String country)
Sets the equivalent of the country component ofLocale.- Parameters:
country- The new country value
-
getVariant
public java.lang.String getVariant()
Gets the equivalent of the variant component ofLocale.- Returns:
- The variant value
-
setVariant
public void setVariant(java.lang.String variant)
Sets the equivalent of the variant component ofLocale.- Parameters:
variant- The new variant value
-
addConstant
public void addConstant(java.lang.String name, java.lang.String value)Add aConstantto the locale level.- Parameters:
name- The constant namevalue- The constant value
-
addForm
public void addForm(Form f)
Add aFormto theFormSet.- Parameters:
f- The form
-
getForm
public Form getForm(java.lang.String formName)
Retrieve aFormbased on the form name.- Parameters:
formName- The form name- Returns:
- The form
-
getForms
public java.util.Map<java.lang.String,Form> getForms()
AMapofForms is returned as an unmodifiableMapwith the key based on the form name.- Returns:
- The forms map
-
process
void process(java.util.Map<java.lang.String,java.lang.String> globalConstants)
Processes all of theForms.- Parameters:
globalConstants- Global constants
-
displayKey
public java.lang.String displayKey()
Returns a string representation of the object's key.- Returns:
- A string representation of the key
-
toString
public java.lang.String toString()
Returns a string representation of the object.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation
-
getLog
private org.apache.commons.logging.Log getLog()
Accessor method for Log instance. The Log instance variable is transient and accessing it through this method ensures it is re-initialized when this instance is de-serialized.- Returns:
- The Log instance.
-
-