org.apache.commons.validator

Class FormSet

public class FormSet extends Object implements Serializable

Holds a set of Forms stored associated with a Locale based on the country, language, and variant specified. Instances of this class are configured with a <formset> xml element.

Version: $Revision: 478334 $ $Date: 2006-11-22 21:31:54 +0000 (Wed, 22 Nov 2006) $

Field Summary
Mapconstants
A Map of Constants using the name field of the Constant as the key.
Stringcountry
Country component of Locale (optional).
protected static intCOUNTRY_FORMSET
This is the type of FormSets where only language and country locale are specified.
Mapforms
A Map of Forms using the name field of the Form as the key.
protected static intGLOBAL_FORMSET
This is the type of FormSets where no locale is specified.
Stringlanguage
Language component of Locale (required).
Loglog
Logging
protected static intLANGUAGE_FORMSET
This is the type of FormSets where only language locale is specified.
booleanmerged
Flag indicating if this formSet has been merged with its parent (higher rank in Locale hierarchy).
booleanprocessed
Whether or not the this FormSet was processed for replacing variables in strings with their values.
Stringvariant
Variant component of Locale (optional).
protected static intVARIANT_FORMSET
This is the type of FormSets where full locale has been set.
Method Summary
voidaddConstant(String name, String value)
Add a Constant to the locale level.
voidaddForm(Form f)
Add a Form to the FormSet.
StringdisplayKey()
Returns a string representation of the object's key.
StringgetCountry()
Gets the equivalent of the country component of Locale.
FormgetForm(String formName)
Retrieve a Form based on the form name.
MapgetForms()
A Map of Forms is returned as an unmodifiable Map with the key based on the form name.
StringgetLanguage()
Gets the equivalent of the language component of Locale.
LoggetLog()
Accessor method for Log instance.
protected intgetType()
Returns the type of FormSet:GLOBAL_FORMSET, LANGUAGE_FORMSET,COUNTRY_FORMSET or VARIANT_FORMSET .
StringgetVariant()
Gets the equivalent of the variant component of Locale.
protected booleanisMerged()
Has this formSet been merged?
booleanisProcessed()
Whether or not the this FormSet was processed for replacing variables in strings with their values.
protected voidmerge(FormSet depends)
Merges the given FormSet into this one.
voidprocess(Map globalConstants)
Processes all of the Forms.
voidsetCountry(String country)
Sets the equivalent of the country component of Locale.
voidsetLanguage(String language)
Sets the equivalent of the language component of Locale.
voidsetVariant(String variant)
Sets the equivalent of the variant component of Locale.
StringtoString()
Returns a string representation of the object.

Field Detail

constants

private Map constants
A Map of Constants using the name field of the Constant as the key.

country

private String country
Country component of Locale (optional).

COUNTRY_FORMSET

protected static final int COUNTRY_FORMSET
This is the type of FormSets where only language and country locale are specified.

forms

private Map forms
A Map of Forms using the name field of the Form as the key.

GLOBAL_FORMSET

protected static final int GLOBAL_FORMSET
This is the type of FormSets where no locale is specified.

language

private String language
Language component of Locale (required).

log

private transient Log log
Logging

LANGUAGE_FORMSET

protected static final int LANGUAGE_FORMSET
This is the type of FormSets where only language locale is specified.

merged

private boolean merged
Flag indicating if this formSet has been merged with its parent (higher rank in Locale hierarchy).

processed

private boolean processed
Whether or not the this FormSet was processed for replacing variables in strings with their values.

variant

private String variant
Variant component of Locale (optional).

VARIANT_FORMSET

protected static final int VARIANT_FORMSET
This is the type of FormSets where full locale has been set.

Method Detail

addConstant

public void addConstant(String name, String value)
Add a Constant to the locale level.

Parameters: name The constant name value The constant value

addForm

public void addForm(Form f)
Add a Form to the FormSet.

Parameters: f The form

displayKey

public String displayKey()
Returns a string representation of the object's key.

Returns: A string representation of the key

getCountry

public String getCountry()
Gets the equivalent of the country component of Locale.

Returns: The country value

getForm

public Form getForm(String formName)
Retrieve a Form based on the form name.

Parameters: formName The form name

Returns: The form

getForms

public Map getForms()
A Map of Forms is returned as an unmodifiable Map with the key based on the form name.

Returns: The forms map

getLanguage

public String getLanguage()
Gets the equivalent of the language component of Locale.

Returns: The language value

getLog

private 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.

getType

protected int getType()
Returns the type of FormSet:GLOBAL_FORMSET, LANGUAGE_FORMSET,COUNTRY_FORMSET or VARIANT_FORMSET .

Returns: The type value

Throws: NullPointerException if there is inconsistency in the locale definition (not sure about this)

Since: Validator 1.2.0

getVariant

public String getVariant()
Gets the equivalent of the variant component of Locale.

Returns: The variant value

isMerged

protected boolean isMerged()
Has this formSet been merged?

Returns: true if it has been merged

Since: Validator 1.2.0

isProcessed

public boolean isProcessed()
Whether or not the this FormSet was processed for replacing variables in strings with their values.

Returns: The processed value

merge

protected void merge(FormSet depends)
Merges the given FormSet into this one. If any of depends s Forms are not in this FormSet then, include them, else merge both Forms. Theoretically we should only merge a "parent" formSet.

Parameters: depends FormSet to be merged

Since: Validator 1.2.0

process

void process(Map globalConstants)
Processes all of the Forms.

Parameters: globalConstants Global constants

setCountry

public void setCountry(String country)
Sets the equivalent of the country component of Locale.

Parameters: country The new country value

setLanguage

public void setLanguage(String language)
Sets the equivalent of the language component of Locale.

Parameters: language The new language value

setVariant

public void setVariant(String variant)
Sets the equivalent of the variant component of Locale.

Parameters: variant The new variant value

toString

public String toString()
Returns a string representation of the object.

Returns: A string representation

Copyright (c) 2001-2004 Apache Software Foundation