ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1706479 - in /webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax: FOMCollection.java FOMElement.java FOMExtensibleElement.java FOMMultipartCollection.java
Date Fri, 02 Oct 2015 19:30:48 GMT
Author: veithen
Date: Fri Oct  2 19:30:48 2015
New Revision: 1706479

URL: http://svn.apache.org/viewvc?rev=1706479&view=rev
Log:
Rewrite some FOM code using the core model API.

Modified:
    webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
    webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
    webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
    webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMMultipartCollection.java

Modified: webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java?rev=1706479&r1=1706478&r2=1706479&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
(original)
+++ webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
Fri Oct  2 19:30:48 2015
@@ -37,6 +37,7 @@ import org.apache.abdera.model.Element;
 import org.apache.abdera.model.Text;
 import org.apache.abdera.util.MimeTypeHelper;
 import org.apache.axiom.fom.AbderaCollection;
+import org.apache.axiom.fom.AbderaElement;
 import org.apache.axiom.om.OMElement;
 
 @SuppressWarnings("deprecation")
@@ -80,11 +81,11 @@ public class FOMCollection extends FOMEx
 
     public String[] getAccept() {
         List<String> accept = new ArrayList<String>();
-        Iterator<?> i = getChildrenWithName(ACCEPT);
+        Iterator<AbderaElement> i = _getChildrenWithName(ACCEPT);
         if (i == null || !i.hasNext())
-            i = getChildrenWithName(PRE_RFC_ACCEPT);
+            i = _getChildrenWithName(PRE_RFC_ACCEPT);
         while (i.hasNext()) {
-            Element e = (Element)i.next();
+            Element e = i.next();
             String t = e.getText();
             if (t != null) {
                 accept.add(t.trim());

Modified: webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMElement.java?rev=1706479&r1=1706478&r2=1706479&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
(original)
+++ webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
Fri Oct  2 19:30:48 2015
@@ -58,10 +58,13 @@ import org.apache.abdera.parser.stax.uti
 import org.apache.abdera.util.MimeTypeHelper;
 import org.apache.abdera.writer.Writer;
 import org.apache.abdera.writer.WriterOptions;
+import org.apache.axiom.core.Axis;
 import org.apache.axiom.core.CoreChildNode;
 import org.apache.axiom.core.CoreNSAwareElement;
+import org.apache.axiom.core.ElementMatcher;
 import org.apache.axiom.fom.AbderaElement;
 import org.apache.axiom.fom.AbderaText;
+import org.apache.axiom.fom.FOMExceptionTranslator;
 import org.apache.axiom.fom.FOMList;
 import org.apache.axiom.fom.IRIUtil;
 import org.apache.axiom.fom.Policies;
@@ -220,9 +223,15 @@ public class FOMElement extends FOMChild
         return (T)this;
     }
 
+    protected final Iterator<AbderaElement> _getChildrenWithName(QName qname) {
+        return coreGetElements(Axis.CHILDREN, AbderaElement.class, ElementMatcher.BY_QNAME,
+                qname.getNamespaceURI(), qname.getLocalPart(), FOMExceptionTranslator.INSTANCE,
+                Policies.DETACH_POLICY);
+    }
+
     public <E extends Element> List<E> _getChildrenAsSet(QName qname) {
         FOMFactory factory = (FOMFactory)getFactory();
-        return new FOMList(new FOMElementIteratorWrapper(factory, getChildrenWithName(qname)));
+        return new FOMList(new FOMElementIteratorWrapper(factory, _getChildrenWithName(qname)));
     }
 
     protected void _setChild(QName qname, Element element) {

Modified: webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java?rev=1706479&r1=1706478&r2=1706479&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
(original)
+++ webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
Fri Oct  2 19:30:48 2015
@@ -42,7 +42,7 @@ public class FOMExtensibleElement extend
 
     public <T extends Element> List<T> getExtensions(QName qname) {
         FOMFactory factory = (FOMFactory)this.getFactory();
-        return new FOMList<T>(new FOMElementIteratorWrapper(factory, getChildrenWithName(qname)));
+        return new FOMList<T>(new FOMElementIteratorWrapper(factory, _getChildrenWithName(qname)));
     }
 
     public <T extends Element> T getExtension(QName qname) {

Modified: webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMMultipartCollection.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMMultipartCollection.java?rev=1706479&r1=1706478&r2=1706479&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMMultipartCollection.java
(original)
+++ webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMMultipartCollection.java
Fri Oct  2 19:30:48 2015
@@ -15,6 +15,7 @@ import javax.activation.MimeType;
 import org.apache.abdera.model.Collection;
 import org.apache.abdera.model.Element;
 import org.apache.abdera.util.MimeTypeHelper;
+import org.apache.axiom.fom.AbderaElement;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -53,11 +54,11 @@ public class FOMMultipartCollection exte
 
     public Map<String, String> getAcceptMultiparted() {
         Map<String, String> accept = new HashMap<String, String>();
-        Iterator<?> i = getChildrenWithName(ACCEPT);
+        Iterator<AbderaElement> i = _getChildrenWithName(ACCEPT);
         if (i == null || !i.hasNext())
-            i = getChildrenWithName(PRE_RFC_ACCEPT);
+            i = _getChildrenWithName(PRE_RFC_ACCEPT);
         while (i.hasNext()) {
-            Element e = (Element)i.next();
+            Element e = i.next();
             String t = e.getText();
             if (t != null) {
                 if (e.getAttributeValue(ALTERNATE) != null && e.getAttributeValue(ALTERNATE).trim().length()
> 0) {



Mime
View raw message