dgraham 2003/05/28 20:34:36
Modified: validator/src/share/org/apache/commons/validator
ValidatorResources.java Form.java
validator/src/example/org/apache/commons/validator/example
ValidateExample.java
Log:
Deprecated Form.getFieldMap() and added Form.containsField() and
Form.getField(). This doesn't expose so much of Form's implementation
and makes the client code easier.
Revision Changes Path
1.22 +10 -11
jakarta-commons/validator/src/share/org/apache/commons/validator/ValidatorResources.java
Index: ValidatorResources.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/ValidatorResources.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- ValidatorResources.java 29 May 2003 03:03:02 -0000 1.21
+++ ValidatorResources.java 29 May 2003 03:34:35 -0000 1.22
@@ -492,9 +492,8 @@
Field defaultField = (Field) defaultFields.next();
String fieldKey = defaultField.getKey();
- if (form.getFieldMap().containsKey(fieldKey)) {
- newForm.addField(
- (Field) form.getFieldMap().get(fieldKey));
+ if (form.containsField(fieldKey)) {
+ newForm.addField(form.getField(fieldKey));
} else {
Field field =
@@ -544,7 +543,7 @@
&& !GenericValidator.isBlankOrNull(variant)) {
Form form = this.getForm(language, country, variant, formKey);
- field = (Field) form.getFieldMap().get(fieldKey);
+ field = form.getField(fieldKey);
}
if (field == null) {
@@ -552,20 +551,20 @@
&& !GenericValidator.isBlankOrNull(country)) {
Form form = this.getForm(language, country, null, formKey);
- field = (Field) form.getFieldMap().get(fieldKey);
+ field = form.getField(fieldKey);
}
}
if (field == null) {
if (!GenericValidator.isBlankOrNull(language)) {
Form form = this.getForm(language, null, null, formKey);
- field = (Field) form.getFieldMap().get(fieldKey);
+ field = form.getField(fieldKey);
}
}
if (field == null) {
Form form = this.getForm(defaultLocale, formKey);
- field = (Field) form.getFieldMap().get(fieldKey);
+ field = form.getField(fieldKey);
}
return field;
1.8 +19 -4
jakarta-commons/validator/src/share/org/apache/commons/validator/Form.java
Index: Form.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/Form.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Form.java 29 May 2003 03:03:56 -0000 1.7
+++ Form.java 29 May 2003 03:34:35 -0000 1.8
@@ -133,9 +133,24 @@
/**
* The <code>Field</code>s are returned as an unmodifiable <code>Map</code>.
+ * @deprecated Use containsField(String) and getField(String) instead.
*/
public Map getFieldMap() {
return Collections.unmodifiableMap(hFields);
+ }
+
+ /**
+ * Returns the Field with the given name or null if this Form has no such field
+ */
+ public Field getField(String fieldName) {
+ return (Field) this.hFields.get(fieldName);
+ }
+
+ /**
+ * Returns true if this Form contains a Field with the given name.
+ */
+ public boolean containsField(String fieldName){
+ return this.hFields.containsKey(fieldName);
}
/**
1.12 +5 -5
jakarta-commons/validator/src/example/org/apache/commons/validator/example/ValidateExample.java
Index: ValidateExample.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/validator/src/example/org/apache/commons/validator/example/ValidateExample.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ValidateExample.java 28 May 2003 04:28:01 -0000 1.11
+++ ValidateExample.java 29 May 2003 03:34:35 -0000 1.12
@@ -188,7 +188,7 @@
String propertyName = (String) propertyNames.next();
// Get the Field associated with that property in the Form
- Field field = (Field) form.getFieldMap().get(propertyName);
+ Field field = form.getField(propertyName);
// Look up the formatted name of the field from the Field arg0
String prettyFieldName = apps.getString(field.getArg(0).getKey());
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]