Class FormSet

java.lang.Object
org.apache.commons.validator.FormSet
All Implemented Interfaces:
Serializable

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: 1713331 $
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Map<String,String>
    A Map of Constants using the name field of the Constant as the key.
    private String
    Country component of Locale (optional).
    protected static final int
    This is the type of FormSets where only language and country locale are specified.
    private final Map<String,Form>
    A Map of Forms using the name field of the Form as the key.
    protected static final int
    This is the type of FormSets where no locale is specified.
    private String
    Language component of Locale (required).
    protected static final int
    This is the type of FormSets where only language locale is specified.
    private org.apache.commons.logging.Log
    Logging
    private boolean
    Flag indicating if this formSet has been merged with its parent (higher rank in Locale hierarchy).
    private boolean
    Whether or not the this FormSet was processed for replacing variables in strings with their values.
    private static final long
     
    private String
    Variant component of Locale (optional).
    protected static final int
    This is the type of FormSets where full locale has been set.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addConstant(String name, String value)
    Add a Constant to the locale level.
    void
    Add a Form to the FormSet.
    Returns a string representation of the object's key.
    Gets the equivalent of the country component of Locale.
    getForm(String formName)
    Retrieve a Form based on the form name.
    A Map of Forms is returned as an unmodifiable Map with the key based on the form name.
    Gets the equivalent of the language component of Locale.
    private org.apache.commons.logging.Log
    Accessor method for Log instance.
    protected int
    Returns the type of FormSet:GLOBAL_FORMSET, LANGUAGE_FORMSET,COUNTRY_FORMSET or VARIANT_FORMSET .
    Gets the equivalent of the variant component of Locale.
    protected boolean
    Has this formSet been merged?
    boolean
    Whether or not the this FormSet was processed for replacing variables in strings with their values.
    protected void
    merge(FormSet depends)
    Merges the given FormSet into this one.
    (package private) void
    process(Map<String,String> globalConstants)
    Processes all of the Forms.
    void
    setCountry(String country)
    Sets the equivalent of the country component of Locale.
    void
    setLanguage(String language)
    Sets the equivalent of the language component of Locale.
    void
    setVariant(String variant)
    Sets the equivalent of the variant component of Locale.
    Returns a string representation of the object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • log

      private transient org.apache.commons.logging.Log log
      Logging
    • processed

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

      private String language
      Language component of Locale (required).
    • country

      private String country
      Country component of Locale (optional).
    • variant

      private String variant
      Variant component of Locale (optional).
    • forms

      private final Map<String,Form> forms
      A Map of Forms using the name field of the Form as the key.
    • constants

      private final Map<String,String> constants
      A Map of Constants using the name field of the Constant as the key.
    • GLOBAL_FORMSET

      protected static final int GLOBAL_FORMSET
      This is the type of FormSets where no locale is specified.
      See Also:
    • LANGUAGE_FORMSET

      protected static final int LANGUAGE_FORMSET
      This is the type of FormSets where only language locale is specified.
      See Also:
    • COUNTRY_FORMSET

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

      protected static final int VARIANT_FORMSET
      This is the type of FormSets where full locale has been set.
      See Also:
    • merged

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

    • FormSet

      public FormSet()
  • Method Details

    • 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 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
    • 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
    • isProcessed

      public boolean isProcessed()
      Whether or not the this FormSet was processed for replacing variables in strings with their values.
      Returns:
      The processed value
    • getLanguage

      public String getLanguage()
      Gets the equivalent of the language component of Locale.
      Returns:
      The language value
    • setLanguage

      public void setLanguage(String language)
      Sets the equivalent of the language component of Locale.
      Parameters:
      language - The new language value
    • getCountry

      public String getCountry()
      Gets the equivalent of the country component of Locale.
      Returns:
      The country value
    • setCountry

      public void setCountry(String country)
      Sets the equivalent of the country component of Locale.
      Parameters:
      country - The new country value
    • getVariant

      public String getVariant()
      Gets the equivalent of the variant component of Locale.
      Returns:
      The variant value
    • setVariant

      public void setVariant(String variant)
      Sets the equivalent of the variant component of Locale.
      Parameters:
      variant - The new variant value
    • 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
    • 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<String,Form> getForms()
      A Map of Forms is returned as an unmodifiable Map with the key based on the form name.
      Returns:
      The forms map
    • process

      void process(Map<String,String> globalConstants)
      Processes all of the Forms.
      Parameters:
      globalConstants - Global constants
    • displayKey

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

      public String toString()
      Returns a string representation of the object.
      Overrides:
      toString in class 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.