ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1728782 - in /webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom: om/impl/common/builder/ om/impl/common/factory/ om/impl/intf/ soap/impl/factory/
Date Sat, 06 Feb 2016 00:47:56 GMT
Author: veithen
Date: Sat Feb  6 00:47:55 2016
New Revision: 1728782

URL: http://svn.apache.org/viewvc?rev=1728782&view=rev
Log:
Use BuilderHandler to create elements as well.

Modified:
    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/PushOMBuilder.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/om/impl/common/factory/AbstractOMMetaFactory.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/OMFactoryImpl.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/SAXOMBuilder.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/intf/OMFactoryEx.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/factory/SOAPFactoryImpl.java

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=1728782&r1=1728781&r2=1728782&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
Sat Feb  6 00:47:55 2016
@@ -25,6 +25,7 @@ import java.util.Map;
 import org.apache.axiom.core.NodeFactory;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMSerializable;
+import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.common.AxiomSemantics;
 import org.apache.axiom.om.impl.intf.AxiomCDATASection;
 import org.apache.axiom.om.impl.intf.AxiomCharacterDataNode;
@@ -33,6 +34,7 @@ import org.apache.axiom.om.impl.intf.Axi
 import org.apache.axiom.om.impl.intf.AxiomContainer;
 import org.apache.axiom.om.impl.intf.AxiomDocType;
 import org.apache.axiom.om.impl.intf.AxiomDocument;
+import org.apache.axiom.om.impl.intf.AxiomElement;
 import org.apache.axiom.om.impl.intf.AxiomEntityReference;
 import org.apache.axiom.om.impl.intf.AxiomProcessingInstruction;
 import org.apache.commons.logging.Log;
@@ -43,6 +45,7 @@ public final class BuilderHandler {
     
     public final NodeFactory nodeFactory;
     public final Model model;
+    private final OMXMLParserWrapper builder;
     public AxiomContainer target;
     // returns the state of completion
     public boolean done;
@@ -65,9 +68,10 @@ public final class BuilderHandler {
     
     private ArrayList<NodePostProcessor> nodePostProcessors;
 
-    public BuilderHandler(NodeFactory nodeFactory, Model model) {
+    public BuilderHandler(NodeFactory nodeFactory, Model model, OMXMLParserWrapper builder)
{
         this.nodeFactory = nodeFactory;
         this.model = model;
+        this.builder = builder;
     }
 
     public void addNodePostProcessor(NodePostProcessor nodePostProcessor) {
@@ -100,6 +104,17 @@ public final class BuilderHandler {
         addChild(node);
     }
     
+    public AxiomElement startElement(String namespaceURI, String localName, String prefix)
{
+        elementLevel++;
+        AxiomElement element = nodeFactory.createNode(model.determineElementType(
+                target, elementLevel, namespaceURI, localName));
+        element.coreSetBuilder(builder);
+        element.initName(localName, /*ns*/ null, false);
+        addChild(element);
+        target = element;
+        return element;
+    }
+    
     public void processCharacterData(Object data, boolean ignorable) {
         AxiomCharacterDataNode node = nodeFactory.createNode(AxiomCharacterDataNode.class);
         node.coreSetCharacterData(data);

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushOMBuilder.java?rev=1728782&r1=1728781&r2=1728782&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushOMBuilder.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/builder/PushOMBuilder.java
Sat Feb  6 00:47:55 2016
@@ -44,7 +44,7 @@ public class PushOMBuilder extends Abstr
 
     public PushOMBuilder(AxiomSourcedElement root) throws XMLStreamException {
         this.root = root;
-        handler = new BuilderHandler(root.coreGetNodeFactory(), PlainXMLModel.INSTANCE);
+        handler = new BuilderHandler(root.coreGetNodeFactory(), PlainXMLModel.INSTANCE, null);
         factory = (OMFactoryEx)root.getOMFactory();
         // Seed the namespace context with the namespace context from the parent
         OMContainer parent = root.getParent();
@@ -112,9 +112,7 @@ public class PushOMBuilder extends Abstr
             root.validateName(prefix, localName, namespaceURI);
             handler.target = root;
         } else {
-            // We use the createOMElement variant that takes a OMXMLParserWrapper parameter
and
-            // don't pass the namespace. This avoids creation of a namespace declaration.
-            handler.target = factory.createAxiomElement(AxiomElement.class, localName, handler.target,
null);
+            handler.startElement(namespaceURI, localName, prefix);
         }
         if (ns != null) {
             ((OMElement)handler.target).setNamespace(ns, false);

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=1728782&r1=1728781&r2=1728782&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
Sat Feb  6 00:47:55 2016
@@ -138,7 +138,7 @@ public class StAXOMBuilder implements Bu
 
     private StAXOMBuilder(NodeFactory nodeFactory, OMFactory omFactory, XMLStreamReader parser,
String encoding,
             boolean autoClose, Detachable detachable, Closeable closeable, Model model, PayloadSelector
payloadSelector) {
-        handler = new BuilderHandler(nodeFactory, model);
+        handler = new BuilderHandler(nodeFactory, model, this);
         omfactory = (OMFactoryEx)omFactory;
         this.parser = parser;
         this.autoClose = autoClose;
@@ -592,7 +592,7 @@ public class StAXOMBuilder implements Bu
             
             switch (token) {
                 case XMLStreamConstants.START_ELEMENT: {
-                    handler.postProcessNode(createNextOMElement());
+                    createNextOMElement();
                     break;
                 }
                 case XMLStreamConstants.CHARACTERS:
@@ -665,12 +665,8 @@ public class StAXOMBuilder implements Bu
             }
         }
         if (newElement == null) {
-            handler.elementLevel++;
-            newElement = omfactory.createAxiomElement(
-                    handler.model.determineElementType(handler.target, handler.elementLevel,
parser.getNamespaceURI(), parser.getLocalName()),
-                    parser.getLocalName(), handler.target, this);
+            newElement = handler.startElement(parser.getNamespaceURI(), parser.getLocalName(),
parser.getPrefix());
             populateOMElement(newElement);
-            handler.target = (AxiomContainer)newElement;
         }
         return newElement;
     }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java?rev=1728782&r1=1728781&r2=1728782&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AbstractOMMetaFactory.java
Sat Feb  6 00:47:55 2016
@@ -207,9 +207,10 @@ public abstract class AbstractOMMetaFact
         return new StAXOMBuilder(nodeFactory, omFactory, new DOMXMLStreamReader(node, expandEntityReferences),
true, (Detachable)null, (Closeable)null);
     }
 
+    // TODO: don't need the omFactory argument anymore
     public OMXMLParserWrapper createOMBuilder(OMFactory omFactory, SAXSource source,
             boolean expandEntityReferences) {
-        return new SAXOMBuilder(nodeFactory, omFactory, PlainXMLModel.INSTANCE, source, expandEntityReferences);
+        return new SAXOMBuilder(nodeFactory, PlainXMLModel.INSTANCE, source, expandEntityReferences);
     }
 
     public OMXMLParserWrapper createOMBuilder(StAXParserConfiguration configuration,

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/OMFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/OMFactoryImpl.java?rev=1728782&r1=1728781&r2=1728782&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/OMFactoryImpl.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/OMFactoryImpl.java
Sat Feb  6 00:47:55 2016
@@ -216,26 +216,20 @@ public class OMFactoryImpl implements OM
     }
 
     protected final <T extends AxiomElement> T createAxiomElement(Class<T> type,
-            OMContainer parent, String localName, OMNamespace ns, OMXMLParserWrapper builder,
-            boolean generateNSDecl) {
+            OMContainer parent, String localName, OMNamespace ns, OMXMLParserWrapper builder)
{
         T element = createNode(type);
         element.coreSetBuilder(builder);
         if (parent != null) {
             ((AxiomContainer)parent).addChild(element, builder != null);
         }
-        element.initName(localName, ns, generateNSDecl);
+        element.initName(localName, ns, true);
         return element;
     }
 
     public final OMElement createOMElement(String localName, OMNamespace ns, OMContainer
parent) {
-        return createAxiomElement(AxiomElement.class, parent, localName, ns, null, true);
+        return createAxiomElement(AxiomElement.class, parent, localName, ns, null);
     }
 
-    public final <T extends AxiomElement> T createAxiomElement(Class<T> type,
String localName,
-            OMContainer parent, OMXMLParserWrapper builder) {
-        return createAxiomElement(type, parent, localName, null, builder, false);
-    }
-    
     public final OMElement createOMElement(QName qname, OMContainer parent) {
         AxiomElement element = createNode(AxiomElement.class);
         if (parent != null) {

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/SAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/SAXOMBuilder.java?rev=1728782&r1=1728781&r2=1728782&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/SAXOMBuilder.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/SAXOMBuilder.java
Sat Feb  6 00:47:55 2016
@@ -23,7 +23,6 @@ import org.apache.axiom.core.NodeFactory
 import org.apache.axiom.om.OMDocument;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
-import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.common.OMContentHandler;
@@ -32,7 +31,6 @@ import org.apache.axiom.om.impl.common.b
 import org.apache.axiom.om.impl.common.builder.Model;
 import org.apache.axiom.om.impl.intf.AxiomContainer;
 import org.apache.axiom.om.impl.intf.AxiomElement;
-import org.apache.axiom.om.impl.intf.OMFactoryEx;
 import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
 
@@ -45,12 +43,9 @@ public class SAXOMBuilder extends OMCont
     private final BuilderHandler handler;
     private final SAXSource source;
     
-    private final OMFactoryEx factory;
-
-    public SAXOMBuilder(NodeFactory nodeFactory, OMFactory factory, Model model, SAXSource
source, boolean expandEntityReferences) {
+    public SAXOMBuilder(NodeFactory nodeFactory, Model model, SAXSource source, boolean expandEntityReferences)
{
         super(expandEntityReferences);
-        handler = new BuilderHandler(nodeFactory, model);
-        this.factory = (OMFactoryEx)factory;
+        handler = new BuilderHandler(nodeFactory, model, this);
         this.source = source;
     }
     
@@ -149,12 +144,11 @@ public class SAXOMBuilder extends OMCont
 
     protected OMElement createOMElement(String localName,
             String namespaceURI, String prefix, String[] namespaces, int namespaceCount)
{
-        AxiomElement element = factory.createAxiomElement(AxiomElement.class, localName,
handler.target, this);
+        AxiomElement element = handler.startElement(null, localName, null);
         for (int i = 0; i < namespaceCount; i++) {
             element.addNamespaceDeclaration(namespaces[2*i+1], namespaces[2*i]);
         }
         BuilderUtil.setNamespace(element, namespaceURI, prefix);
-        handler.target = element;
         return element;
     }
 

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/intf/OMFactoryEx.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/intf/OMFactoryEx.java?rev=1728782&r1=1728781&r2=1728782&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/intf/OMFactoryEx.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/intf/OMFactoryEx.java
Sat Feb  6 00:47:55 2016
@@ -18,20 +18,14 @@
  */
 package org.apache.axiom.om.impl.intf;
 
-import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMXMLParserWrapper;
 
 /**
  * Interface that is used internally by Axiom and that should not be considered being part
of the
  * public API.
  */
 public interface OMFactoryEx extends OMFactory {
-
-    <T extends AxiomElement> T createAxiomElement(Class<T> type, String localName,
-            OMContainer parent, OMXMLParserWrapper builder);
-
     /**
      * This method is intended only to be used by Axiom intenrals when merging nodes from
different
      * Axiom implementations.

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/factory/SOAPFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/factory/SOAPFactoryImpl.java?rev=1728782&r1=1728781&r2=1728782&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/factory/SOAPFactoryImpl.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/factory/SOAPFactoryImpl.java
Sat Feb  6 00:47:55 2016
@@ -98,7 +98,7 @@ public abstract class SOAPFactoryImpl ex
     }
     
     public final SOAPEnvelope createSOAPEnvelope(OMNamespace ns) {
-        return createAxiomElement(getSOAPHelper().getEnvelopeClass(), null, SOAPConstants.SOAPENVELOPE_LOCAL_NAME,
ns, null, true);
+        return createAxiomElement(getSOAPHelper().getEnvelopeClass(), null, SOAPConstants.SOAPENVELOPE_LOCAL_NAME,
ns, null);
     }
 
     public final SOAPHeader createSOAPHeader(SOAPEnvelope parent) {
@@ -111,11 +111,11 @@ public abstract class SOAPFactoryImpl ex
     }
 
     public final SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns,
SOAPHeader parent) {
-        return createAxiomElement(getSOAPHelper().getHeaderBlockClass(), parent, localName,
ns, null, true);
+        return createAxiomElement(getSOAPHelper().getHeaderBlockClass(), parent, localName,
ns, null);
     }
 
     public final SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns)
{
-        return createAxiomElement(getSOAPHelper().getHeaderBlockClass(), null, localName,
ns, null, true);
+        return createAxiomElement(getSOAPHelper().getHeaderBlockClass(), null, localName,
ns, null);
     }
 
     public final SOAPHeaderBlock createSOAPHeaderBlock(OMDataSource source) {



Mime
View raw message