Commits

Anonymous committed 1636960

Javadoc improvements

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@350e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (1)

src/java/com/opensymphony/xwork/validator/DelegatingValidatorContext.java

 
 
 /**
- * Provides a default implementation of ValidatorContext.
+ * A default implementation of the {@link ValidatorContext} interface.
  *
  * @author Jason Carreira
  */
 public class DelegatingValidatorContext implements ValidatorContext {
-    //~ Instance fields ////////////////////////////////////////////////////////
 
     private LocaleProvider localeProvider;
     private TextProvider textProvider;
     private ValidationAware validationAware;
 
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    public DelegatingValidatorContext(ValidationAware validationAware, TextProvider textProvider, LocaleProvider localeProvider) {
+    /**
+     * Creates a new validation context given a ValidationAware object, and a text and locale provider. These objects
+     * are used internally to set errors and get and set error text.
+     */
+    public DelegatingValidatorContext(ValidationAware validationAware, TextProvider textProvider,
+            LocaleProvider localeProvider)
+    {
         this.textProvider = textProvider;
         this.validationAware = validationAware;
         this.localeProvider = localeProvider;
     }
 
+    /**
+     * Creates a new validation context given an object - usually an Action. The internal objects
+     * (validation aware instance and a locale and text provider) are created based on the given action.
+     *
+     * @param object the object to use for validation (usually an Action).
+     */
     public DelegatingValidatorContext(Object object) {
         this.localeProvider = makeLocaleProvider(object);
         this.validationAware = makeValidationAware(object);
         this.textProvider = makeTextProvider(object, localeProvider);
     }
 
+    /**
+     * Create a new validation context given a Class definition. The locale provider, text provider and
+     * the validation context are created based on the class.
+     *
+     * @param clazz the class to initialize the context with.
+     */
     public DelegatingValidatorContext(Class clazz) {
         localeProvider = new ActionContextLocaleProvider();
         textProvider = new TextProviderSupport(clazz, localeProvider);
         validationAware = new LoggingValidationAware(clazz);
     }
 
-    //~ Methods ////////////////////////////////////////////////////////////////
-
     public void setActionErrors(Collection errorMessages) {
         validationAware.setActionErrors(errorMessages);
     }
         return validationAware.getActionErrors();
     }
 
-    /**
-     * Set the Collection of Action level String messages (not errors)
-     */
     public void setActionMessages(Collection messages) {
         validationAware.setActionMessages(messages);
     }
 
-    /**
-     * Get the Collection of Action level messages for this action. Messages should not be added
-     * directly here, as implementations are free to return a new Collection or an Unmodifiable
-     * Collection.
-     *
-     * @return Collection of String messages
-     */
     public Collection getActionMessages() {
         return validationAware.getActionMessages();
     }
         return validationAware.getFieldErrors();
     }
 
-    /**
-     * Translates a simple field name into a full field name in Ognl syntax
-     * @param fieldName
-     * @return
-     */
     public String getFullFieldName(String fieldName) {
         return fieldName;
     }
         validationAware.addActionError(anErrorMessage);
     }
 
-    /**
-     * Add an Action level message to this Action
-     */
     public void addActionMessage(String aMessage) {
         validationAware.addActionMessage(aMessage);
     }
         return validationAware.hasActionErrors();
     }
 
-    /**
-     * Checks whether there are any Action-level messages.
-     *
-     * @return true if any Action-level messages have been registered
-     */
     public boolean hasActionMessages() {
         return validationAware.hasActionMessages();
     }
         return validationAware;
     }
 
-    //~ Inner Classes //////////////////////////////////////////////////////////
-
+    /**
+     * An implementation of LocaleProvider which gets the locale from the action context.
+     */
     private static class ActionContextLocaleProvider implements LocaleProvider {
         public Locale getLocale() {
             return ActionContext.getContext().getLocale();
         }
     }
 
+    /**
+     * An implementation of ValidationAware which logs errors and messages. 
+     */
     private static class LoggingValidationAware implements ValidationAware {
+
         private Log log;
 
         public LoggingValidationAware(Class clazz) {
         }
 
         public void setActionErrors(Collection errorMessages) {
-            for (Iterator iterator = errorMessages.iterator();
-                    iterator.hasNext();) {
+            for (Iterator iterator = errorMessages.iterator(); iterator.hasNext();) {
                 String s = (String) iterator.next();
                 addActionError(s);
             }
             return null;
         }
 
-        /**
-         * Set the Collection of Action level String messages (not errors)
-         */
         public void setActionMessages(Collection messages) {
             for (Iterator iterator = messages.iterator(); iterator.hasNext();) {
                 String s = (String) iterator.next();
             }
         }
 
-        /**
-         * Get the Collection of Action level messages for this action. Messages should not be added
-         * directly here, as implementations are free to return a new Collection or an Unmodifiable
-         * Collection.
-         *
-         * @return Collection of String messages
-         */
         public Collection getActionMessages() {
             return null;
         }
 
         public void setFieldErrors(Map errorMap) {
-            for (Iterator iterator = errorMap.entrySet().iterator();
-                    iterator.hasNext();) {
+            for (Iterator iterator = errorMap.entrySet().iterator(); iterator.hasNext();) {
                 Map.Entry entry = (Map.Entry) iterator.next();
                 addFieldError((String) entry.getKey(), (String) entry.getValue());
             }
             log.error("Validation error: " + anErrorMessage);
         }
 
-        /**
-         * Add an Action level message to this Action
-         */
         public void addActionMessage(String aMessage) {
             log.info("Validation Message: " + aMessage);
         }
             return false;
         }
 
-        /**
-         * Checks whether there are any Action-level messages.
-         *
-         * @return true if any Action-level messages have been registered
-         */
         public boolean hasActionMessages() {
             return false;
         }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.