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/26 22:41:56 UTC

svn commit: r1698000 - in /webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom: DeferredNamespace.java OMSourcedElementImpl.java

Author: veithen
Date: Wed Aug 26 20:41:55 2015
New Revision: 1698000

URL: http://svn.apache.org/r1698000
Log:
Move DeferredNamespace out of OMSourcedElementImpl.

Added:
    webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/DeferredNamespace.java   (with props)
Modified:
    webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java

Added: webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/DeferredNamespace.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/DeferredNamespace.java?rev=1698000&view=auto
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/DeferredNamespace.java (added)
+++ webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/DeferredNamespace.java Wed Aug 26 20:41:55 2015
@@ -0,0 +1,72 @@
+/*
+ * 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.llom;
+
+import org.apache.axiom.om.OMNamespace;
+
+final class DeferredNamespace implements OMNamespace {
+    private final OMSourcedElementImpl element;
+    
+    final String uri;
+    
+    DeferredNamespace(OMSourcedElementImpl omSourcedElementImpl, String ns) {
+        element = omSourcedElementImpl;
+        this.uri = ns;
+    }
+
+    public boolean equals(String uri, String prefix) {
+        String thisPrefix = getPrefix();
+        return (this.uri.equals(uri) &&
+                (thisPrefix == null ? prefix == null :
+                        thisPrefix.equals(prefix)));
+    }
+
+    public String getName() {
+        return uri;
+    }
+
+    public String getNamespaceURI() {
+        return uri;
+    }
+
+    public String getPrefix() {
+        if (!element.isExpanded()) {
+            element.forceExpand();
+        }
+        OMNamespace actualNS = element.getNamespace();
+        return actualNS == null ? "" : actualNS.getPrefix();
+    }
+    
+    public int hashCode() {
+        String thisPrefix = getPrefix();
+        return uri.hashCode() ^ (thisPrefix != null ? thisPrefix.hashCode() : 0);
+    }
+    
+    public boolean equals(Object obj) {
+        if (!(obj instanceof OMNamespace)) {
+            return false;
+        }
+        OMNamespace other = (OMNamespace)obj;
+        String otherPrefix = other.getPrefix();
+        String thisPrefix = getPrefix();
+        return (uri.equals(other.getNamespaceURI()) &&
+                (thisPrefix == null ? otherPrefix == null :
+                        thisPrefix.equals(otherPrefix)));
+    }
+}
\ No newline at end of file

Propchange: webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/DeferredNamespace.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=1698000&r1=1697999&r2=1698000&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java Wed Aug 26 20:41:55 2015
@@ -122,7 +122,7 @@ public class OMSourcedElementImpl extend
         } else {
             // Create a deferred namespace that forces an expand to get the prefix
             String uri = ns.getNamespaceURI();
-            definedNamespace = new DeferredNamespace(uri);
+            definedNamespace = new DeferredNamespace(this, uri);
         }
         definedNamespaceSet = true;
     }
@@ -148,7 +148,7 @@ public class OMSourcedElementImpl extend
         } else {
             // Create a deferred namespace that forces an expand to get the prefix
             String uri = qName.getNamespaceURI();
-            definedNamespace = uri.length() == 0 ? null : new DeferredNamespace(uri);
+            definedNamespace = uri.length() == 0 ? null : new DeferredNamespace(this, uri);
         }
         definedNamespaceSet = true;
     }
@@ -362,7 +362,7 @@ public class OMSourcedElementImpl extend
                         String prefix = ((QNameAwareOMDataSource)dataSource).getPrefix();
                         if (prefix == null) {
                             // Prefix is unknown
-                            definedNamespace = new DeferredNamespace(namespaceURI);
+                            definedNamespace = new DeferredNamespace(this, namespaceURI);
                         } else {
                             definedNamespace = new OMNamespaceImpl(namespaceURI, prefix);
                         }
@@ -424,7 +424,7 @@ public class OMSourcedElementImpl extend
         targetOMSE.internalSetLocalName(internalGetLocalName());
         targetOMSE.definedNamespaceSet = definedNamespaceSet;
         if (definedNamespace instanceof DeferredNamespace) {
-            targetOMSE.definedNamespace = targetOMSE.new DeferredNamespace(definedNamespace.getNamespaceURI());
+            targetOMSE.definedNamespace = new DeferredNamespace(targetOMSE, definedNamespace.getNamespaceURI());
         } else {
             targetOMSE.definedNamespace = definedNamespace;
         }
@@ -510,7 +510,7 @@ public class OMSourcedElementImpl extend
             coreSetBuilder(null);
             if (isLossyPrefix(dataSource)) {
                 // Create a deferred namespace that forces an expand to get the prefix
-                definedNamespace = new DeferredNamespace(definedNamespace.getNamespaceURI());
+                definedNamespace = new DeferredNamespace(this, definedNamespace.getNamespaceURI());
             }
             return oldDS;
         }
@@ -531,56 +531,6 @@ public class OMSourcedElementImpl extend
         }
     }
     
-    class DeferredNamespace implements OMNamespace {
-        
-        final String uri;
-        
-        DeferredNamespace(String ns) {
-            this.uri = ns;
-        }
-
-        public boolean equals(String uri, String prefix) {
-            String thisPrefix = getPrefix();
-            return (this.uri.equals(uri) &&
-                    (thisPrefix == null ? prefix == null :
-                            thisPrefix.equals(prefix)));
-        }
-
-        public String getName() {
-            return uri;
-        }
-
-        public String getNamespaceURI() {
-            return uri;
-        }
-
-        public String getPrefix() {
-            if (!isExpanded()) {
-                forceExpand();
-            }
-            OMNamespace actualNS = getNamespace();
-            return actualNS == null ? "" : actualNS.getPrefix();
-        }
-        
-        public int hashCode() {
-            String thisPrefix = getPrefix();
-            return uri.hashCode() ^ (thisPrefix != null ? thisPrefix.hashCode() : 0);
-        }
-        
-        public boolean equals(Object obj) {
-            if (!(obj instanceof OMNamespace)) {
-                return false;
-            }
-            OMNamespace other = (OMNamespace)obj;
-            String otherPrefix = other.getPrefix();
-            String thisPrefix = getPrefix();
-            return (uri.equals(other.getNamespaceURI()) &&
-                    (thisPrefix == null ? otherPrefix == null :
-                            thisPrefix.equals(otherPrefix)));
-        }
-        
-    }
-
     public Object getObject(Class dataSourceClass) {
         if (dataSource == null || isExpanded || !dataSourceClass.isInstance(dataSource)) {
             return null;