ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1728946 - in /webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common: ./ builder/ factory/
Date Sun, 07 Feb 2016 10:58:55 GMT
Author: veithen
Date: Sun Feb  7 10:58:55 2016
New Revision: 1728946

URL: http://svn.apache.org/viewvc?rev=1728946&view=rev
Log:
Make BuilderHandler implement the Handler interface.

Modified:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Handler.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/OMContentHandler.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/SAXResultContentHandler.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/StAXOMBuilder.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/SAXOMBuilder.java

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Handler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Handler.java?rev=1728946&r1=1728945&r2=1728946&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Handler.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/Handler.java
Sun Feb  7 10:58:55 2016
@@ -18,7 +18,6 @@
  */
 package org.apache.axiom.om.impl.common;
 
-// TODO: transitional interface that should eventually converge with BuilderHandler
 public interface Handler {
     void startDocument(String inputEncoding, String xmlVersion, String xmlEncoding, boolean
standalone);
     
@@ -37,11 +36,13 @@ public interface Handler {
     
     void attributesCompleted();
     
-    void createOMText(String text, int type);
+    void processCharacterData(Object data, boolean ignorable);
     
     void createProcessingInstruction(String piTarget, String piData);
     
     void createComment(String content);
     
+    void createCDATASection(String content);
+    
     void createEntityReference(String name, String replacementText);
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/OMContentHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/OMContentHandler.java?rev=1728946&r1=1728945&r2=1728946&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/OMContentHandler.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/OMContentHandler.java
Sun Feb  7 10:58:55 2016
@@ -31,6 +31,8 @@ import org.xml.sax.ext.LexicalHandler;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.xml.stream.XMLStreamConstants;
+
 public final class OMContentHandler implements ContentHandler, LexicalHandler, DeclHandler,
DTDHandler {
     private final Handler handler;
     private final boolean expandEntityReferences;
@@ -291,7 +293,20 @@ public final class OMContentHandler impl
     private void characterData(char[] ch, int start, int length, int nodeType)
             throws SAXException {
         if (!inEntityReference) {
-            handler.createOMText(new String(ch, start, length), nodeType);
+            String text = new String(ch, start, length);
+            switch (nodeType) {
+                case XMLStreamConstants.CHARACTERS:
+                    handler.processCharacterData(text, false);
+                    break;
+                case XMLStreamConstants.SPACE:
+                    handler.processCharacterData(text, true);
+                    break;
+                case XMLStreamConstants.CDATA:
+                    handler.createCDATASection(text);
+                    break;
+                default:
+                    throw new IllegalArgumentException();
+            }
         }
     }
 

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/SAXResultContentHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/SAXResultContentHandler.java?rev=1728946&r1=1728945&r2=1728946&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/SAXResultContentHandler.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/SAXResultContentHandler.java
Sun Feb  7 10:58:55 2016
@@ -90,8 +90,14 @@ public final  class SAXResultContentHand
     public void attributesCompleted() {
     }
 
-    public void createOMText(String text, int type) {
-        factory.createOMText(target, text, type);
+    @Override
+    public void processCharacterData(Object data, boolean ignorable) {
+        factory.createOMText(target, data.toString(), ignorable ? OMNode.SPACE_NODE : OMNode.TEXT_NODE);
+    }
+
+    @Override
+    public void createCDATASection(String content) {
+        factory.createOMText(target, content, OMNode.CDATA_SECTION_NODE);
     }
 
     public void createProcessingInstruction(String piTarget, String piData) {

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=1728946&r1=1728945&r2=1728946&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
Sun Feb  7 10:58:55 2016
@@ -32,6 +32,7 @@ import org.apache.axiom.om.OMNamespace;
 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.common.Handler;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.apache.axiom.om.impl.intf.AxiomAttribute;
 import org.apache.axiom.om.impl.intf.AxiomCDATASection;
@@ -50,7 +51,7 @@ import org.apache.axiom.util.namespace.S
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-public final class BuilderHandler {
+public final class BuilderHandler implements Handler {
     private static final Log log = LogFactory.getLog(BuilderHandler.class);
     
     private static final OMNamespace DEFAULT_NS = new OMNamespaceImpl("", "");
@@ -160,7 +161,7 @@ public final class BuilderHandler {
         }
     }
     
-    public AxiomElement startElement(String namespaceURI, String localName, String prefix)
{
+    public void startElement(String namespaceURI, String localName, String prefix) {
         elementLevel++;
         AxiomElement element;
         OMNamespace ns = nsCache.getOMNamespace(namespaceURI, prefix);
@@ -181,7 +182,6 @@ public final class BuilderHandler {
             nsContext.startScope();
             ensureNamespaceDeclared(ns);
         }
-        return element;
     }
     
     public void endElement() {

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=1728946&r1=1728945&r2=1728946&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
Sun Feb  7 10:58:55 2016
@@ -587,7 +587,7 @@ public class StAXOMBuilder extends Abstr
             }
         }
         if (newElement == null) {
-            newElement = handler.startElement(namespaceURI, localName, prefix);
+            handler.startElement(namespaceURI, localName, prefix);
             for (int i = 0, count = parser.getNamespaceCount(); i < count; i++) {
                 handler.createNamespaceDeclaration(
                         normalize(parser.getNamespacePrefix(i)),

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=1728946&r1=1728945&r2=1728946&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
Sun Feb  7 10:58:55 2016
@@ -21,7 +21,6 @@ package org.apache.axiom.om.impl.common.
 
 import org.apache.axiom.core.NodeFactory;
 import org.apache.axiom.om.OMException;
-import org.apache.axiom.om.impl.common.Handler;
 import org.apache.axiom.om.impl.common.OMContentHandler;
 import org.apache.axiom.om.impl.common.builder.AbstractPushBuilder;
 import org.apache.axiom.om.impl.common.builder.Model;
@@ -30,10 +29,9 @@ import org.xml.sax.XMLReader;
 
 import java.io.IOException;
 
-import javax.xml.stream.XMLStreamConstants;
 import javax.xml.transform.sax.SAXSource;
 
-public final class SAXOMBuilder extends AbstractPushBuilder implements Handler {
+public final class SAXOMBuilder extends AbstractPushBuilder {
     private final boolean expandEntityReferences;
     private final SAXSource source;
     
@@ -53,7 +51,7 @@ public final class SAXOMBuilder extends
 
     public int next() {
         XMLReader reader = source.getXMLReader();
-        OMContentHandler contentHandler = new OMContentHandler(this, expandEntityReferences);
+        OMContentHandler contentHandler = new OMContentHandler(handler, expandEntityReferences);
         reader.setContentHandler(contentHandler);
         reader.setDTDHandler(contentHandler);
         try {
@@ -75,57 +73,4 @@ public final class SAXOMBuilder extends
         }
         return -1;
     }
-
-    public void createDocumentTypeDeclaration(String rootName, String publicId,
-            String systemId, String internalSubset) {
-        handler.createDocumentTypeDeclaration(rootName, publicId, systemId, internalSubset);
-    }
-
-    public void startElement(String namespaceURI, String localName, String prefix) {
-        handler.startElement(namespaceURI, localName, prefix);
-    }
-
-    public void endElement() {
-        handler.endElement();
-    }
-
-    public void createOMText(String text, int type) {
-        switch (type) {
-            case XMLStreamConstants.CHARACTERS:
-                handler.processCharacterData(text, false);
-                break;
-            case XMLStreamConstants.SPACE:
-                handler.processCharacterData(text, true);
-                break;
-            case XMLStreamConstants.CDATA:
-                handler.createCDATASection(text);
-                break;
-            default:
-                throw new IllegalArgumentException();
-        }
-    }
-
-    public void createProcessingInstruction(String piTarget, String piData) {
-        handler.createProcessingInstruction(piTarget, piData);
-    }
-
-    public void createComment(String content) {
-        handler.createComment(content);
-    }
-
-    public void createEntityReference(String name, String replacementText) {
-        handler.createEntityReference(name, replacementText);
-    }
-
-    public void createAttribute(String namespaceURI, String localName, String prefix, String
value, String type, boolean specified) {
-        handler.createAttribute(namespaceURI, localName, prefix, value, type, specified);
-    }
-
-    public void createNamespaceDeclaration(String prefix, String namespaceURI) {
-        handler.createNamespaceDeclaration(prefix, namespaceURI);
-    }
-
-    public void attributesCompleted() {
-        handler.attributesCompleted();
-    }
 }



Mime
View raw message