cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: r279430 - /cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/
Date Wed, 07 Sep 2005 21:32:46 GMT
Author: pier
Date: Wed Sep  7 14:32:38 2005
New Revision: 279430

URL: http://svn.apache.org/viewcvs?rev=279430&view=rev
Log:
Refactoring close to final implementation

Added:
    cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesContentHandler.java
      - copied, changed from r279423, cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesValidationHandler.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesContext.java
      - copied, changed from r279423, cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesComponentManager.java
Removed:
    cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesComponentManager.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesValidationHandler.java
Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesGrammarParser.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesSchema.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesSchemaParser.java

Copied: cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesContentHandler.java
(from r279423, cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesValidationHandler.java)
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesContentHandler.java?p2=cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesContentHandler.java&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesValidationHandler.java&r1=279423&r2=279430&rev=279430&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesValidationHandler.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesContentHandler.java
Wed Sep  7 14:32:38 2005
@@ -30,17 +30,21 @@
 import org.xml.sax.SAXException;
 
 /**
- * <p>TODO: ...</p>
+ * <p>An implementation of the {@link ContentHandler} interface wrapping around
+ * a Xerces {@link XMLDocumentHandler} instance.</p>
  *
  * @author <a href="mailto:pier@betaversion.org">Pier Fumagalli</a>
  */
-public class XercesValidationHandler implements ContentHandler {
+public class XercesContentHandler implements ContentHandler {
     
     private final XMLDocumentHandler validationHandler;
     private final NamespaceContext namespaceContext = new NamespaceSupport();
     private final SAXLocatorWrapper locator = new SAXLocatorWrapper();
 
-    public XercesValidationHandler(XMLDocumentHandler validationHandler) {
+    /**
+     * <p>Create a new {@link XercesContentHandler} instance.</p>
+     */
+    public XercesContentHandler(XMLDocumentHandler validationHandler) {
         this.validationHandler = validationHandler;
     }
 

Copied: cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesContext.java
(from r279423, cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesComponentManager.java)
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesContext.java?p2=cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesContext.java&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesComponentManager.java&r1=279423&r2=279430&rev=279430&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesComponentManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesContext.java
Wed Sep  7 14:32:38 2005
@@ -38,12 +38,12 @@
 
 
 /**
- * <p>An implementation of Xerces' {@link XMLComponentManager} interface
- * allowing interoperation of components while parsing or validatin.</p>
+ * <p>An implementation of Xerces {@link XMLComponentManager} interface allowing
+ * interoperation of components while parsing or validating.</p>
  *
  * @author <a href="mailto:pier@betaversion.org">Pier Fumagalli</a>
  */
-public class XercesComponentManager extends ParserConfigurationSettings {
+public class XercesContext extends ParserConfigurationSettings {
 
     private static final String P_ENTITY_MANAGER =        
             Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;
@@ -89,15 +89,19 @@
                 F_PARSER_SETTINGS
             };
 
-    public XercesComponentManager(XMLGrammarPool grammarPool,
-                                  XMLEntityResolver entityResolver) {
-        this(grammarPool, entityResolver, null);
+    /**
+     * <p>Create a new {@link XercesContext} instance.</p>
+     */
+    public XercesContext(XMLGrammarPool grammar, XMLEntityResolver resolver) {
+        this(grammar, resolver, null);
     }
 
-    public XercesComponentManager(XMLGrammarPool grammarPool,
-                                  XMLEntityResolver entityResolver,
-                                  final ErrorHandler errorHandler) {
-
+    /**
+     * <p>Create a new {@link XercesContext} instance specifying the SAX
+     * {@link ErrorHandler} handling errors.</p>
+     */
+    public XercesContext(XMLGrammarPool grammar, XMLEntityResolver resolver,
+                         ErrorHandler errorHandler) {
         super.addRecognizedFeatures(FEATURES);
         super.addRecognizedProperties(PROPERTIES);
         
@@ -110,8 +114,8 @@
                                           new XMLMessageFormatter());
         XMLErrorHandler xercesHandler = new ErrorHandlerWrapper(errorHandler);
 
-        super.setProperty(P_XMLGRAMMAR_POOL,    grammarPool);
-        super.setProperty(P_ENTITY_RESOLVER,    entityResolver);
+        super.setProperty(P_XMLGRAMMAR_POOL,    grammar);
+        super.setProperty(P_ENTITY_RESOLVER,    resolver);
         super.setProperty(P_ERROR_REPORTER,     errorReporter);
         super.setProperty(P_ERROR_HANDLER,      xercesHandler);
 

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesGrammarParser.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesGrammarParser.java?rev=279430&r1=279429&r2=279430&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesGrammarParser.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesGrammarParser.java
Wed Sep  7 14:32:38 2005
@@ -20,7 +20,6 @@
 import org.apache.cocoon.components.validation.Schema;
 import org.apache.cocoon.components.validation.SchemaParser;
 import org.apache.excalibur.source.SourceValidity;
-import org.apache.xerces.impl.Constants;
 import org.apache.xerces.util.XMLGrammarPoolImpl;
 import org.apache.xerces.xni.grammars.XMLGrammarLoader;
 import org.apache.xerces.xni.grammars.XMLGrammarPool;
@@ -36,9 +35,6 @@
 public abstract class XercesGrammarParser extends CachingSchemaParser 
 implements SchemaParser {
 
-    private static final String P_XML_GRAMMAR_POOL =
-            Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
-
     /**
      * <p>Create a new {@link XercesGrammarParser} instance.</p>
      */
@@ -61,18 +57,18 @@
         XercesEntityResolver resolver = new XercesEntityResolver();
 
         /* Create a Xerces component manager contextualizing the loader */
-        XercesComponentManager manager = new XercesComponentManager(pool, resolver);
+        XercesContext context = new XercesContext(pool, resolver);
 
         /* Create a new XML Schema Loader and set the pool into it */
         XMLGrammarLoader loader = this.newGrammarLoader();
-        ((XMLComponent) loader).reset(manager);
+        ((XMLComponent) loader).reset(context);
 
         /* Load (parse and interpret) the grammar */
         loader.loadGrammar(resolver.resolveEntity(uri));
         
         /* Return a new Schema instance */
         SourceValidity validity = resolver.getSourceValidity();
-        Class validator = this.getValidationHandler();
+        Class validator = this.getValidationHandlerClass();
         return new XercesSchema(pool, validity, resolver, validator);
     }
 
@@ -85,6 +81,6 @@
     /**
      * <p>Return the {@link Class} that will implement the validator handler.</p>
      */
-    protected abstract Class getValidationHandler(); 
+    protected abstract Class getValidationHandlerClass(); 
 
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesSchema.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesSchema.java?rev=279430&r1=279429&r2=279430&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesSchema.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesSchema.java
Wed Sep  7 14:32:38 2005
@@ -24,7 +24,7 @@
 import org.xml.sax.SAXException;
 
 /**
- * <p>TODO: ...</p>
+ * <p>A wrapper around a schema parsed by Xerces.</p>
  *
  * @author <a href="mailto:pier@betaversion.org">Pier Fumagalli</a>
  */
@@ -34,6 +34,9 @@
     private final XMLGrammarPool grammarPool;
     private final Class validatorClass;
 
+    /**
+     * <p>Create a new {@link XercesSchema} instance.</p>
+     */
     public XercesSchema(XMLGrammarPool grammarPool, SourceValidity sourceValidity,
                         XercesEntityResolver entityResolver, Class validatorClass) {
         super(sourceValidity);
@@ -43,13 +46,23 @@
         this.grammarPool = grammarPool;
     }
 
+    /**
+     * <p>Return a {@link ContentHandler} able to receive SAX events and performing
+     * validation according to the schema wrapped by this instance.</p>
+     *
+     * @param errorHandler {@link ErrorHandler} to be notified of validation errors.
+     * @return a <b>non-null</b> {@link ContentHandler} instance.
+     * @throws SAXException if an error occurred creating the {@link ContentHandler}.
+     */
     public ContentHandler newValidator(ErrorHandler errorHandler)
     throws SAXException {
-        XercesComponentManager manager = new XercesComponentManager(this.grammarPool, entityResolver,
errorHandler);
+        XercesContext context = new XercesContext(this.grammarPool,
+                                                  this.entityResolver,
+                                                  errorHandler);
         try {
-            Object instance = validatorClass.newInstance();
-            ((XMLComponent) instance).reset(manager);
-            return new XercesValidationHandler((XMLDocumentHandler) instance);
+            Object instance = this.validatorClass.newInstance();
+            ((XMLComponent) instance).reset(context);
+            return new XercesContentHandler((XMLDocumentHandler) instance);
         } catch (Exception exception) {
             throw new SAXException("Unable to access validator", exception);
         }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesSchemaParser.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesSchemaParser.java?rev=279430&r1=279429&r2=279430&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesSchemaParser.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/validation/java/org/apache/cocoon/components/validation/impl/XercesSchemaParser.java
Wed Sep  7 14:32:38 2005
@@ -54,13 +54,19 @@
         return GRAMMARS;
     }
 
+    /**
+     * <p>Return a {@link XMLGrammarLoader} for the XML Schema grammar.</p>
+     */
     protected XMLGrammarLoader newGrammarLoader() {
         XMLSchemaLoader loader = new XMLSchemaLoader();
         loader.setFeature(F_SCHEMA_FULL_CHECK, true);
         return loader;
     }
 
-    protected Class getValidationHandler() {
+    /**
+     * <p>Return a {@link Class} implementing the final validation handler.</p>
+     */
+    protected Class getValidationHandlerClass() {
         return VALIDATOR;
     }
 }



Mime
View raw message