ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1704120 - in /webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common: ./ serializer/pull/ serializer/push/ util/
Date Sun, 20 Sep 2015 10:18:36 GMT
Author: veithen
Date: Sun Sep 20 10:18:36 2015
New Revision: 1704120

URL: http://svn.apache.org/viewvc?rev=1704120&view=rev
Log:
Eliminate some package cycles in om-aspects.

Added:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/util/
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/util/OMDataSourceUtil.java
      - copied, changed from r1704088, webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/OMDataSourceUtil.java
Removed:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/OMDataSourceUtil.java
Modified:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomContainerSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomDocumentSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomSourcedElementSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/Serializer.java

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomContainerSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomContainerSupport.aj?rev=1704120&r1=1704119&r2=1704120&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomContainerSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomContainerSupport.aj
Sun Sep 20 10:18:36 2015
@@ -30,6 +30,8 @@ import javax.xml.transform.sax.SAXResult
 import javax.xml.transform.sax.SAXSource;
 
 import org.apache.axiom.core.Axis;
+import org.apache.axiom.ext.stax.datahandler.DataHandlerReader;
+import org.apache.axiom.om.DeferredParsingException;
 import org.apache.axiom.om.NodeUnavailableException;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
@@ -43,13 +45,16 @@ import org.apache.axiom.om.OMXMLStreamRe
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
 import org.apache.axiom.om.impl.builder.OMFactoryEx;
 import org.apache.axiom.om.impl.builder.StAXBuilder;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.common.serializer.pull.OMXMLStreamReaderExAdapter;
 import org.apache.axiom.om.impl.common.serializer.pull.PullSerializer;
 import org.apache.axiom.om.impl.common.serializer.push.OutputException;
+import org.apache.axiom.om.impl.common.serializer.push.Serializer;
 import org.apache.axiom.om.impl.common.serializer.push.sax.XMLReaderImpl;
 import org.apache.axiom.om.impl.common.serializer.push.stax.StAXSerializer;
 import org.apache.axiom.om.util.OMXMLStreamReaderValidator;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.util.stax.XMLStreamReaderUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.xml.sax.InputSource;
@@ -342,6 +347,76 @@ public aspect AxiomContainerSupport {
         }
     }
 
+    final void AxiomContainer.serializeChildren(Serializer serializer, OMOutputFormat format,
boolean cache) throws OutputException {
+        if (getState() == AxiomContainer.DISCARDED) {
+            StAXBuilder builder = (StAXBuilder)getBuilder();
+            if (builder != null) {
+                builder.debugDiscarded(this);
+            }
+            throw new NodeUnavailableException();
+        }
+        if (cache) {
+            AxiomChildNode child = (AxiomChildNode)getFirstOMChild();
+            while (child != null) {
+                child.internalSerialize(serializer, format, true);
+                child = (AxiomChildNode)child.getNextOMSibling();
+            }
+        } else {
+            // First, recursively serialize all child nodes that have already been created
+            AxiomChildNode child = (AxiomChildNode)coreGetFirstChildIfAvailable();
+            while (child != null) {
+                child.internalSerialize(serializer, format, cache);
+                child = (AxiomChildNode)child.coreGetNextSiblingIfAvailable();
+            }
+            // Next, if the container is incomplete, disable caching (temporarily)
+            // and serialize the nodes that have not been built yet by copying the
+            // events from the underlying XMLStreamReader.
+            if (!isComplete() && getBuilder() != null) {
+                StAXOMBuilder builder = (StAXOMBuilder)getBuilder();
+                XMLStreamReader reader = builder.disableCaching();
+                DataHandlerReader dataHandlerReader = XMLStreamReaderUtils.getDataHandlerReader(reader);
+                boolean first = true;
+                int depth = 0;
+                loop: while (true) {
+                    int event;
+                    if (first) {
+                        event = reader.getEventType();
+                        first = false;
+                    } else {
+                        try {
+                            event = reader.next();
+                        } catch (XMLStreamException ex) {
+                            throw new DeferredParsingException(ex);
+                        }
+                    }
+                    switch (event) {
+                        case XMLStreamReader.START_ELEMENT:
+                            depth++;
+                            break;
+                        case XMLStreamReader.END_ELEMENT:
+                            if (depth == 0) {
+                                break loop;
+                            } else {
+                                depth--;
+                            }
+                            break;
+                        case XMLStreamReader.END_DOCUMENT:
+                            if (depth != 0) {
+                                // If we get here, then we have seen a START_ELEMENT event
without
+                                // a matching END_ELEMENT
+                                throw new IllegalStateException();
+                            }
+                            break loop;
+                    }
+                    // Note that we don't copy the final END_ELEMENT/END_DOCUMENT event for
+                    // the container. This is the responsibility of the caller.
+                    serializer.copyEvent(reader, dataHandlerReader);
+                }
+                builder.reenableCaching(this);
+            }
+        }
+    }
+
     public final void AxiomContainer.notifyChildComplete() {
         if (getState() == INCOMPLETE && getBuilder() == null) {
             Iterator iterator = getChildren();

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomDocumentSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomDocumentSupport.aj?rev=1704120&r1=1704119&r2=1704120&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomDocumentSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomDocumentSupport.aj
Sun Sep 20 10:18:36 2015
@@ -72,7 +72,7 @@ public aspect AxiomDocumentSupport {
                 serializer.writeStartDocument(encoding, version);
             }
         }
-        serializer.serializeChildren(this, format, cache);
+        serializeChildren(serializer, format, cache);
         serializer.writeEndDocument();
     }
 

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj?rev=1704120&r1=1704119&r2=1704120&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
Sun Sep 20 10:18:36 2015
@@ -509,7 +509,7 @@ public aspect AxiomElementSupport {
     public final void AxiomElement.defaultInternalSerialize(Serializer serializer, OMOutputFormat
format,
             boolean cache) throws OutputException {
         serializer.serializeStartpart(this);
-        serializer.serializeChildren(this, format, cache);
+        serializeChildren(serializer, format, cache);
         serializer.writeEndElement();
     }
 

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomSourcedElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomSourcedElementSupport.aj?rev=1704120&r1=1704119&r2=1704120&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomSourcedElementSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomSourcedElementSupport.aj
Sun Sep 20 10:18:36 2015
@@ -31,10 +31,10 @@ import org.apache.axiom.om.OMXMLStreamRe
 import org.apache.axiom.om.QNameAwareOMDataSource;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.common.AxiomSourcedElement;
-import org.apache.axiom.om.impl.common.OMDataSourceUtil;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.apache.axiom.om.impl.common.serializer.push.OutputException;
 import org.apache.axiom.om.impl.common.serializer.push.Serializer;
+import org.apache.axiom.om.impl.common.util.OMDataSourceUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java?rev=1704120&r1=1704119&r2=1704120&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java
Sun Sep 20 10:18:36 2015
@@ -63,7 +63,7 @@ import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.builder.StAXBuilder;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.common.OMDataSourceUtil;
+import org.apache.axiom.om.impl.common.util.OMDataSourceUtil;
 import org.apache.axiom.util.namespace.MapBasedNamespaceContext;
 import org.apache.axiom.util.stax.XMLEventUtils;
 import org.apache.commons.logging.Log;

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/Serializer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/Serializer.java?rev=1704120&r1=1704119&r2=1704120&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/Serializer.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/Serializer.java
Sun Sep 20 10:18:36 2015
@@ -31,20 +31,14 @@ import org.apache.axiom.ext.stax.DTDRead
 import org.apache.axiom.ext.stax.datahandler.DataHandlerProvider;
 import org.apache.axiom.ext.stax.datahandler.DataHandlerReader;
 import org.apache.axiom.om.DeferredParsingException;
-import org.apache.axiom.om.NodeUnavailableException;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMSerializable;
-import org.apache.axiom.om.impl.builder.StAXBuilder;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.common.AxiomContainer;
-import org.apache.axiom.om.impl.common.AxiomChildNode;
-import org.apache.axiom.om.impl.common.OMDataSourceUtil;
+import org.apache.axiom.om.impl.common.util.OMDataSourceUtil;
 import org.apache.axiom.util.stax.XMLStreamReaderUtils;
 
 public abstract class Serializer {
@@ -129,7 +123,7 @@ public abstract class Serializer {
         finishStartElement();
     }
     
-    private void copyEvent(XMLStreamReader reader, DataHandlerReader dataHandlerReader) throws
OutputException {
+    public final void copyEvent(XMLStreamReader reader, DataHandlerReader dataHandlerReader)
throws OutputException {
         try {
             int eventType = reader.getEventType();
             switch (eventType) {
@@ -258,76 +252,6 @@ public abstract class Serializer {
         }
     }
     
-    public final void serializeChildren(AxiomContainer container, OMOutputFormat format,
boolean cache) throws OutputException {
-        if (container.getState() == AxiomContainer.DISCARDED) {
-            StAXBuilder builder = (StAXBuilder)container.getBuilder();
-            if (builder != null) {
-                builder.debugDiscarded(container);
-            }
-            throw new NodeUnavailableException();
-        }
-        if (cache) {
-            AxiomChildNode child = (AxiomChildNode)container.getFirstOMChild();
-            while (child != null) {
-                child.internalSerialize(this, format, true);
-                child = (AxiomChildNode)child.getNextOMSibling();
-            }
-        } else {
-            // First, recursively serialize all child nodes that have already been created
-            AxiomChildNode child = (AxiomChildNode)container.coreGetFirstChildIfAvailable();
-            while (child != null) {
-                child.internalSerialize(this, format, cache);
-                child = (AxiomChildNode)child.coreGetNextSiblingIfAvailable();
-            }
-            // Next, if the container is incomplete, disable caching (temporarily)
-            // and serialize the nodes that have not been built yet by copying the
-            // events from the underlying XMLStreamReader.
-            if (!container.isComplete() && container.getBuilder() != null) {
-                StAXOMBuilder builder = (StAXOMBuilder)container.getBuilder();
-                XMLStreamReader reader = builder.disableCaching();
-                DataHandlerReader dataHandlerReader = XMLStreamReaderUtils.getDataHandlerReader(reader);
-                boolean first = true;
-                int depth = 0;
-                loop: while (true) {
-                    int event;
-                    if (first) {
-                        event = reader.getEventType();
-                        first = false;
-                    } else {
-                        try {
-                            event = reader.next();
-                        } catch (XMLStreamException ex) {
-                            throw new DeferredParsingException(ex);
-                        }
-                    }
-                    switch (event) {
-                        case XMLStreamReader.START_ELEMENT:
-                            depth++;
-                            break;
-                        case XMLStreamReader.END_ELEMENT:
-                            if (depth == 0) {
-                                break loop;
-                            } else {
-                                depth--;
-                            }
-                            break;
-                        case XMLStreamReader.END_DOCUMENT:
-                            if (depth != 0) {
-                                // If we get here, then we have seen a START_ELEMENT event
without
-                                // a matching END_ELEMENT
-                                throw new IllegalStateException();
-                            }
-                            break loop;
-                    }
-                    // Note that we don't copy the final END_ELEMENT/END_DOCUMENT event for
-                    // the container. This is the responsibility of the caller.
-                    copyEvent(reader, dataHandlerReader);
-                }
-                builder.reenableCaching(container);
-            }
-        }
-    }
-
     /**
      * Serialize the given data source.
      * 

Copied: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/util/OMDataSourceUtil.java
(from r1704088, webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/OMDataSourceUtil.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/util/OMDataSourceUtil.java?p2=webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/util/OMDataSourceUtil.java&p1=webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/OMDataSourceUtil.java&r1=1704088&r2=1704120&rev=1704120&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/OMDataSourceUtil.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/util/OMDataSourceUtil.java
Sun Sep 20 10:18:36 2015
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.axiom.om.impl.common;
+package org.apache.axiom.om.impl.common.util;
 
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMDataSourceExt;



Mime
View raw message