commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1197908 - in /commons/proper/digester/trunk: RELEASE-NOTES.txt src/changes/changes.xml src/main/java/org/apache/commons/digester3/binder/DigesterLoader.java src/test/java/org/apache/commons/digester3/binder/DigesterLoaderTestCase.java
Date Sat, 05 Nov 2011 09:28:51 GMT
Author: simonetripodi
Date: Sat Nov  5 09:28:51 2011
New Revision: 1197908

URL: http://svn.apache.org/viewvc?rev=1197908&view=rev
Log:
[DIGESTER-152] The org.apache.commons.digester3.binder.DigesterLoader doesn't allow binding
a default org.xml.sax.Locator

Modified:
    commons/proper/digester/trunk/RELEASE-NOTES.txt
    commons/proper/digester/trunk/src/changes/changes.xml
    commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/DigesterLoader.java
    commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/binder/DigesterLoaderTestCase.java

Modified: commons/proper/digester/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/RELEASE-NOTES.txt?rev=1197908&r1=1197907&r2=1197908&view=diff
==============================================================================
--- commons/proper/digester/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/digester/trunk/RELEASE-NOTES.txt Sat Nov  5 09:28:51 2011
@@ -60,6 +60,7 @@ BUGS FROM PREVIOUS RELEASE
 IMPROVEMENTS OVER PREVIOUS RELEASE
 ===================================
 
+ * [DIGESTER-152] The DigesterLoader doesn't allow binding a default Locator
  * [DIGESTER-151] The DigesterLoader doesn't allow binding a default ErrorHandler.
 
 DEPRECATIONS

Modified: commons/proper/digester/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/changes/changes.xml?rev=1197908&r1=1197907&r2=1197908&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/changes/changes.xml (original)
+++ commons/proper/digester/trunk/src/changes/changes.xml Sat Nov  5 09:28:51 2011
@@ -26,6 +26,9 @@
     <action dev="simonetripodi" type="add" issue="DIGESTER-153">
       Add Constructor support to ObjectCreateRule
     </action>
+    <action dev="simonetripodi" type="add" issue="DIGESTER-152">
+      The org.apache.commons.digester3.binder.DigesterLoader doesn't allow binding a default
org.xml.sax.Locator
+    </action>
     <action dev="simonetripodi" type="add" issue="DIGESTER-151">
       The org.apache.commons.digester3.binder.DigesterLoader doesn't allow binding a default
org.xml.sax.ErrorHandler.
     </action>

Modified: commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/DigesterLoader.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/DigesterLoader.java?rev=1197908&r1=1197907&r2=1197908&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/DigesterLoader.java
(original)
+++ commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/DigesterLoader.java
Sat Nov  5 09:28:51 2011
@@ -43,6 +43,7 @@ import org.apache.commons.digester3.Stac
 import org.apache.commons.digester3.Substitutor;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.ErrorHandler;
+import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
 
@@ -145,6 +146,12 @@ public final class DigesterLoader
     private ErrorHandler errorHandler = null;
 
     /**
+     * The Locator associated with our parser.
+     * @since 3.2
+     */
+    private Locator locator = null;
+
+    /**
      * Creates a new {@link DigesterLoader} instance given a collection of {@link RulesModule}
instance.
      *
      * @param rulesModules The modules containing the {@code Rule} binding
@@ -409,6 +416,29 @@ public final class DigesterLoader
     }
 
     /**
+     * Gets the document locator associated with our parser.
+     *
+     * @return the Locator supplied by the document parser
+     * @since 3.2
+     */
+    public Locator getDocumentLocator()
+    {
+        return locator;
+    }
+
+    /**
+     * Sets the document locator associated with our parser.
+     *
+     * @param locator the document locator associated with our parser.
+     * @since 3.2
+     */
+    public DigesterLoader setDocumentLocator( Locator locator )
+    {
+        this.locator = locator;
+        return this;
+    }
+
+    /**
      * Creates a new {@link Digester} instance that relies on the default {@link Rules} implementation.
      *
      * @return a new {@link Digester} instance
@@ -517,6 +547,7 @@ public final class DigesterLoader
         digester.setNamespaceAware( isNamespaceAware() );
         digester.setExecutorService( executorService );
         digester.setErrorHandler( errorHandler );
+        digester.setDocumentLocator( locator );
 
         addRules( digester );
 

Modified: commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/binder/DigesterLoaderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/binder/DigesterLoaderTestCase.java?rev=1197908&r1=1197907&r2=1197908&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/binder/DigesterLoaderTestCase.java
(original)
+++ commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/binder/DigesterLoaderTestCase.java
Sat Nov  5 09:28:51 2011
@@ -25,6 +25,7 @@ import static org.apache.commons.digeste
 import org.apache.commons.digester3.Digester;
 import org.junit.Test;
 import org.xml.sax.ErrorHandler;
+import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
@@ -76,4 +77,51 @@ public final class DigesterLoaderTestCas
         assertSame( expected, actual );
     }
 
+    @Test
+    public void digeser152()
+    {
+        Locator expected = new Locator()
+        {
+
+            public String getSystemId()
+            {
+                // just fake method
+                return null;
+            }
+
+            public String getPublicId()
+            {
+                // just fake method
+                return null;
+            }
+
+            public int getLineNumber()
+            {
+                // just fake method
+                return 0;
+            }
+
+            public int getColumnNumber()
+            {
+                // just fake method
+                return 0;
+            }
+        };
+
+        Digester digester = newLoader( new AbstractRulesModule()
+        {
+
+            @Override
+            protected void configure()
+            {
+                // do nothing
+            }
+
+        } ).setDocumentLocator( expected ).newDigester();
+
+        Locator actual = digester.getDocumentLocator();
+
+        assertSame( expected, actual );
+    }
+
 }



Mime
View raw message