You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2015/08/31 15:51:50 UTC

svn commit: r1700249 - in /webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common: AxiomAttributeSupport.aj AxiomElementSupport.aj AxiomNamedInformationItemSupport.aj NSUtil.java

Author: veithen
Date: Mon Aug 31 13:51:49 2015
New Revision: 1700249

URL: http://svn.apache.org/r1700249
Log:
handleNamespace should be a static method.

Added:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/NSUtil.java   (with props)
Modified:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.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/AxiomNamedInformationItemSupport.aj

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj?rev=1700249&r1=1700248&r2=1700249&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj Mon Aug 31 13:51:49 2015
@@ -30,7 +30,7 @@ public aspect AxiomAttributeSupport {
     }
     
     public final void AxiomAttribute.setNamespace(OMNamespace namespace, boolean decl) {
-        internalSetNamespace(handleNamespace((AxiomElement)getOwner(), namespace, true, decl));
+        internalSetNamespace(NSUtil.handleNamespace((AxiomElement)getOwner(), namespace, true, decl));
     }
     
     public final void AxiomAttribute.setOMNamespace(OMNamespace omNamespace) {

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=1700249&r1=1700248&r2=1700249&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 Mon Aug 31 13:51:49 2015
@@ -68,7 +68,7 @@ public aspect AxiomElementSupport {
     
     public final void AxiomElement.initName(String localName, OMNamespace ns, boolean generateNSDecl) {
         internalSetLocalName(localName);
-        internalSetNamespace(generateNSDecl ? handleNamespace(this, ns, false, true) : ns);
+        internalSetNamespace(generateNSDecl ? NSUtil.handleNamespace(this, ns, false, true) : ns);
     }
     
     final void AxiomElement.beforeSetLocalName() {
@@ -86,7 +86,7 @@ public aspect AxiomElementSupport {
 
     public final void AxiomElement.setNamespace(OMNamespace namespace, boolean decl) {
         forceExpand();
-        internalSetNamespace(handleNamespace(this, namespace, false, decl));
+        internalSetNamespace(NSUtil.handleNamespace(this, namespace, false, decl));
     }
 
     public final OMElement AxiomElement.getFirstElement() {

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj?rev=1700249&r1=1700248&r2=1700249&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj Mon Aug 31 13:51:49 2015
@@ -23,7 +23,6 @@ import javax.xml.namespace.QName;
 import org.apache.axiom.core.CoreNSAwareNamedNode;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.util.OMSerializerUtil;
 
 public aspect AxiomNamedInformationItemSupport {
     /**
@@ -106,49 +105,6 @@ public aspect AxiomNamedInformationItemS
         }
     }
 
-    public final OMNamespace AxiomNamedInformationItem.handleNamespace(AxiomElement context, OMNamespace ns, boolean attr, boolean decl) {
-        String namespaceURI = ns == null ? "" : ns.getNamespaceURI();
-        String prefix = ns == null ? "" : ns.getPrefix();
-        if (namespaceURI.length() == 0) {
-            if (prefix != null && prefix.length() != 0) {
-                throw new IllegalArgumentException("Cannot bind a prefix to the empty namespace name");
-            }
-            if (!attr && decl) {
-                // Special case: no namespace; we need to generate a namespace declaration only if
-                // there is a conflicting namespace declaration (i.e. a declaration for the default
-                // namespace with a non empty URI) is in scope
-                if (context.getDefaultNamespace() != null) {
-                    context.declareDefaultNamespace("");
-                }
-            }
-            return null;
-        } else {
-            if (attr && prefix != null && prefix.length() == 0) {
-                throw new IllegalArgumentException("An attribute with a namespace must be prefixed");
-            }
-            boolean addNSDecl = false;
-            if (context != null && (decl || prefix == null)) {
-                OMNamespace existingNSDecl = context.findNamespace(namespaceURI, prefix);
-                if (existingNSDecl == null
-                        || (prefix != null && !existingNSDecl.getPrefix().equals(prefix))
-                        || (prefix == null && attr && existingNSDecl.getPrefix().length() == 0)) {
-                    addNSDecl = decl;
-                } else {
-                    prefix = existingNSDecl.getPrefix();
-                    ns = existingNSDecl;
-                }
-            }
-            if (prefix == null) {
-                prefix = OMSerializerUtil.getNextNSPrefix();
-                ns = new OMNamespaceImpl(namespaceURI, prefix);
-            }
-            if (addNSDecl) {
-                context.addNamespaceDeclaration(ns);
-            }
-            return ns;
-        }
-    }
-    
     public final String AxiomNamedInformationItem.coreGetNamespaceURI() {
         OMNamespace namespace = getNamespace();
         return namespace == null ? "" : namespace.getNamespaceURI();

Added: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/NSUtil.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/NSUtil.java?rev=1700249&view=auto
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/NSUtil.java (added)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/NSUtil.java Mon Aug 31 13:51:49 2015
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om.impl.common;
+
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.util.OMSerializerUtil;
+
+public final class NSUtil {
+    private NSUtil() {}
+
+    public static OMNamespace handleNamespace(AxiomElement context, OMNamespace ns, boolean attr, boolean decl) {
+        String namespaceURI = ns == null ? "" : ns.getNamespaceURI();
+        String prefix = ns == null ? "" : ns.getPrefix();
+        if (namespaceURI.length() == 0) {
+            if (prefix != null && prefix.length() != 0) {
+                throw new IllegalArgumentException("Cannot bind a prefix to the empty namespace name");
+            }
+            if (!attr && decl) {
+                // Special case: no namespace; we need to generate a namespace declaration only if
+                // there is a conflicting namespace declaration (i.e. a declaration for the default
+                // namespace with a non empty URI) is in scope
+                if (context.getDefaultNamespace() != null) {
+                    context.declareDefaultNamespace("");
+                }
+            }
+            return null;
+        } else {
+            if (attr && prefix != null && prefix.length() == 0) {
+                throw new IllegalArgumentException("An attribute with a namespace must be prefixed");
+            }
+            boolean addNSDecl = false;
+            if (context != null && (decl || prefix == null)) {
+                OMNamespace existingNSDecl = context.findNamespace(namespaceURI, prefix);
+                if (existingNSDecl == null
+                        || (prefix != null && !existingNSDecl.getPrefix().equals(prefix))
+                        || (prefix == null && attr && existingNSDecl.getPrefix().length() == 0)) {
+                    addNSDecl = decl;
+                } else {
+                    prefix = existingNSDecl.getPrefix();
+                    ns = existingNSDecl;
+                }
+            }
+            if (prefix == null) {
+                prefix = OMSerializerUtil.getNextNSPrefix();
+                ns = new OMNamespaceImpl(namespaceURI, prefix);
+            }
+            if (addNSDecl) {
+                context.addNamespaceDeclaration(ns);
+            }
+            return ns;
+        }
+    }
+}

Propchange: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/NSUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native