abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1184766 - in /abdera/java/trunk: ./ parser/src/main/java/org/apache/abdera/parser/stax/ parser/src/main/java/org/apache/abdera/parser/stax/util/
Date Sun, 16 Oct 2011 06:49:20 GMT
Author: antelder
Date: Sun Oct 16 06:49:19 2011
New Revision: 1184766

URL: http://svn.apache.org/viewvc?rev=1184766&view=rev
Log:
ABDERA-290: Apply patch from Andreas Veithen and Olve Sæther Hansen to fix using Axiom 1.2.12
breaks Abdera-parser - compile-errors

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/FOMElement.java
    abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMMetaFactory.java
    abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMElementIterator.java
    abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java
    abdera/java/trunk/pom.xml

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=1184766&r1=1184765&r2=1184766&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 Sun
Oct 16 06:49:19 2011
@@ -96,7 +96,7 @@ public class FOMBuilder extends StAXOMBu
         } else {
             OMElement e = (OMElement)lastNode;
             node = constructNode((OMElement)lastNode, elementName);
-            e.setFirstChild(node);
+            ((OMContainerEx)e).setFirstChild(node);
         }
         return node;
     }

Modified: abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java?rev=1184766&r1=1184765&r2=1184766&view=diff
==============================================================================
--- abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java (original)
+++ abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java Sun
Oct 16 06:49:19 2011
@@ -17,11 +17,11 @@
  */
 package org.apache.abdera.parser.stax;
 
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -525,12 +525,9 @@ public class FOMElement extends OMElemen
             return null;
         FOMFactory fomfactory = (FOMFactory)factory;
         Parser parser = fomfactory.newParser();
-        ByteArrayInputStream bais =
-            new ByteArrayInputStream(value.getBytes(getXMLStreamReader().getCharacterEncodingScheme()));
         ParserOptions options = parser.getDefaultParserOptions();
-        options.setCharset(getXMLStreamReader().getCharacterEncodingScheme());
         options.setFactory(fomfactory);
-        Document doc = parser.parse(bais, (baseUri != null) ? baseUri.toString() : null,
options);
+        Document doc = parser.parse(new StringReader(value), (baseUri != null) ? baseUri.toString()
: null, options);
         return doc.getRoot();
     }
 

Modified: abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMMetaFactory.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMMetaFactory.java?rev=1184766&r1=1184765&r2=1184766&view=diff
==============================================================================
--- abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMMetaFactory.java
(original)
+++ abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMMetaFactory.java
Sun Oct 16 06:49:19 2011
@@ -18,25 +18,12 @@
 package org.apache.abdera.parser.stax;
 
 import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
-import org.apache.axiom.soap.impl.llom.soap12.SOAP12Factory;
+import org.apache.axiom.om.impl.llom.factory.OMLinkedListMetaFactory;
 
-public class FOMMetaFactory implements OMMetaFactory {
+public class FOMMetaFactory extends OMLinkedListMetaFactory {
     private final OMFactory omFactory = new FOMFactory();
-    private final SOAPFactory soap11Factory = new SOAP11Factory();
-    private final SOAPFactory soap12Factory = new SOAP12Factory();
     
     public OMFactory getOMFactory() {
         return omFactory;
     }
-    
-    public SOAPFactory getSOAP11Factory() {
-        return soap11Factory;
-    }
-    
-    public SOAPFactory getSOAP12Factory() {
-        return soap12Factory;
-    }
 }

Modified: abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMElementIterator.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMElementIterator.java?rev=1184766&r1=1184765&r2=1184766&view=diff
==============================================================================
--- abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMElementIterator.java
(original)
+++ abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMElementIterator.java
Sun Oct 16 06:49:19 2011
@@ -21,10 +21,11 @@ import javax.xml.namespace.QName;
 
 import org.apache.abdera.model.Element;
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.traverse.OMChildrenIterator;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.impl.traverse.OMFilterIterator;
 
 @SuppressWarnings("unchecked")
-public class FOMElementIterator extends OMChildrenIterator {
+public class FOMElementIterator extends OMFilterIterator {
 
     /**
      * Field givenQName
@@ -35,23 +36,13 @@ public class FOMElementIterator extends 
     protected Class _class = null;
 
     /**
-     * Field needToMoveForward
-     */
-    private boolean needToMoveForward = true;
-
-    /**
-     * Field isMatchingNodeFound
-     */
-    private boolean isMatchingNodeFound = false;
-
-    /**
      * Constructor OMChildrenQNameIterator.
      * 
-     * @param currentChild
+     * @param parent
      * @param givenQName
      */
     public FOMElementIterator(Element parent, Class _class) {
-        super(((OMElement)parent).getFirstOMChild());
+        super(((OMElement)parent).getChildren());
         this._class = _class;
     }
 
@@ -62,45 +53,9 @@ public class FOMElementIterator extends 
         this.defaultValue = defaultValue;
     }
 
-    /**
-     * Returns <tt>true</tt> if the iteration has more elements. (In other words,
returns <tt>true</tt> if <tt>next</tt>
-     * would return an element rather than throwing an exception.)
-     * 
-     * @return Returns <tt>true</tt> if the iterator has more elements.
-     */
-    public boolean hasNext() {
-        while (needToMoveForward) {
-            if (currentChild != null) {
-                // check the current node for the criteria
-                if (currentChild instanceof Element) {
-                    if (((_class != null && _class.isAssignableFrom(currentChild.getClass()))
|| _class == null) && isMatch((Element)currentChild)) {
-                        isMatchingNodeFound = true;
-                        needToMoveForward = false;
-                    } else {
-                        isMatchingNodeFound = false;
-                        currentChild = currentChild.getNextOMSibling();
-                    }
-                } else {
-                    isMatchingNodeFound = false;
-                    currentChild = currentChild.getNextOMSibling();
-                }
-            } else {
-                needToMoveForward = false;
-            }
-        }
-        return isMatchingNodeFound;
-    }
-
-    public Object next() {
-
-        // reset the flags
-        needToMoveForward = true;
-        isMatchingNodeFound = false;
-        nextCalled = true;
-        removeCalled = false;
-        lastChild = currentChild;
-        currentChild = currentChild.getNextOMSibling();
-        return lastChild;
+    @Override
+    protected boolean matches(OMNode node) {
+        return ((_class != null && _class.isAssignableFrom(node.getClass())) || _class
== null) && isMatch((Element)node);
     }
 
     protected boolean isMatch(Element el) {

Modified: abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java
URL: http://svn.apache.org/viewvc/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java?rev=1184766&r1=1184765&r2=1184766&view=diff
==============================================================================
--- abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java
(original)
+++ abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java
Sun Oct 16 06:49:19 2011
@@ -20,14 +20,12 @@ package org.apache.abdera.parser.stax.ut
 import org.apache.abdera.model.Element;
 import org.apache.abdera.parser.stax.FOMFactory;
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.traverse.OMChildrenIterator;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.impl.traverse.OMFilterIterator;
 
 import javax.xml.namespace.QName;
 
-/**
- * Most of the original code for this class came from the OMChildrenQNameIterator from Axiom
- */
-public class FOMExtensionIterator extends OMChildrenIterator {
+public class FOMExtensionIterator extends OMFilterIterator {
 
     /**
      * Field givenQName
@@ -37,23 +35,13 @@ public class FOMExtensionIterator extend
     private FOMFactory factory = null;
 
     /**
-     * Field needToMoveForward
-     */
-    private boolean needToMoveForward = true;
-
-    /**
-     * Field isMatchingNodeFound
-     */
-    private boolean isMatchingNodeFound = false;
-
-    /**
      * Constructor OMChildrenQNameIterator.
      * 
-     * @param currentChild
+     * @param parent
      * @param givenQName
      */
     public FOMExtensionIterator(OMElement parent) {
-        super(parent.getFirstOMChild());
+        super(parent.getChildren());
         this.namespace = parent.getQName().getNamespaceURI();
         this.factory = (FOMFactory)parent.getOMFactory();
     }
@@ -63,44 +51,15 @@ public class FOMExtensionIterator extend
         this.extns = extns;
     }
 
-    /**
-     * Returns <tt>true</tt> if the iteration has more elements. (In other words,
returns <tt>true</tt> if <tt>next</tt>
-     * would return an element rather than throwing an exception.)
-     * 
-     * @return Returns <tt>true</tt> if the iterator has more elements.
-     */
-    public boolean hasNext() {
-        while (needToMoveForward) {
-            if (currentChild != null) {
-
-                // check the current node for the criteria
-                if ((currentChild instanceof OMElement) && (isQNamesMatch(((OMElement)currentChild).getQName(),
-                                                                          this.namespace)))
{
-                    isMatchingNodeFound = true;
-                    needToMoveForward = false;
-                } else {
-
-                    // get the next named node
-                    currentChild = currentChild.getNextOMSibling();
-                    isMatchingNodeFound = needToMoveForward = !(currentChild == null);
-                }
-            } else {
-                needToMoveForward = false;
-            }
-        }
-        return isMatchingNodeFound;
-    }
-
+    @Override
     public Object next() {
+        return factory.getElementWrapper((Element)super.next());
+    }
 
-        // reset the flags
-        needToMoveForward = true;
-        isMatchingNodeFound = false;
-        nextCalled = true;
-        removeCalled = false;
-        lastChild = currentChild;
-        currentChild = currentChild.getNextOMSibling();
-        return factory.getElementWrapper((Element)lastChild);
+    @Override
+    protected boolean matches(OMNode node) {
+        return (node instanceof OMElement) && (isQNamesMatch(((OMElement)node).getQName(),
+                this.namespace));
     }
 
     private boolean isQNamesMatch(QName elementQName, String namespace) {

Modified: abdera/java/trunk/pom.xml
URL: http://svn.apache.org/viewvc/abdera/java/trunk/pom.xml?rev=1184766&r1=1184765&r2=1184766&view=diff
==============================================================================
--- abdera/java/trunk/pom.xml (original)
+++ abdera/java/trunk/pom.xml Sun Oct 16 06:49:19 2011
@@ -377,13 +377,13 @@
       <dependency>
         <groupId>org.apache.ws.commons.axiom</groupId>
         <artifactId>axiom-api</artifactId>
-        <version>1.2.10</version>  
+        <version>1.2.12</version>  
       </dependency>
 
       <dependency>
         <groupId>org.apache.ws.commons.axiom</groupId>
         <artifactId>axiom-impl</artifactId>
-        <version>1.2.10</version>  
+        <version>1.2.12</version>  
 
       <exclusions>
         <exclusion>



Mime
View raw message