Author: chinthaka
Date: Fri Dec  1 09:57:58 2006
New Revision: 481323

URL: http://svn.apache.org/viewvc?view=rev&rev=481323
Log:
Some more code improvements

Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/util/XMLComparator.java
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java?view=diff&rev=481323&r1=481322&r2=481323
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
 Fri Dec  1 09:57:58 2006
@@ -55,9 +55,9 @@
      */
     public OMAttributeImpl(String localName, OMNamespace ns, String value, 
             OMFactory factory) {
-        setLocalName(localName);
-        setAttributeValue(value);
-        setOMNamespace(ns);
+        this.localName = localName;
+        this.value = value;
+        this.namespace = ns; 
         this.factory = factory;
     }
 

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?view=diff&rev=481323&r1=481322&r2=481323
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
 Fri Dec  1 09:57:58 2006
@@ -148,8 +148,9 @@
         // first try to find a namespace from the scope
         String namespaceURI = qname.getNamespaceURI();
         if (namespaceURI != null && namespaceURI.length() > 0) {
+            String prefix = qname.getPrefix();
             ns = findNamespace(qname.getNamespaceURI(),
-                    qname.getPrefix());
+                    prefix);
 
             /**
              * What is left now is
@@ -157,7 +158,6 @@
              *  2. nsURI != null, (parent doesn't have an ns with given URI), 
but ns = null
              */
             if (ns == null) {
-                String prefix = qname.getPrefix();
                 if ("".equals(prefix)) {
                     prefix = OMSerializerUtil.getNextNSPrefix();
                 }
@@ -493,10 +493,12 @@
             this.attributes = new LinkedHashMap(5);
         }
         OMNamespace namespace = attr.getNamespace();
-        if (namespace != null && namespace.getNamespaceURI() != null && 
-                !"".equals(namespace.getNamespaceURI()) && 
-                this.findNamespace(namespace.getNamespaceURI(), 
namespace.getPrefix()) == null) {
-            this.declareNamespace(namespace.getNamespaceURI(), 
namespace.getPrefix());
+        String nsURI;
+        String nsPrefix;
+        if (namespace != null && (nsURI = namespace.getNamespaceURI()) != null 
&&
+                !"".equals(nsURI) &&
+                this.findNamespace(nsURI, (nsPrefix = namespace.getPrefix())) 
== null) {
+            this.declareNamespace(nsURI, nsPrefix);
         }
 
         attributes.put(attr.getQName(), attr);
@@ -519,14 +521,14 @@
      */
     public OMAttribute addAttribute(String attributeName, String value,
                                     OMNamespace ns) {
-        OMNamespace namespace;
+        OMNamespace namespace = null;
         if (ns != null) {
             namespace = findNamespace(ns.getNamespaceURI(), ns.getPrefix());
             if (namespace == null) {
                 namespace = new OMNamespaceImpl(ns.getNamespaceURI(), 
ns.getPrefix());
             }
         }
-        return addAttribute(new OMAttributeImpl(attributeName, ns, value, 
this.factory));
+        return addAttribute(new OMAttributeImpl(attributeName, namespace, 
value, this.factory));
     }
 
     /**
@@ -709,9 +711,10 @@
         while (child != null) {
             if (child.getType() == OMNode.TEXT_NODE) {
                 textNode = (OMText) child;
-                if (textNode.getText() != null &&
-                        !"".equals(textNode.getText())) {
-                    childText += textNode.getText();
+                String textValue = textNode.getText();
+                if (textValue != null &&
+                        !"".equals(textValue)) {
+                    childText += textValue;
                 }
             }
             child = child.getNextOMSibling();
@@ -728,13 +731,14 @@
         while (child != null) {
             if (child.getType() == OMNode.TEXT_NODE) {
                 textNode = (OMText) child;
-                if (textNode.getText() != null &&
-                        !"".equals(textNode.getText())) {
+                String textValue = textNode.getText();
+                if (textValue != null &&
+                        !"".equals(textValue)) {
                     String namespaceURI = 
textNode.getTextAsQName().getNamespaceURI();
                     if (namespaceURI != null && !"".equals(namespaceURI)) {
                         return textNode.getTextAsQName();
                     }
-                    childText += textNode.getText();
+                    childText += textValue;
                 }
             }
             child = child.getNextOMSibling();
@@ -756,9 +760,10 @@
         while (child != null) {
             if (child.getType() == OMNode.TEXT_NODE) {
                 textNode = (OMText) child;
-                if (textNode.getText() != null &&
-                        !"".equals(textNode.getText().trim())) {
-                    childText += textNode.getText().trim();
+                String textValue = textNode.getText();
+                if (textValue != null &&
+                        !"".equals(textValue.trim())) {
+                    childText += textValue.trim();
                 }
             }
             child = child.getNextOMSibling();

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java?view=diff&rev=481323&r1=481322&r2=481323
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNavigator.java
 Fri Dec  1 09:57:58 2006
@@ -135,7 +135,7 @@
                }
        } else {
                OMContainer parent = next.getParent();
-               OMNode nextSibling = _getNextSibling(next);
+               OMNode nextSibling = getNextSibling(next);
                if (nextSibling != null) {
                        next = nextSibling;
                } else if ((parent != null) && parent.isComplete() && !(parent 
instanceof OMDocument)) {
@@ -171,7 +171,7 @@
      * @param node
      * @return next sibling or null
      */
-    private OMNode _getNextSibling(OMNode node) {
+    private OMNode getNextSibling(OMNode node) {
        if (node instanceof OMSourcedElementImpl) {
                return node.getNextOMSibling();
        } else {

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/util/XMLComparator.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/util/XMLComparator.java?view=diff&rev=481323&r1=481322&r2=481323
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/util/XMLComparator.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/util/XMLComparator.java
 Fri Dec  1 09:57:58 2006
@@ -27,6 +27,10 @@
 import java.util.Iterator;
 import java.util.Vector;
 
+
+/**
+ * @deprecated This class is outdated. Please use XmlUnit to compate two xml 
files.
+ */
 public class XMLComparator {
     /**
      * Eran Chinthaka ([EMAIL PROTECTED])

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java?view=diff&rev=481323&r1=481322&r2=481323
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
 Fri Dec  1 09:57:58 2006
@@ -88,9 +88,10 @@
 
     private void inferFactory() {
         if (ns != null) {
-            if 
(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns.getNamespaceURI())) {
+            String namespaceURI = ns.getNamespaceURI();
+            if 
(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
                 factory = OMAbstractFactory.getSOAP12Factory();
-            } else if 
(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns.getNamespaceURI())) {
+            } else if 
(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
                 factory = OMAbstractFactory.getSOAP11Factory();
             }
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to