commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tur...@apache.org
Subject cvs commit: jakarta-commons/validator/src/share/org/apache/commons/validator ValidatorResourcesInitializer.java
Date Wed, 16 Oct 2002 23:00:21 GMT
turner      2002/10/16 16:00:21

  Modified:    validator/src/share/org/apache/commons/validator
                        ValidatorResourcesInitializer.java
  Log:
  Added registration of Commons Validator DTD (fixed bug 13030)
  
  Revision  Changes    Path
  1.8       +26 -5     jakarta-commons/validator/src/share/org/apache/commons/validator/ValidatorResourcesInitializer.java
  
  Index: ValidatorResourcesInitializer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/ValidatorResourcesInitializer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ValidatorResourcesInitializer.java	12 Oct 2002 18:28:05 -0000	1.7
  +++ ValidatorResourcesInitializer.java	16 Oct 2002 23:00:21 -0000	1.8
  @@ -66,6 +66,7 @@
   import java.io.FileInputStream;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.net.URL;
   import org.apache.commons.digester.Digester;
   import org.xml.sax.SAXException;
   import org.apache.commons.logging.Log;
  @@ -76,6 +77,7 @@
    * <p>Maps an xml file to <code>ValidatorResources</code>.</p>
    *
    * @author David Winterfeldt
  + * @author Dave Derry
    * @version $Revision$ $Date$
   */
   public class ValidatorResourcesInitializer {
  @@ -85,6 +87,18 @@
      */
      protected static Log log = LogSource.getInstance(ValidatorResourcesInitializer.class.getName());
      
  +
  +    /**
  +     * The set of public identifiers, and corresponding resource names, for
  +     * the versions of the configuration file DTDs that we know about.  There
  +     * <strong>MUST</strong> be an even number of Strings in this list!
  +     */
  +    protected static String registrations[] = {
  +        "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN",
  +	"/org/apache/commons/resources/validator_1_0.dtd"
  +   };
  +
  +
      /**
       * Initializes a <code>ValidatorResources</code> based on a
       * file path and automatically process the resources.
  @@ -141,6 +155,13 @@
         digester.push(resources);
         digester.setNamespaceAware(true);
         digester.setValidating(false);
  +      // register DTDs
  +      for (int i = 0; i < registrations.length; i += 2) {
  +          URL url = ValidatorResourcesInitializer.class.getResource(registrations[i+1]);
  +          if (url != null)
  +              digester.register(registrations[i], url.toString());
  +      }
  +      
         digester.setUseContextClassLoader(true);
         
         // Create Global Constant objects
  @@ -247,4 +268,4 @@
    
      }
      
  -}
  \ No newline at end of file
  +}
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message