You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/11/03 17:44:04 UTC
svn commit: r1197213 - in /commons/proper/digester/trunk/src: changes/
main/java/org/apache/commons/digester3/binder/
test/java/org/apache/commons/digester3/binder/
Author: simonetripodi
Date: Thu Nov 3 16:44:04 2011
New Revision: 1197213
URL: http://svn.apache.org/viewvc?rev=1197213&view=rev
Log:
[DIGESTER-151] The org.apache.commons.digester3.binder.DigesterLoader doesn't allow binding a default org.xml.sax.ErrorHandler
Added:
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/binder/
commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/binder/DigesterLoaderTestCase.java (with props)
Modified:
commons/proper/digester/trunk/src/changes/changes.xml
commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/DigesterLoader.java
Modified: commons/proper/digester/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/changes/changes.xml?rev=1197213&r1=1197212&r2=1197213&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/changes/changes.xml (original)
+++ commons/proper/digester/trunk/src/changes/changes.xml Thu Nov 3 16:44:04 2011
@@ -23,7 +23,9 @@
</properties>
<body>
<release version="3.2" date="201?-??-??" description="Maintenance release.">
-
+ <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>
</release>
<release version="3.1" date="2011-10-29" description="New features release.">
<action dev="simonetripodi" type="add" issue="DIGESTER-150">
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=1197213&r1=1197212&r2=1197213&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 Thu Nov 3 16:44:04 2011
@@ -42,6 +42,7 @@ import org.apache.commons.digester3.Rule
import org.apache.commons.digester3.StackAction;
import org.apache.commons.digester3.Substitutor;
import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
@@ -138,6 +139,12 @@ public final class DigesterLoader
private ExecutorService executorService;
/**
+ * The application-supplied error handler that is notified when parsing warnings, errors, or fatal errors occur.
+ * @since 3.2
+ */
+ private ErrorHandler errorHandler = null;
+
+ /**
* Creates a new {@link DigesterLoader} instance given a collection of {@link RulesModule} instance.
*
* @param rulesModules The modules containing the {@code Rule} binding
@@ -378,6 +385,30 @@ public final class DigesterLoader
}
/**
+ * Return the error handler for this Digester.
+ *
+ * @return the error handler for this Digester.
+ * @since 3.2
+ */
+ public ErrorHandler getErrorHandler()
+ {
+ return ( this.errorHandler );
+ }
+
+ /**
+ * Set the error handler for this Digester.
+ *
+ * @param errorHandler The new error handler
+ * @return This loader instance, useful to chain methods.
+ * @since 3.2
+ */
+ public DigesterLoader setErrorHandler( ErrorHandler errorHandler )
+ {
+ this.errorHandler = errorHandler;
+ return this;
+ }
+
+ /**
* Creates a new {@link Digester} instance that relies on the default {@link Rules} implementation.
*
* @return a new {@link Digester} instance
@@ -486,6 +517,11 @@ public final class DigesterLoader
digester.setNamespaceAware( isNamespaceAware() );
digester.setExecutorService( executorService );
+ if ( errorHandler != null )
+ {
+ digester.setErrorHandler( errorHandler );
+ }
+
addRules( digester );
return digester;
Added: 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=1197213&view=auto
==============================================================================
--- commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/binder/DigesterLoaderTestCase.java (added)
+++ commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/binder/DigesterLoaderTestCase.java Thu Nov 3 16:44:04 2011
@@ -0,0 +1,79 @@
+package org.apache.commons.digester3.binder;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.junit.Assert.assertSame;
+import static org.apache.commons.digester3.binder.DigesterLoader.newLoader;
+
+import org.apache.commons.digester3.Digester;
+import org.junit.Test;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+public final class DigesterLoaderTestCase
+{
+
+ /**
+ * {@link https://issues.apache.org/jira/browse/DIGESTER-151}
+ */
+ @Test
+ public void digester151()
+ {
+ ErrorHandler expected = new ErrorHandler()
+ {
+
+ public void warning( SAXParseException exception )
+ throws SAXException
+ {
+ // do nothing
+ }
+
+ public void fatalError( SAXParseException exception )
+ throws SAXException
+ {
+ // do nothing
+ }
+
+ public void error( SAXParseException exception )
+ throws SAXException
+ {
+ // do nothing
+ }
+
+ };
+
+ Digester digester = newLoader( new AbstractRulesModule()
+ {
+
+ @Override
+ protected void configure()
+ {
+ // do nothing
+ }
+
+ } ).setErrorHandler( expected ).newDigester();
+
+ ErrorHandler actual = digester.getErrorHandler();
+
+ assertSame( expected, actual );
+ }
+
+}
Propchange: commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/binder/DigesterLoaderTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/binder/DigesterLoaderTestCase.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/binder/DigesterLoaderTestCase.java
------------------------------------------------------------------------------
svn:mime-type = text/plain