You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2002/06/24 18:56:56 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/validator ValidatorPlugIn.java ValidatorForm.java ValidatorActionForm.java DynaValidatorForm.java DynaValidatorActionForm.java

husted      2002/06/24 09:56:56

  Modified:    src/share/org/apache/struts/validator ValidatorPlugIn.java
                        ValidatorForm.java ValidatorActionForm.java
                        DynaValidatorForm.java DynaValidatorActionForm.java
  Log:
  Conform @since Struts 1.1 JavaDocs.
  
  Revision  Changes    Path
  1.4       +35 -35    jakarta-struts/src/share/org/apache/struts/validator/ValidatorPlugIn.java
  
  Index: ValidatorPlugIn.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/validator/ValidatorPlugIn.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ValidatorPlugIn.java	1 Apr 2002 02:22:08 -0000	1.3
  +++ ValidatorPlugIn.java	24 Jun 2002 16:56:56 -0000	1.4
  @@ -84,12 +84,12 @@
   
   
   /**
  - * <p>Loads <code>ValidatorResources</code> based on 
  + * <p>Loads <code>ValidatorResources</code> based on
    * configuration in the struts-config.xml.</p>
    *
    * @author David Winterfeldt
    * @version $Revision$ $Date$
  - * @since 1.1
  + * @since Struts 1.1
   */
   public class ValidatorPlugIn implements PlugIn {
   
  @@ -113,7 +113,7 @@
        * Delimitter for Validator resources.
       */
       private final static String RESOURCE_DELIM = ",";
  -    
  +
       /**
        * Application scope key that <code>ValidatorResources</code> is stored under.
       */
  @@ -131,7 +131,7 @@
       /**
        * A comma delimitted list of Validator resource.
        */
  -    private String pathnames = null; 
  +    private String pathnames = null;
   
       /**
        * Gets a comma delimitted list of Validator resource.
  @@ -162,15 +162,15 @@
           this.config = config;
           this.servlet = servlet;
   
  -	// Load our database from persistent storage
  -	try {
  -	    initResources();
  -	    servlet.getServletContext().setAttribute(VALIDATOR_KEY, resources);
  -	} catch (Exception e) {
  -	    log.error(e.getMessage(), e);
  -	    throw new UnavailableException
  -		("Cannot load a validator resource from '" + pathnames + "'");
  -	}
  +    // Load our database from persistent storage
  +    try {
  +        initResources();
  +        servlet.getServletContext().setAttribute(VALIDATOR_KEY, resources);
  +    } catch (Exception e) {
  +        log.error(e.getMessage(), e);
  +        throw new UnavailableException
  +        ("Cannot load a validator resource from '" + pathnames + "'");
  +    }
   
       }
   
  @@ -179,14 +179,14 @@
        * that were allocated at initialization.
       */
       public void destroy() {
  -	
  -	if (log.isDebugEnabled()) {
  -	    log.debug("Destroying ValidatorPlugin");
  -	}
  +
  +    if (log.isDebugEnabled()) {
  +        log.debug("Destroying ValidatorPlugin");
  +    }
   
           servlet = null;
           config = null;
  -        
  +
           destroyResources();
       }
   
  @@ -201,35 +201,35 @@
   
          if (pathnames != null && pathnames.length() > 0) {
             StringTokenizer st = new StringTokenizer(pathnames, RESOURCE_DELIM);
  -          
  +
             while (st.hasMoreTokens()) {
                String validatorRules = st.nextToken();
  -             
  +
                validatorRules = validatorRules.trim();
  -        
  -	     if (log.isInfoEnabled()) {
  -	        log.info("Loading validation rules file from '" + validatorRules + "'");
  -	     }          
  -	     
  +
  +         if (log.isInfoEnabled()) {
  +            log.info("Loading validation rules file from '" + validatorRules + "'");
  +         }
  +
                InputStream input = null;
                BufferedInputStream bis = null;
                input = servlet.getServletContext().getResourceAsStream(validatorRules);
  -             
  +
                if (input != null) {
                   bis = new BufferedInputStream(input);
  -             
  +
                   try {
  -                   // pass in false so resources aren't processed 
  +                   // pass in false so resources aren't processed
                      // until last file is loaded
                      ValidatorResourcesInitializer.initialize(resources, bis, false);
                   } catch (Exception e) {
                      log.error(e.getMessage(), e);
                   }
                } else {
  -                log.error("Skipping validation rules file from '" + validatorRules + "'.  No stream could be opened.");	
  +                log.error("Skipping validation rules file from '" + validatorRules + "'.  No stream could be opened.");
                }
             }
  -          
  +
             // process resources
             resources.process();
          }
  @@ -239,7 +239,7 @@
        * Destroy <code>ValidatorResources</code>.
       */
       protected void destroyResources() {
  -	resources = null;
  +    resources = null;
       }
   
   }
  
  
  
  1.3       +40 -40    jakarta-struts/src/share/org/apache/struts/validator/ValidatorForm.java
  
  Index: ValidatorForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/validator/ValidatorForm.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ValidatorForm.java	2 Apr 2002 04:02:13 -0000	1.2
  +++ ValidatorForm.java	24 Jun 2002 16:56:56 -0000	1.3
  @@ -57,8 +57,8 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  - 
  - 
  +
  +
   package org.apache.struts.validator;
   
   import java.io.Serializable;
  @@ -79,18 +79,18 @@
   
   
   /**
  - * <p>This class extends <strong>ActionForm</strong> and provides 
  - * basic field validation based on an XML file.  The key passed into the 
  - * validator is the action element's 'name' attribute from the 
  - * struts-config.xml which should match the form element's name attribute 
  + * <p>This class extends <strong>ActionForm</strong> and provides
  + * basic field validation based on an XML file.  The key passed into the
  + * validator is the action element's 'name' attribute from the
  + * struts-config.xml which should match the form element's name attribute
    * in the validation.xml.</p>
    *
  - * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml 
  + * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml
    * for validation rules.</li></ul>
    *
    * @author David Winterfeldt
    * @version $Revision$ $Date$
  - * @since 1.1
  + * @since Struts 1.1
    * @see org.apache.struts.action.ActionForm
   */
   public class ValidatorForm extends ActionForm implements Serializable {
  @@ -101,7 +101,7 @@
       private Log log = LogSource.getInstance(this.getClass().getName());
   
       /**
  -     * The results returned from the validation performed 
  +     * The results returned from the validation performed
        * by the <code>Validator</code>.
       */
       protected ValidatorResults validatorResults = null;
  @@ -115,14 +115,14 @@
        * Gets page.
       */
       public int getPage() {
  -       return page;	
  +       return page;
       }
   
       /**
        * Sets page.
       */
       public void setPage(int page) {
  -       this.page = page;	
  +       this.page = page;
       }
   
       /**
  @@ -139,28 +139,28 @@
                                    HttpServletRequest request) {
   
           ServletContext application = getServlet().getServletContext();
  -        ActionErrors errors = new ActionErrors();	
  -        
  -	Validator validator = StrutsValidatorUtil.initValidator(mapping.getAttribute(), 
  -	                                                        this,
  -	                                                        application, request, 
  -	                                                        errors, page);
  -	
  -	try {
  -	   validatorResults = validator.validate();
  +        ActionErrors errors = new ActionErrors();
  +
  +    Validator validator = StrutsValidatorUtil.initValidator(mapping.getAttribute(),
  +                                                            this,
  +                                                            application, request,
  +                                                            errors, page);
  +
  +    try {
  +       validatorResults = validator.validate();
           } catch (ValidatorException e) {
  -	   log.error(e.getMessage(), e);
  -	}
  +       log.error(e.getMessage(), e);
  +    }
   
           return errors;
       }
   
       /**
  -     * Convenience method that call the comparable servlet log method and writes 
  -     * an explanatory message and a stack trace for a given Throwable exception to the 
  +     * Convenience method that call the comparable servlet log method and writes
  +     * an explanatory message and a stack trace for a given Throwable exception to the
        * servlet log file.
        *
  -     * @param 	message		String that describes the error or exception
  +     * @param   message     String that describes the error or exception
       */
       protected void log(String message) {
          if (getServlet().getDebug() >= 1) {
  @@ -169,12 +169,12 @@
       }
   
       /**
  -     * Convenience method that call the comparable servlet log method and writes 
  -     * an explanatory message and a stack trace for a given Throwable exception to the 
  +     * Convenience method that call the comparable servlet log method and writes
  +     * an explanatory message and a stack trace for a given Throwable exception to the
        * servlet log file.
        *
  -     * @param 	message		String that describes the error or exception
  -     * @param 	throwable	Throwable error or exception
  +     * @param   message     String that describes the error or exception
  +     * @param   throwable   Throwable error or exception
       */
       protected void log(String message, Throwable throwable) {
          if (getServlet().getDebug() >= 1) {
  @@ -195,29 +195,29 @@
       }
   
       /**
  -     * Get results of the validation performed by the 
  +     * Get results of the validation performed by the
        * <code>Validator</code>.
       */
       public ValidatorResults getValidatorResults() {
  -       return validatorResults;	
  +       return validatorResults;
       }
   
       /**
  -     * Set results of the validation performed by the 
  +     * Set results of the validation performed by the
        * <code>Validator</code>.
       */
       public void setValidatorResults(ValidatorResults validatorResults) {
  -       this.validatorResults = validatorResults;	
  +       this.validatorResults = validatorResults;
       }
   
       /**
  -     * Returns a <code>Map</code> of values returned 
  -     * from any validation that returns a value other than 
  -     * <code>null</code> or <code>Boolean</code> with the 
  +     * Returns a <code>Map</code> of values returned
  +     * from any validation that returns a value other than
  +     * <code>null</code> or <code>Boolean</code> with the
        * key the full property path of the field.
       */
       public Map getResultValueMap() {
          return (validatorResults != null ? validatorResults.getResultValueMap() : null);
       }
  -    
  +
   }
  
  
  
  1.3       +22 -22    jakarta-struts/src/share/org/apache/struts/validator/ValidatorActionForm.java
  
  Index: ValidatorActionForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/validator/ValidatorActionForm.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ValidatorActionForm.java	2 Apr 2002 04:02:13 -0000	1.2
  +++ ValidatorActionForm.java	24 Jun 2002 16:56:56 -0000	1.3
  @@ -57,8 +57,8 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  - 
  - 
  +
  +
   package org.apache.struts.validator;
   
   import java.io.Serializable;
  @@ -77,18 +77,18 @@
   
   
   /**
  - * <p>This class extends <strong>ValidatorForm</strong> and provides 
  - * basic field validation based on an XML file.  The key passed into the 
  - * validator is the action element's 'path' attribute from the 
  - * struts-config.xml which should match the form element's name attribute 
  + * <p>This class extends <strong>ValidatorForm</strong> and provides
  + * basic field validation based on an XML file.  The key passed into the
  + * validator is the action element's 'path' attribute from the
  + * struts-config.xml which should match the form element's name attribute
    * in the validation.xml.</p>
    *
  - * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml 
  + * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml
    * for validation rules.</li></ul>
    *
    * @author David Winterfeldt
    * @version $Revision$ $Date$
  - * @since 1.1
  + * @since Struts 1.1
   */
   
   public class ValidatorActionForm extends ValidatorForm implements Serializable {
  @@ -112,18 +112,18 @@
                                    HttpServletRequest request) {
   
           ServletContext application = getServlet().getServletContext();
  -        ActionErrors errors = new ActionErrors();	
  -        
  -	Validator validator = StrutsValidatorUtil.initValidator(mapping.getPath(), 
  -	                                                        this,
  -	                                                        application, request, 
  -	                                                        errors, page);
  -	
  -	try {
  -	   validatorResults = validator.validate();
  +        ActionErrors errors = new ActionErrors();
  +
  +    Validator validator = StrutsValidatorUtil.initValidator(mapping.getPath(),
  +                                                            this,
  +                                                            application, request,
  +                                                            errors, page);
  +
  +    try {
  +       validatorResults = validator.validate();
           } catch (ValidatorException e) {
  -	   log.error(e.getMessage(), e);
  -	}
  +       log.error(e.getMessage(), e);
  +    }
   
           return errors;
       }
  
  
  
  1.3       +39 -39    jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorForm.java
  
  Index: DynaValidatorForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorForm.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DynaValidatorForm.java	2 Apr 2002 04:02:13 -0000	1.2
  +++ DynaValidatorForm.java	24 Jun 2002 16:56:56 -0000	1.3
  @@ -57,8 +57,8 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  - 
  - 
  +
  +
   package org.apache.struts.validator;
   
   import java.io.Serializable;
  @@ -80,18 +80,18 @@
   
   
   /**
  - * <p>This class extends <strong>DynaActionForm</strong> and provides 
  - * basic field validation based on an XML file.  The key passed into the 
  - * validator is the action element's 'name' attribute from the 
  - * struts-config.xml which should match the form element's name attribute 
  + * <p>This class extends <strong>DynaActionForm</strong> and provides
  + * basic field validation based on an XML file.  The key passed into the
  + * validator is the action element's 'name' attribute from the
  + * struts-config.xml which should match the form element's name attribute
    * in the validation.xml.</p>
    *
  - * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml 
  + * <ul><li>See <code>ValidatorPlugin</code> definition in struts-config.xml
    * for validation rules.</li></ul>
    *
    * @author David Winterfeldt
    * @version $Revision$ $Date$
  - * @since 1.1
  + * @since Struts 1.1
    * @see org.apache.struts.action.ActionForm
   */
   
  @@ -103,7 +103,7 @@
       private Log log = LogSource.getInstance(this.getClass().getName());
   
       /**
  -     * The results returned from the validation performed 
  +     * The results returned from the validation performed
        * by the <code>Validator</code>.
       */
       protected ValidatorResults validatorResults = null;
  @@ -117,14 +117,14 @@
        * Gets page.
       */
       public int getPage() {
  -       return page;	
  +       return page;
       }
   
       /**
        * Sets page.
       */
       public void setPage(int page) {
  -       this.page = page;	
  +       this.page = page;
       }
   
       /**
  @@ -141,28 +141,28 @@
                                    HttpServletRequest request) {
   
           ServletContext application = getServlet().getServletContext();
  -        ActionErrors errors = new ActionErrors();	
  -        
  -	Validator validator = StrutsValidatorUtil.initValidator(mapping.getAttribute(), 
  -	                                                        this,
  -	                                                        application, request, 
  -	                                                        errors, page);
  -	
  -	try {
  -	   validatorResults = validator.validate();
  +        ActionErrors errors = new ActionErrors();
  +
  +    Validator validator = StrutsValidatorUtil.initValidator(mapping.getAttribute(),
  +                                                            this,
  +                                                            application, request,
  +                                                            errors, page);
  +
  +    try {
  +       validatorResults = validator.validate();
           } catch (ValidatorException e) {
  -	   log.error(e.getMessage(), e);
  -	}
  +       log.error(e.getMessage(), e);
  +    }
   
           return errors;
       }
   
       /**
  -     * Convenience method that call the comparable servlet log method and writes 
  -     * an explanatory message and a stack trace for a given Throwable exception to the 
  +     * Convenience method that call the comparable servlet log method and writes
  +     * an explanatory message and a stack trace for a given Throwable exception to the
        * servlet log file.
        *
  -     * @param 	message		String that describes the error or exception
  +     * @param   message     String that describes the error or exception
       */
       protected void log(String message) {
          if (getServlet().getDebug() >= 1) {
  @@ -171,12 +171,12 @@
       }
   
       /**
  -     * Convenience method that call the comparable servlet log method and writes 
  -     * an explanatory message and a stack trace for a given Throwable exception to the 
  +     * Convenience method that call the comparable servlet log method and writes
  +     * an explanatory message and a stack trace for a given Throwable exception to the
        * servlet log file.
        *
  -     * @param 	message		String that describes the error or exception
  -     * @param 	throwable	Throwable error or exception
  +     * @param   message     String that describes the error or exception
  +     * @param   throwable   Throwable error or exception
       */
       protected void log(String message, Throwable throwable) {
          if (getServlet().getDebug() >= 1) {
  @@ -197,25 +197,25 @@
       }
   
       /**
  -     * Get results of the validation performed by the 
  +     * Get results of the validation performed by the
        * <code>Validator</code>.
       */
       public ValidatorResults getValidatorResults() {
  -       return validatorResults;	
  +       return validatorResults;
       }
   
       /**
  -     * Set results of the validation performed by the 
  +     * Set results of the validation performed by the
        * <code>Validator</code>.
       */
       public void setValidatorResults(ValidatorResults validatorResults) {
  -       this.validatorResults = validatorResults;	
  +       this.validatorResults = validatorResults;
       }
   
       /**
  -     * Returns a <code>Map</code> of values returned 
  -     * from any validation that returns a value other than 
  -     * <code>null</code> or <code>Boolean</code> with the  
  +     * Returns a <code>Map</code> of values returned
  +     * from any validation that returns a value other than
  +     * <code>null</code> or <code>Boolean</code> with the
        * key the full property path of the field.
       */
       public Map getResultValueMap() {
  
  
  
  1.4       +13 -13    jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorActionForm.java
  
  Index: DynaValidatorActionForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/validator/DynaValidatorActionForm.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DynaValidatorActionForm.java	2 Apr 2002 04:02:13 -0000	1.3
  +++ DynaValidatorActionForm.java	24 Jun 2002 16:56:56 -0000	1.4
  @@ -89,7 +89,7 @@
    *
    * @author David Winterfeldt
    * @version $Revision$ $Date$
  - * @since 1.1
  + * @since Struts 1.1
   */
   
   public class DynaValidatorActionForm extends DynaValidatorForm implements DynaBean, Serializable {
  @@ -115,16 +115,16 @@
           ServletContext application = getServlet().getServletContext();
           ActionErrors errors = new ActionErrors();
   
  -	Validator validator = StrutsValidatorUtil.initValidator(mapping.getPath(),
  -	                                                        this,
  -	                                                        application, request,
  -	                                                        errors, page);
  +    Validator validator = StrutsValidatorUtil.initValidator(mapping.getPath(),
  +                                                            this,
  +                                                            application, request,
  +                                                            errors, page);
   
  -	try {
  -	   validatorResults = validator.validate();
  +    try {
  +       validatorResults = validator.validate();
           } catch (ValidatorException e) {
  -	   log.error(e.getMessage(), e);
  -	}
  +       log.error(e.getMessage(), e);
  +    }
   
           return errors;
       }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>