ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1729741 - in /webservices/axiom/trunk: aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/ aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/ implementations/fom-impl/src/main/java/org/apache/...
Date Wed, 10 Feb 2016 21:25:13 GMT
Author: veithen
Date: Wed Feb 10 21:25:13 2016
New Revision: 1729741

URL: http://svn.apache.org/viewvc?rev=1729741&view=rev
Log:
Some cleanup.

Added:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderListener.java
      - copied, changed from r1729544, webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/NodePostProcessor.java
Removed:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/NodePostProcessor.java
Modified:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/AbstractBuilder.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java
    webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/AbstractBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/AbstractBuilder.java?rev=1729741&r1=1729740&r2=1729741&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/AbstractBuilder.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/AbstractBuilder.java
Wed Feb 10 21:25:13 2016
@@ -36,8 +36,8 @@ public abstract class AbstractBuilder im
         handler = repairNamespaces ? new NamespaceRepairingFilterHandler(builderHandler)
: builderHandler;
     }
 
-    public final void addNodePostProcessor(NodePostProcessor nodePostProcessor) {
-        builderHandler.addNodePostProcessor(nodePostProcessor);
+    public final void addListener(BuilderListener listener) {
+        builderHandler.addListener(listener);
     }
 
     public final boolean isCompleted() {

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java?rev=1729741&r1=1729740&r2=1729741&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderHandler.java
Wed Feb 10 21:25:13 2016
@@ -25,13 +25,12 @@ import java.util.Map;
 import javax.xml.stream.XMLStreamConstants;
 
 import org.apache.axiom.core.Builder;
+import org.apache.axiom.core.CoreNode;
 import org.apache.axiom.core.CoreParentNode;
 import org.apache.axiom.core.NodeFactory;
-import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.OMSerializable;
 import org.apache.axiom.om.impl.common.AxiomSemantics;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.apache.axiom.om.impl.intf.AxiomAttribute;
@@ -70,11 +69,11 @@ public final class BuilderHandler implem
     public AxiomDocument document;
     
     /**
-     * Tracks the depth of the node identified by {@link #target}. By definition, the level
of the
-     * root element is defined as 1. Note that if caching is disabled, then this depth may
be
-     * different from the actual depth reached by the underlying parser.
+     * Tracks the depth of the node identified by {@link #target}. By definition, the document
has
+     * depth 0. Note that if caching is disabled, then this depth may be different from the
actual
+     * depth reached by the underlying parser.
      */
-    public int elementLevel;
+    public int depth;
     
     /**
      * Stores the stack trace of the code that caused a node to be discarded or consumed.
This is
@@ -82,7 +81,7 @@ public final class BuilderHandler implem
      */
     public Map<CoreParentNode,Throwable> discardTracker = log.isDebugEnabled() ? new
LinkedHashMap<CoreParentNode,Throwable>() : null;
     
-    private ArrayList<NodePostProcessor> nodePostProcessors;
+    private ArrayList<BuilderListener> listeners;
 
     public BuilderHandler(NodeFactory nodeFactory, Model model, AxiomSourcedElement root,
Builder builder) {
         this.nodeFactory = nodeFactory;
@@ -91,17 +90,17 @@ public final class BuilderHandler implem
         this.builder = builder;
     }
 
-    public void addNodePostProcessor(NodePostProcessor nodePostProcessor) {
-        if (nodePostProcessors == null) {
-            nodePostProcessors = new ArrayList<NodePostProcessor>();
+    public void addListener(BuilderListener listener) {
+        if (listeners == null) {
+            listeners = new ArrayList<BuilderListener>();
         }
-        nodePostProcessors.add(nodePostProcessor);
+        listeners.add(listener);
     }
     
-    public void postProcessNode(OMSerializable node) {
-        if (nodePostProcessors != null) {
-            for (int i=0, size=nodePostProcessors.size(); i<size; i++) {
-                nodePostProcessors.get(i).postProcessNode(node);
+    public void nodeAdded(CoreNode node) {
+        if (listeners != null) {
+            for (int i=0, size=listeners.size(); i<size; i++) {
+                listeners.get(i).nodeAdded(node, depth);
             }
         }
     }
@@ -120,7 +119,7 @@ public final class BuilderHandler implem
     
     private void addChild(AxiomChildNode node) {
         target.addChild(node, true);
-        postProcessNode(node);
+        nodeAdded(node);
     }
     
     public void startDocument(String inputEncoding, String xmlVersion, String xmlEncoding,
boolean standalone) {
@@ -131,7 +130,7 @@ public final class BuilderHandler implem
             document.coreSetXmlEncoding(xmlEncoding);
             document.coreSetStandalone(standalone);
             document.coreSetBuilder(builder);
-            postProcessNode(document);
+            nodeAdded(document);
             target = document;
         }
     }
@@ -148,16 +147,16 @@ public final class BuilderHandler implem
     }
     
     public void startElement(String namespaceURI, String localName, String prefix) {
-        elementLevel++;
+        depth++;
         AxiomElement element;
         OMNamespace ns = nsCache.getOMNamespace(namespaceURI, prefix);
-        if (elementLevel == 1 && root != null) {
+        if (depth == 1 && root != null) {
             root.validateName(prefix, localName, namespaceURI);
             root.initName(localName, ns, false);
             element = root;
         } else {
             element = nodeFactory.createNode(model.determineElementType(
-                    target, elementLevel, namespaceURI, localName));
+                    target, depth, namespaceURI, localName));
             element.coreSetBuilder(builder);
             element.coreSetState(CoreParentNode.ATTRIBUTES_PENDING);
             element.initName(localName, ns, false);
@@ -167,9 +166,9 @@ public final class BuilderHandler implem
     }
     
     public void endElement() {
-        elementLevel--;
+        depth--;
         target.setComplete(true);
-        if (elementLevel == 0) {
+        if (depth == 0) {
             // This is relevant for OMSourcedElements and for the case where the document
has been discarded
             // using getDocumentElement(true). In these cases, this will actually set target
to null. In all
             // other cases, this will have the same effect as the instruction in the else
clause.
@@ -242,7 +241,7 @@ public final class BuilderHandler implem
     }
     
     public void endDocument() {
-        if (elementLevel != 0) {
+        if (depth != 0) {
             throw new IllegalStateException();
         }
         if (document != null) {
@@ -254,7 +253,7 @@ public final class BuilderHandler implem
 
     @Override
     public void processOMDataSource(String namespaceURI, String localName, OMDataSource dataSource)
throws StreamException {
-        Class<? extends AxiomElement> elementType = model.determineElementType(target,
elementLevel+1, namespaceURI, localName);
+        Class<? extends AxiomElement> elementType = model.determineElementType(target,
depth+1, namespaceURI, localName);
         Class<? extends AxiomSourcedElement> sourcedElementType;
         if (elementType == AxiomElement.class) {
             sourcedElementType = AxiomSourcedElement.class;

Copied: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderListener.java
(from r1729544, webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/NodePostProcessor.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderListener.java?p2=webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderListener.java&p1=webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/NodePostProcessor.java&r1=1729544&r2=1729741&rev=1729741&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/NodePostProcessor.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/BuilderListener.java
Wed Feb 10 21:25:13 2016
@@ -18,8 +18,20 @@
  */
 package org.apache.axiom.om.impl.common.builder;
 
-import org.apache.axiom.om.OMSerializable;
+import org.apache.axiom.core.CoreDocument;
+import org.apache.axiom.core.CoreNode;
 
-public interface NodePostProcessor {
-    void postProcessNode(OMSerializable node);
+public interface BuilderListener {
+    /**
+     * Inform the listener that a node has been added to the tree. Note that this method
will also
+     * be invoked for the {@link CoreDocument}.
+     * 
+     * @param node
+     *            the node that has been added
+     * @param depth
+     *            the depth of the node, with 0 corresponding to the document
+     */
+    // TODO: specify if what happens for attributes (including depth)
+    // TODO: an ancestor of the node may have been detached or moved; specify what this means
for the depth
+    void nodeAdded(CoreNode node, int depth);
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java?rev=1729741&r1=1729740&r2=1729741&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXHelper.java
Wed Feb 10 21:25:13 2016
@@ -316,11 +316,11 @@ public class StAXHelper {
         String localName = parser.getLocalName();
         String prefix = normalize(parser.getPrefix());
         if (builderHandler != null) {
-            if (customBuilderForPayload != null && payloadSelector.isPayload(builderHandler.elementLevel+1,
builderHandler.target)
+            if (customBuilderForPayload != null && payloadSelector.isPayload(builderHandler.depth+1,
builderHandler.target)
                     && processWithCustomBuilder(customBuilderForPayload)) {
                 return;
             }
-            if (customBuilders != null && builderHandler.elementLevel < this.maxDepthForCustomBuilders)
{
+            if (customBuilders != null && builderHandler.depth < this.maxDepthForCustomBuilders)
{
                 CustomBuilder customBuilder = customBuilders.get(namespaceURI, localName);
                 if (customBuilder != null && processWithCustomBuilder(customBuilder))
{
                     return;
@@ -460,7 +460,7 @@ public class StAXHelper {
                     throw ex;
                 }
                 if (builderHandler != null && event == XMLStreamConstants.END_DOCUMENT)
{
-                    if (builderHandler.cache && builderHandler.elementLevel != 0)
{
+                    if (builderHandler.cache && builderHandler.depth != 0) {
                         throw new OMException("Unexpected END_DOCUMENT event");
                     }
                     if (autoClose) {

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java?rev=1729741&r1=1729740&r2=1729741&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/StAXOMBuilder.java
Wed Feb 10 21:25:13 2016
@@ -101,7 +101,7 @@ public class StAXOMBuilder extends Abstr
     }
     
     public final void discard(CoreParentNode container) {
-        int targetElementLevel = builderHandler.elementLevel;
+        int targetElementLevel = builderHandler.depth;
         AxiomContainer current = builderHandler.target;
         while (current != container) {
             targetElementLevel--;
@@ -132,14 +132,14 @@ public class StAXOMBuilder extends Abstr
                         discarded(builderHandler.target);
                         boolean found = container == builderHandler.target;
                         builderHandler.target = (AxiomContainer)((OMElement)builderHandler.target).getParent();
-                        builderHandler.elementLevel--;
+                        builderHandler.depth--;
                         if (found) {
                             break loop;
                         }
                     }
                     break;
                 case XMLStreamReader.END_DOCUMENT:
-                    if (skipDepth != 0 || builderHandler.elementLevel != 0) {
+                    if (skipDepth != 0 || builderHandler.depth != 0) {
                         throw new OMException("Unexpected END_DOCUMENT");
                     }
                     if (builderHandler.target != builderHandler.document) {
@@ -213,10 +213,10 @@ public class StAXOMBuilder extends Abstr
             parserAccessed = true;
             // Mark all containers in the hierarchy as discarded because they can no longer
be built
             AxiomContainer current = builderHandler.target;
-            while (builderHandler.elementLevel > 0) {
+            while (builderHandler.depth > 0) {
                 discarded(current);
                 current = (AxiomContainer)((OMElement)current).getParent();
-                builderHandler.elementLevel--;
+                builderHandler.depth--;
             }
             if (current != null && current == builderHandler.document) {
                 discarded(current);
@@ -235,7 +235,7 @@ public class StAXOMBuilder extends Abstr
         // care of lookahead
         helper.parserNext();
         if (log.isDebugEnabled()) {
-            log.debug("Caching disabled; current element level is " + builderHandler.elementLevel);
+            log.debug("Caching disabled; current element level is " + builderHandler.depth);
         }
         return helper.parser;
     }
@@ -246,13 +246,13 @@ public class StAXOMBuilder extends Abstr
         AxiomContainer current = builderHandler.target;
         while (true) {
             discarded(current);
-            if (builderHandler.elementLevel == 0) {
+            if (builderHandler.depth == 0) {
                 if (current != container || current != builderHandler.document) {
                     throw new IllegalStateException();
                 }
                 break;
             }
-            builderHandler.elementLevel--;
+            builderHandler.depth--;
             if (current == container) {
                 break;
             }
@@ -262,7 +262,7 @@ public class StAXOMBuilder extends Abstr
         if (container == builderHandler.document) {
             builderHandler.target = null;
             builderHandler.done = true;
-        } else if (builderHandler.elementLevel == 0 && builderHandler.document ==
null) {
+        } else if (builderHandler.depth == 0 && builderHandler.document == null)
{
             // Consume the remaining event; for the rationale, see StAXOMBuilder#next()
             while (helper.parserNext() != XMLStreamConstants.END_DOCUMENT) {
                 // Just loop
@@ -273,7 +273,7 @@ public class StAXOMBuilder extends Abstr
             builderHandler.target = (AxiomContainer)((OMElement)container).getParent();
         }
         if (log.isDebugEnabled()) {
-            log.debug("Caching re-enabled; new element level: " + builderHandler.elementLevel
+ "; done=" + builderHandler.done);
+            log.debug("Caching re-enabled; new element level: " + builderHandler.depth +
"; done=" + builderHandler.done);
         }
         if (builderHandler.done && helper.autoClose) {
             close();

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java?rev=1729741&r1=1729740&r2=1729741&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/common/builder/StAXSOAPModelBuilder.java
Wed Feb 10 21:25:13 2016
@@ -21,11 +21,11 @@ package org.apache.axiom.soap.impl.commo
 
 import java.io.Closeable;
 
+import org.apache.axiom.core.CoreNode;
 import org.apache.axiom.core.NodeFactory;
 import org.apache.axiom.om.OMException;
-import org.apache.axiom.om.OMSerializable;
 import org.apache.axiom.om.impl.builder.Detachable;
-import org.apache.axiom.om.impl.common.builder.NodePostProcessor;
+import org.apache.axiom.om.impl.common.builder.BuilderListener;
 import org.apache.axiom.om.impl.common.builder.StAXOMBuilder;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPFactory;
@@ -47,11 +47,11 @@ public class StAXSOAPModelBuilder extend
         // The SOAPFactory instance linked to the SOAPMessage is unknown until we reach the
         // SOAPEnvelope. Register a post-processor that does the necessary updates on the
         // SOAPMessage.
-        addNodePostProcessor(new NodePostProcessor() {
+        addListener(new BuilderListener() {
             private AxiomSOAPMessage message;
             
             @Override
-            public void postProcessNode(OMSerializable node) {
+            public void nodeAdded(CoreNode node, int depth) {
                 if (node instanceof AxiomSOAPMessage) {
                     message = (AxiomSOAPMessage)node;
                 } else if (message != null && node instanceof AxiomSOAPEnvelope)
{

Modified: webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java?rev=1729741&r1=1729740&r2=1729741&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
(original)
+++ webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
Wed Feb 10 21:25:13 2016
@@ -26,12 +26,13 @@ import org.apache.abdera.model.Element;
 import org.apache.abdera.parser.ParseException;
 import org.apache.abdera.parser.ParserOptions;
 import org.apache.abdera.util.Constants;
+import org.apache.axiom.core.CoreNode;
 import org.apache.axiom.fom.AbderaNode;
 import org.apache.axiom.fom.impl.FOMNodeFactory;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMSerializable;
 import org.apache.axiom.om.impl.builder.Detachable;
-import org.apache.axiom.om.impl.common.builder.NodePostProcessor;
+import org.apache.axiom.om.impl.common.builder.BuilderListener;
 import org.apache.axiom.om.impl.common.builder.PayloadSelector;
 import org.apache.axiom.om.impl.common.builder.StAXOMBuilder;
 
@@ -46,9 +47,9 @@ public class FOMBuilder extends StAXOMBu
                 factory, PayloadSelector.DEFAULT, null);
         this.parserOptions = parserOptions;
         this.fomfactory = factory;
-        addNodePostProcessor(new NodePostProcessor() {
+        addListener(new BuilderListener() {
             @Override
-            public void postProcessNode(OMSerializable node) {
+            public void nodeAdded(CoreNode node, int depth) {
                 ((AbderaNode)node).setFactory(factory);
             }
         });



Mime
View raw message