/** * <p>Gets a <code>FormSet</code> based on the language, country * and variant.</p> * @param language The locale's language. * @param country The locale's country. * @param variant The locale's language variant. * @return The FormSet for a locale. * @since Validator 1.2 */ FormSet getFormSet(String language, String country, String variant) { String key = buildLocale(language, country, variant); if (key.length() == 0) { return defaultFormSet; } return getFormSets().get(key); }
/** * <p>Process the <code>Form</code> objects. This clones the <code>Field</code>s * that don't exist in a <code>FormSet</code> compared to its parent * <code>FormSet</code>.</p> */ private void processForms() { if (defaultFormSet == null) {// it isn't mandatory to have a // default formset defaultFormSet = new FormSet(); } defaultFormSet.process(getConstants()); // Loop through FormSets and merge if necessary for (Iterator<String> i = getFormSets().keySet().iterator(); i.hasNext();) { String key = i.next(); FormSet fs = getFormSets().get(key); fs.merge(getParent(fs)); } // Process Fully Constructed FormSets for (Iterator<FormSet> i = getFormSets().values().iterator(); i.hasNext();) { FormSet fs = i.next(); if (!fs.isProcessed()) { fs.process(getConstants()); } } }
/** * Add a <code>FormSet</code> to this <code>ValidatorResources</code> * object. It will be associated with the <code>Locale</code> of the * <code>FormSet</code>. * @param fs The form set to add. * @since Validator 1.1 */ public void addFormSet(FormSet fs) { String key = this.buildKey(fs); if (key.length() == 0) {// there can only be one default formset if (getLog().isWarnEnabled() && defaultFormSet != null) { // warn the user he might not get the expected results getLog().warn("Overriding default FormSet definition."); } defaultFormSet = fs; } else { FormSet formset = getFormSets().get(key); if (formset == null) {// it hasn't been included yet if (getLog().isDebugEnabled()) { getLog().debug("Adding FormSet '" + fs.toString() + "'."); } } else if (getLog().isWarnEnabled()) {// warn the user he might not // get the expected results getLog() .warn("Overriding FormSet definition. Duplicate for locale: " + key); } getFormSets().put(key, fs); } }
parent = defaultFormSet; } else if (fs.getType() == FormSet.COUNTRY_FORMSET) { parent = getFormSets().get(buildLocale(fs.getLanguage(), null, null)); if (parent == null) { parent = getFormSets().get(buildLocale(fs.getLanguage(), fs .getCountry(), null)); if (parent == null) { parent = getFormSets().get(buildLocale(fs.getLanguage(), null, null)); if (parent == null) {
FormSet formSet = getFormSets().get(key); if (formSet != null) { form = formSet.getForm(formKey); key = buildLocale(language, country, null); if (key.length() > 0) { FormSet formSet = getFormSets().get(key); if (formSet != null) { form = formSet.getForm(formKey); key = buildLocale(language, null, null); if (key.length() > 0) { FormSet formSet = getFormSets().get(key); if (formSet != null) { form = formSet.getForm(formKey);
/** * <p>Gets a <code>FormSet</code> based on the language, country * and variant.</p> * @param language The locale's language. * @param country The locale's country. * @param variant The locale's language variant. * @return The FormSet for a locale. * @since Validator 1.2 */ FormSet getFormSet(String language, String country, String variant) { String key = buildLocale(language, country, variant); if (key.length() == 0) { return defaultFormSet; } return getFormSets().get(key); }
/** * <p>Process the <code>Form</code> objects. This clones the <code>Field</code>s * that don't exist in a <code>FormSet</code> compared to its parent * <code>FormSet</code>.</p> */ private void processForms() { if (defaultFormSet == null) {// it isn't mandatory to have a // default formset defaultFormSet = new FormSet(); } defaultFormSet.process(getConstants()); // Loop through FormSets and merge if necessary for (Iterator<String> i = getFormSets().keySet().iterator(); i.hasNext();) { String key = i.next(); FormSet fs = getFormSets().get(key); fs.merge(getParent(fs)); } // Process Fully Constructed FormSets for (Iterator<FormSet> i = getFormSets().values().iterator(); i.hasNext();) { FormSet fs = i.next(); if (!fs.isProcessed()) { fs.process(getConstants()); } } }
/** * Add a <code>FormSet</code> to this <code>ValidatorResources</code> * object. It will be associated with the <code>Locale</code> of the * <code>FormSet</code>. * @param fs The form set to add. * @since Validator 1.1 */ public void addFormSet(FormSet fs) { String key = this.buildKey(fs); if (key.length() == 0) {// there can only be one default formset if (getLog().isWarnEnabled() && defaultFormSet != null) { // warn the user he might not get the expected results getLog().warn("Overriding default FormSet definition."); } defaultFormSet = fs; } else { FormSet formset = getFormSets().get(key); if (formset == null) {// it hasn't been included yet if (getLog().isDebugEnabled()) { getLog().debug("Adding FormSet '" + fs.toString() + "'."); } } else if (getLog().isWarnEnabled()) {// warn the user he might not // get the expected results getLog() .warn("Overriding FormSet definition. Duplicate for locale: " + key); } getFormSets().put(key, fs); } }
parent = defaultFormSet; } else if (fs.getType() == FormSet.COUNTRY_FORMSET) { parent = getFormSets().get(buildLocale(fs.getLanguage(), null, null)); if (parent == null) { parent = getFormSets().get(buildLocale(fs.getLanguage(), fs .getCountry(), null)); if (parent == null) { parent = getFormSets().get(buildLocale(fs.getLanguage(), null, null)); if (parent == null) {
FormSet formSet = getFormSets().get(key); if (formSet != null) { form = formSet.getForm(formKey); key = buildLocale(language, country, null); if (key.length() > 0) { FormSet formSet = getFormSets().get(key); if (formSet != null) { form = formSet.getForm(formKey); key = buildLocale(language, null, null); if (key.length() > 0) { FormSet formSet = getFormSets().get(key); if (formSet != null) { form = formSet.getForm(formKey);