abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1435571 - in /abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax: FOMBuilder.java FOMDocument.java FOMFactory.java
Date Sat, 19 Jan 2013 15:38:26 GMT
Author: veithen
Date: Sat Jan 19 15:38:25 2013
New Revision: 1435571

URL: http://svn.apache.org/viewvc?rev=1435571&view=rev
Log:
Prevent FOMBuilder from modifying the internal state of its superclass (StAXOMBuilder) because
this creates a compatibility issue with Axiom 1.2.15. Instead, let Axiom handle the creation
of the FOMDocument instance.

Modified:
    abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
    abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java
    abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java

Modified: abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java?rev=1435571&r1=1435570&r2=1435571&view=diff
==============================================================================
--- abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java (original)
+++ abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java Sat
Jan 19 15:38:25 2013
@@ -28,7 +28,6 @@ import org.apache.abdera.parser.ParseExc
 import org.apache.abdera.parser.ParserOptions;
 import org.apache.abdera.util.Constants;
 import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.om.OMDocument;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
@@ -38,16 +37,11 @@ public class FOMBuilder extends StAXOMBu
 
     private final FOMFactory fomfactory;
     private final ParserOptions parserOptions;
-    private boolean indoc = false;
 
     public FOMBuilder(FOMFactory factory, XMLStreamReader parser, ParserOptions parserOptions)
{
         super(factory, new FOMStAXFilter(parser, parserOptions));
-        this.document = (OMDocument)factory.newDocument();
         this.parserOptions = parserOptions;
         this.fomfactory = factory;
-        String enc = parser.getCharacterEncodingScheme();
-        document.setCharsetEncoding(enc != null ? enc : "utf-8");
-        document.setXMLVersion(parser.getVersion() != null ? parser.getVersion() : "1.0");
     }
 
     public ParserOptions getParserOptions() {
@@ -96,13 +90,8 @@ public class FOMBuilder extends StAXOMBu
 
     @Override
     protected OMElement constructNode(OMContainer parent, String name) {
-        OMElement element = null;
-        if (!indoc) {
-            parent = document;
-            indoc = true;
-        }
         QName qname = parser.getName();
-        element = fomfactory.createElement(qname, parent, this);
+        OMElement element = fomfactory.createElement(qname, parent, this);
         if (element == null) {
             element = new FOMElement(qname.getLocalPart(), parent, fomfactory, this);
         }
@@ -110,14 +99,11 @@ public class FOMBuilder extends StAXOMBu
     }
 
     public <T extends Element> Document<T> getFomDocument() {
-        while (!indoc && !done) {
-            next();
-        }
-        return (Document<T>)document;
-    }
-
-    public OMDocument getDocument() {
-        return (OMDocument)getFomDocument();
+        // For compatibility with earlier Abdera versions, force creation of the document
element.
+        // Note that the only known case where this has a visible effect is when the document
is
+        // not well formed. At least one unit test depends on this behavior.
+        getDocumentElement();
+        return (Document<T>)getDocument();
     }
 
     public FOMFactory getFactory() {

Modified: abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java?rev=1435571&r1=1435570&r2=1435571&view=diff
==============================================================================
--- abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java
(original)
+++ abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDocument.java
Sat Jan 19 15:38:25 2013
@@ -212,10 +212,12 @@ public class FOMDocument<T extends Eleme
     }
 
     public String getCharset() {
-        return this.getCharsetEncoding();
+        String enc = this.getXMLEncoding();
+        return enc == null ? "utf-8" : enc;
     }
 
     public Document<T> setCharset(String charset) {
+        this.setXMLEncoding(charset);
         this.setCharsetEncoding(charset);
         return this;
     }

Modified: abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java?rev=1435571&r1=1435570&r2=1435571&view=diff
==============================================================================
--- abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java (original)
+++ abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java Sat
Jan 19 15:38:25 2013
@@ -57,6 +57,7 @@ import org.apache.abdera.util.Version;
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMComment;
 import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMDocument;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
@@ -95,16 +96,11 @@ public class FOMFactory extends OMLinked
         return new FOMDocument(this);
     }
 
-    public <T extends Element> Document<T> newDocument(OMXMLParserWrapper parserWrapper)
{
+    @Override
+    public OMDocument createOMDocument(OMXMLParserWrapper parserWrapper) {
         return new FOMDocument(parserWrapper, this);
     }
 
-    public <T extends Element> Document<T> newDocument(T root, OMXMLParserWrapper
parserWrapper) {
-        FOMDocument<T> doc = (FOMDocument<T>)newDocument(parserWrapper);
-        doc.setRoot(root);
-        return doc;
-    }
-
     public Service newService(Base parent) {
         return new FOMService((OMContainer)parent, this);
     }



Mime
View raw message