ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1700054 - in /webservices/axiom/trunk: aspects/fom-aspects/src/main/java/org/apache/axiom/fom/ implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/
Date Sat, 29 Aug 2015 15:48:31 GMT
Author: veithen
Date: Sat Aug 29 15:48:30 2015
New Revision: 1700054

URL: http://svn.apache.org/r1700054
Log:
AXIOM-472: Reimplement FOMAttribute as a first class node instead of a wrapper around an OMAttribute.

Added:
    webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaAttribute.java
  (with props)
    webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaAttributeSupport.aj
      - copied, changed from r1698456, webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMAttribute.java
Modified:
    webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMAttribute.java
    webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
    webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java

Added: webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaAttribute.java?rev=1700054&view=auto
==============================================================================
--- webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaAttribute.java
(added)
+++ webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaAttribute.java
Sat Aug 29 15:48:30 2015
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+package org.apache.axiom.fom;
+
+import org.apache.abdera.model.Attribute;
+import org.apache.axiom.core.CoreNSAwareAttribute;
+
+public interface AbderaAttribute extends Attribute, AbderaNode, CoreNSAwareAttribute {
+
+}

Propchange: webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaAttributeSupport.aj
(from r1698456, webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMAttribute.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaAttributeSupport.aj?p2=webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaAttributeSupport.aj&p1=webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMAttribute.java&r1=1698456&r2=1700054&rev=1700054&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMAttribute.java
(original)
+++ webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaAttributeSupport.aj
Sat Aug 29 15:48:30 2015
@@ -15,62 +15,17 @@
  * copyright in this work, please see the NOTICE file in the top level
  * directory of this distribution.
  */
-package org.apache.abdera.parser.stax;
+package org.apache.axiom.fom;
 
-import javax.xml.namespace.QName;
-
-import org.apache.abdera.factory.Factory;
 import org.apache.abdera.model.Attribute;
-import org.apache.axiom.om.OMAttribute;
-
-public class FOMAttribute implements Attribute {
-
-    private final OMAttribute attr;
-
-    protected FOMAttribute(OMAttribute attr) {
-        this.attr = attr;
-    }
-
-    public QName getQName() {
-        return attr.getQName();
-    }
 
-    public String getText() {
-        return attr.getAttributeValue();
+public aspect AbderaAttributeSupport {
+    public final String AbderaAttribute.getText() {
+        return coreGetCharacterData().toString();
     }
 
-    public Attribute setText(String text) {
-        attr.setAttributeValue(text);
+    public final Attribute AbderaAttribute.setText(String text) {
+        coreSetCharacterData(text, Policies.DETACH_POLICY);
         return this;
     }
-
-    public Factory getFactory() {
-        return (Factory)attr.getOMFactory();
-    }
-
-    @Override
-    public int hashCode() {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + ((attr == null) ? 0 : attr.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-        if (obj == null)
-            return false;
-        if (getClass() != obj.getClass())
-            return false;
-        final FOMAttribute other = (FOMAttribute)obj;
-        if (attr == null) {
-            if (other.attr != null)
-                return false;
-        } else if (!attr.equals(other.attr))
-            return false;
-        return true;
-    }
-
 }

Modified: webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMAttribute.java?rev=1700054&r1=1700053&r2=1700054&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMAttribute.java
(original)
+++ webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMAttribute.java
Sat Aug 29 15:48:30 2015
@@ -17,60 +17,12 @@
  */
 package org.apache.abdera.parser.stax;
 
-import javax.xml.namespace.QName;
-
-import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Attribute;
-import org.apache.axiom.om.OMAttribute;
-
-public class FOMAttribute implements Attribute {
-
-    private final OMAttribute attr;
-
-    protected FOMAttribute(OMAttribute attr) {
-        this.attr = attr;
+import org.apache.axiom.fom.AbderaAttribute;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.impl.llom.OMAttributeImpl;
+
+public class FOMAttribute extends OMAttributeImpl implements AbderaAttribute {
+    protected FOMAttribute(OMFactory factory) {
+        super(factory);
     }
-
-    public QName getQName() {
-        return attr.getQName();
-    }
-
-    public String getText() {
-        return attr.getAttributeValue();
-    }
-
-    public Attribute setText(String text) {
-        attr.setAttributeValue(text);
-        return this;
-    }
-
-    public Factory getFactory() {
-        return (Factory)attr.getOMFactory();
-    }
-
-    @Override
-    public int hashCode() {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + ((attr == null) ? 0 : attr.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-        if (obj == null)
-            return false;
-        if (getClass() != obj.getClass())
-            return false;
-        final FOMAttribute other = (FOMAttribute)obj;
-        if (attr == null) {
-            if (other.attr != null)
-                return false;
-        } else if (!attr.equals(other.attr))
-            return false;
-        return true;
-    }
-
 }

Modified: webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java?rev=1700054&r1=1700053&r2=1700054&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
(original)
+++ webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
Sat Aug 29 15:48:30 2015
@@ -60,6 +60,7 @@ import org.apache.axiom.core.CoreCDATASe
 import org.apache.axiom.core.CoreCharacterDataNode;
 import org.apache.axiom.core.CoreComment;
 import org.apache.axiom.core.CoreDocument;
+import org.apache.axiom.core.CoreNSAwareAttribute;
 import org.apache.axiom.core.CoreNSAwareElement;
 import org.apache.axiom.core.CoreProcessingInstruction;
 import org.apache.axiom.fom.AbderaFactory;
@@ -649,4 +650,9 @@ public class FOMFactory extends OMLinked
     public CoreComment createComment() {
         return new FOMComment(this);
     }
+
+    @Override
+    public CoreNSAwareAttribute createNSAwareAttribute() {
+        return new FOMAttribute(this);
+    }
 }

Modified: webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java?rev=1700054&r1=1700053&r2=1700054&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java
(original)
+++ webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMXPath.java
Sat Aug 29 15:48:30 2015
@@ -17,7 +17,6 @@
  */
 package org.apache.abdera.parser.stax;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -30,7 +29,6 @@ import org.apache.abdera.model.ElementWr
 import org.apache.abdera.parser.stax.util.ResolveFunction;
 import org.apache.abdera.util.AbstractXPath;
 import org.apache.abdera.xpath.XPathException;
-import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.xpath.DocumentNavigator;
 import org.jaxen.BaseXPath;
 import org.jaxen.Function;
@@ -136,17 +134,8 @@ public class FOMXPath extends AbstractXP
                             Map<QName, Object> variables) throws XPathException {
         try {
             base = getElementWrapped(base);
-            List nodes = new ArrayList();
             XPath xpath = getXPath(path, namespaces, functions, variables);
-            List results = xpath.selectNodes(base);
-            for (Object obj : results) {
-                if (obj instanceof OMAttribute) {
-                    nodes.add(new FOMAttribute((OMAttribute)obj));
-                } else {
-                    nodes.add(obj);
-                }
-            }
-            return nodes;
+            return xpath.selectNodes(base);
         } catch (JaxenException e) {
             throw new XPathException(e);
         }
@@ -164,10 +153,7 @@ public class FOMXPath extends AbstractXP
         try {
             base = getElementWrapped(base);
             XPath xpath = getXPath(path, namespaces, functions, variables);
-            Object obj = xpath.selectSingleNode(base);
-            if (obj instanceof OMAttribute)
-                obj = new FOMAttribute((OMAttribute)obj);
-            return obj;
+            return xpath.selectSingleNode(base);
         } catch (JaxenException e) {
             throw new XPathException(e);
         }



Mime
View raw message