ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1729025 - in /webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push: NamespaceHelper.java SerializerImpl.java
Date Sun, 07 Feb 2016 19:46:54 GMT
Author: veithen
Date: Sun Feb  7 19:46:53 2016
New Revision: 1729025

URL: http://svn.apache.org/viewvc?rev=1729025&view=rev
Log:
Turn NamespaceHelper into a XmlHandlerWrapper.

Modified:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/NamespaceHelper.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/SerializerImpl.java

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/NamespaceHelper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/NamespaceHelper.java?rev=1729025&r1=1729024&r2=1729025&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/NamespaceHelper.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/NamespaceHelper.java
Sun Feb  7 19:46:53 2016
@@ -21,8 +21,9 @@ package org.apache.axiom.om.impl.common.
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.impl.stream.StreamException;
+import org.apache.axiom.om.impl.stream.XmlHandlerWrapper;
 
-final class NamespaceHelper {
+final class NamespaceHelper extends XmlHandlerWrapper {
     private static final String XSI_URI = "http://www.w3.org/2001/XMLSchema-instance";
     private static final String XSI_LOCAL_NAME = "type";
     
@@ -31,17 +32,18 @@ final class NamespaceHelper {
     private final boolean namespaceRepairing;
 
     NamespaceHelper(SerializerImpl serializer, OMElement contextElement, boolean namespaceRepairing)
{
+        super(serializer);
         this.serializer = serializer;
         this.contextElement = contextElement;
         this.namespaceRepairing = namespaceRepairing;
     }
 
-    void internalStartElement(String namespaceURI, String localName, String prefix) throws
StreamException {
-        serializer.startElement(namespaceURI, localName, prefix);
+    public void startElement(String namespaceURI, String localName, String prefix) throws
StreamException {
+        super.startElement(namespaceURI, localName, prefix);
         mapNamespace(prefix, namespaceURI, false, false);
     }
     
-    void internalProcessAttribute(String namespaceURI, String localName, String prefix, String
value, String type, boolean specified) throws StreamException {
+    public void processAttribute(String namespaceURI, String localName, String prefix, String
value, String type, boolean specified) throws StreamException {
         mapNamespace(prefix, namespaceURI, false, true);
         if (namespaceRepairing && contextElement != null && namespaceURI.equals(XSI_URI)
&& localName.equals(XSI_LOCAL_NAME)) {
             String trimmedValue = value.trim();
@@ -53,7 +55,11 @@ final class NamespaceHelper {
                 }
             }
         }
-        serializer.processAttribute(namespaceURI, localName, prefix, value, type, specified);
+        super.processAttribute(namespaceURI, localName, prefix, value, type, specified);
+    }
+    
+    public void processNamespaceDeclaration(String prefix, String namespaceURI) throws StreamException
{
+        mapNamespace(prefix, namespaceURI, true, false);
     }
     
     /**
@@ -70,7 +76,7 @@ final class NamespaceHelper {
      *            the name of an element or attribute
      * @param attr
      */
-    void mapNamespace(String prefix, String namespaceURI, boolean fromDecl, boolean attr)
throws StreamException {
+    private void mapNamespace(String prefix, String namespaceURI, boolean fromDecl, boolean
attr) throws StreamException {
         if (namespaceRepairing) {
             // If the prefix and namespace are already associated, no generation is needed
             if (serializer.isAssociated(prefix, namespaceURI)) {
@@ -84,12 +90,12 @@ final class NamespaceHelper {
             }
             
             // Add the namespace if the prefix is not associated.
-            serializer.processNamespaceDeclaration(prefix, namespaceURI);
+            super.processNamespaceDeclaration(prefix, namespaceURI);
         } else {
             // If namespace repairing is disabled, only output namespace declarations that
appear
             // explicitly in the input
             if (fromDecl) {
-                serializer.processNamespaceDeclaration(prefix, namespaceURI);
+                super.processNamespaceDeclaration(prefix, namespaceURI);
             }
         }
     }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/SerializerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/SerializerImpl.java?rev=1729025&r1=1729024&r2=1729025&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/SerializerImpl.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/push/SerializerImpl.java
Sun Feb  7 19:46:53 2016
@@ -43,11 +43,12 @@ import org.apache.axiom.om.impl.common.u
 import org.apache.axiom.om.impl.intf.Serializer;
 import org.apache.axiom.om.impl.intf.TextContent;
 import org.apache.axiom.om.impl.stream.StreamException;
+import org.apache.axiom.om.impl.stream.XmlHandler;
 import org.apache.axiom.util.stax.XMLStreamReaderUtils;
 
 public abstract class SerializerImpl implements Serializer {
     private final OMSerializable root;
-    private final NamespaceHelper helper;
+    private final XmlHandler handler;
     private final boolean preserveNamespaceContext;
     
     /**
@@ -76,16 +77,16 @@ public abstract class SerializerImpl imp
         } else {
             contextElement = null;
         }
-        helper = new NamespaceHelper(this, contextElement, namespaceRepairing);
+        handler = new NamespaceHelper(this, contextElement, namespaceRepairing);
         this.preserveNamespaceContext = preserveNamespaceContext;
     }
 
     public final void serializeStartpart(OMElement element) throws StreamException {
         OMNamespace ns = element.getNamespace();
         if (ns == null) {
-            helper.internalStartElement("", element.getLocalName(), "");
+            handler.startElement("", element.getLocalName(), "");
         } else {
-            helper.internalStartElement(ns.getNamespaceURI(), element.getLocalName(), ns.getPrefix());
+            handler.startElement(ns.getNamespaceURI(), element.getLocalName(), ns.getPrefix());
         }
         if (preserveNamespaceContext && element == root) {
             // Maintain a set of the prefixes we have already seen. This is required to take
into
@@ -97,7 +98,7 @@ public abstract class SerializerImpl imp
                 for (Iterator<OMNamespace> it = current.getAllDeclaredNamespaces();
it.hasNext(); ) {
                     ns = it.next();
                     if (seenPrefixes.add(ns.getPrefix())) {
-                        helper.mapNamespace(ns.getPrefix(), ns.getNamespaceURI(), true, false);
+                        handler.processNamespaceDeclaration(ns.getPrefix(), ns.getNamespaceURI());
                     }
                 }
                 OMContainer parent = current.getParent();
@@ -109,16 +110,16 @@ public abstract class SerializerImpl imp
         } else {
             for (Iterator<OMNamespace> it = element.getAllDeclaredNamespaces(); it.hasNext();
) {
                 ns = it.next();
-                helper.mapNamespace(ns.getPrefix(), ns.getNamespaceURI(), true, false);
+                handler.processNamespaceDeclaration(ns.getPrefix(), ns.getNamespaceURI());
             }
         }
         for (Iterator<OMAttribute> it = element.getAllAttributes(); it.hasNext(); )
{
             OMAttribute attr = it.next();
             ns = attr.getNamespace();
             if (ns == null) {
-                helper.internalProcessAttribute("", attr.getLocalName(), "", attr.getAttributeValue(),
attr.getAttributeType(), ((CoreAttribute)attr).coreGetSpecified());
+                handler.processAttribute("", attr.getLocalName(), "", attr.getAttributeValue(),
attr.getAttributeType(), ((CoreAttribute)attr).coreGetSpecified());
             } else {
-                helper.internalProcessAttribute(ns.getNamespaceURI(), attr.getLocalName(),
ns.getPrefix(), attr.getAttributeValue(), attr.getAttributeType(), ((CoreAttribute)attr).coreGetSpecified());
+                handler.processAttribute(ns.getNamespaceURI(), attr.getLocalName(), ns.getPrefix(),
attr.getAttributeValue(), attr.getAttributeType(), ((CoreAttribute)attr).coreGetSpecified());
             }
         }
         attributesCompleted();
@@ -141,12 +142,12 @@ public abstract class SerializerImpl imp
                     processDocumentTypeDeclaration(dtdReader.getRootName(), dtdReader.getPublicId(),
dtdReader.getSystemId(), reader.getText());
                     break;
                 case XMLStreamReader.START_ELEMENT:
-                    helper.internalStartElement(normalize(reader.getNamespaceURI()), reader.getLocalName(),
normalize(reader.getPrefix()));
+                    handler.startElement(normalize(reader.getNamespaceURI()), reader.getLocalName(),
normalize(reader.getPrefix()));
                     for (int i=0, count=reader.getNamespaceCount(); i<count; i++) {
-                        helper.mapNamespace(normalize(reader.getNamespacePrefix(i)), normalize(reader.getNamespaceURI(i)),
true, false);
+                        handler.processNamespaceDeclaration(normalize(reader.getNamespacePrefix(i)),
normalize(reader.getNamespaceURI(i)));
                     }
                     for (int i=0, count=reader.getAttributeCount(); i<count; i++) {
-                        helper.internalProcessAttribute(
+                        handler.processAttribute(
                                 normalize(reader.getAttributeNamespace(i)),
                                 reader.getAttributeLocalName(i),
                                 normalize(reader.getAttributePrefix(i)),



Mime
View raw message