summaryrefslogtreecommitdiffstats
path: root/xml
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2010-04-20 14:16:25 -0700
committerJesse Wilson <jessewilson@google.com>2010-04-20 14:16:25 -0700
commit81bcd5c1f677de9c79155c87bcfbfc5896920403 (patch)
tree461774d94fe1457cdb325e40049239127c7dda57 /xml
parent0fa251a6abd62d73a1a3d1ca74ee0bfc55050d90 (diff)
downloadlibcore-81bcd5c1f677de9c79155c87bcfbfc5896920403.zip
libcore-81bcd5c1f677de9c79155c87bcfbfc5896920403.tar.gz
libcore-81bcd5c1f677de9c79155c87bcfbfc5896920403.tar.bz2
Fixing reset() on SAXParser and DocumentBuilder, and cleaning up nearby tests.
Also fixing vogar to support a directory of test expectations, so we can group them by file rather than colocating failures we want to fix with those that we don't.
Diffstat (limited to 'xml')
-rw-r--r--xml/src/main/java/javax/xml/parsers/SAXParser.java2
-rw-r--r--xml/src/main/java/org/apache/harmony/xml/ExpatReader.java2
-rw-r--r--xml/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java17
-rw-r--r--xml/src/main/java/org/apache/harmony/xml/parsers/SAXParserImpl.java37
4 files changed, 40 insertions, 18 deletions
diff --git a/xml/src/main/java/javax/xml/parsers/SAXParser.java b/xml/src/main/java/javax/xml/parsers/SAXParser.java
index cd020ab..8c52461 100644
--- a/xml/src/main/java/javax/xml/parsers/SAXParser.java
+++ b/xml/src/main/java/javax/xml/parsers/SAXParser.java
@@ -63,7 +63,7 @@ import org.xml.sax.helpers.DefaultHandler;
* given {@link org.xml.sax.HandlerBase} or the
* {@link org.xml.sax.helpers.DefaultHandler} are called.<p>
*
- * Implementors of this class which wrap an underlaying implementation
+ * Implementations of this class which wrap an underlying implementation
* can consider using the {@link org.xml.sax.helpers.ParserAdapter}
* class to initially adapt their SAX1 implementation to work under
* this revised class.
diff --git a/xml/src/main/java/org/apache/harmony/xml/ExpatReader.java b/xml/src/main/java/org/apache/harmony/xml/ExpatReader.java
index d187456..3bf5d07 100644
--- a/xml/src/main/java/org/apache/harmony/xml/ExpatReader.java
+++ b/xml/src/main/java/org/apache/harmony/xml/ExpatReader.java
@@ -148,7 +148,7 @@ public class ExpatReader implements XMLReader {
if (name.equals(LEXICAL_HANDLER_PROPERTY)) {
// The object must implement LexicalHandler
- if (value instanceof LexicalHandler) {
+ if (value instanceof LexicalHandler || value == null) {
this.lexicalHandler = (LexicalHandler) value;
return;
}
diff --git a/xml/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java b/xml/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java
index 8bce9aa..31384a0 100644
--- a/xml/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java
+++ b/xml/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java
@@ -57,19 +57,20 @@ class DocumentBuilderImpl extends DocumentBuilder {
private static DOMImplementationImpl dom = DOMImplementationImpl.getInstance();
private boolean coalescing;
-
private EntityResolver entityResolver;
-
private ErrorHandler errorHandler;
-
private boolean ignoreComments;
-
private boolean ignoreElementContentWhitespace;
-
private boolean namespaceAware;
-
- DocumentBuilderImpl() {
- // Do nothing.
+ // adding a new field? don't forget to update reset().
+
+ @Override public void reset() {
+ coalescing = false;
+ entityResolver = null;
+ errorHandler = null;
+ ignoreComments = false;
+ ignoreElementContentWhitespace = false;
+ namespaceAware = false;
}
@Override
diff --git a/xml/src/main/java/org/apache/harmony/xml/parsers/SAXParserImpl.java b/xml/src/main/java/org/apache/harmony/xml/parsers/SAXParserImpl.java
index b3af61f..55de4b3 100644
--- a/xml/src/main/java/org/apache/harmony/xml/parsers/SAXParserImpl.java
+++ b/xml/src/main/java/org/apache/harmony/xml/parsers/SAXParserImpl.java
@@ -16,6 +16,8 @@
package org.apache.harmony.xml.parsers;
+import java.util.Collections;
+import java.util.HashMap;
import org.apache.harmony.xml.ExpatReader;
import java.util.Map;
@@ -30,25 +32,44 @@ import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderAdapter;
/**
- * Provides a straightforward SAXParser implementation based on ExpatReader.
- * The class is used internally only, thus only notable members that are not
- * already in the abstract superclass are documented. Hope that's ok.
+ * A SAX parser based on Expat.
*/
-class SAXParserImpl extends SAXParser {
+final class SAXParserImpl extends SAXParser {
+ private Map<String, Boolean> initialFeatures;
private XMLReader reader;
-
private Parser parser;
- SAXParserImpl(Map<String, Boolean> features)
+ SAXParserImpl(Map<String, Boolean> initialFeatures)
throws SAXNotRecognizedException, SAXNotSupportedException {
- reader = new ExpatReader();
+ this.initialFeatures = initialFeatures.isEmpty()
+ ? Collections.<String, Boolean>emptyMap()
+ : new HashMap<String, Boolean>(initialFeatures);
+ resetInternal();
+ }
- for (Map.Entry<String,Boolean> entry : features.entrySet()) {
+ private void resetInternal()
+ throws SAXNotSupportedException, SAXNotRecognizedException {
+ reader = new ExpatReader();
+ for (Map.Entry<String,Boolean> entry : initialFeatures.entrySet()) {
reader.setFeature(entry.getKey(), entry.getValue());
}
}
+ @Override public void reset() {
+ /*
+ * The exceptions are impossible. If any features are unrecognized or
+ * unsupported, construction of this instance would have failed.
+ */
+ try {
+ resetInternal();
+ } catch (SAXNotRecognizedException e) {
+ throw new AssertionError();
+ } catch (SAXNotSupportedException e) {
+ throw new AssertionError();
+ }
+ }
+
@Override
public Parser getParser() {
if (parser == null) {