Author: veithen Date: Sun Mar 15 13:53:49 2009 New Revision: 754666 URL: http://svn.apache.org/viewvc?rev=754666&view=rev Log: Simplified DOMStAXWrapper#getAttributeLocalName by removing the if statement in the following piece of code:
if (attrib.getNamespace() != null) { returnString = attrib.getLocalName(); } else { returnString = ((Attr) attrib).getNodeName(); } The methods in AttrImpl that are used by this code are defined as follows: public OMNamespace getNamespace() { return this.namespace; } public String getLocalName() { return (this.namespace == null) ? this.attrName : DOMUtil .getLocalName(this.attrName); } public String getNodeName() { return (this.namespace != null && !"".equals(this.namespace.getPrefix()) && !(OMConstants.XMLNS_NS_PREFIX.equals(this.attrName))) ? this.namespace.getPrefix() + ":" + this.attrName : this.attrName; } It can be seen that if getNamespace returns null, then both getLocalName and getNodeName return the same value (attrName). Therefore the code shown above can be simply rewritten as: returnString = attrib.getLocalName(); This is important because this code is the only really DOOM specific piece in DOMStAXWrapper. Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java?rev=754666&r1=754665&r2=754666&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMStAXWrapper.java Sun Mar 15 13:53:49 2009 @@ -37,7 +37,6 @@ import org.apache.axiom.om.impl.builder.StAXBuilder; import org.apache.axiom.om.impl.exception.OMStreamingException; import org.apache.axiom.om.impl.util.NamespaceContextImpl; -import org.w3c.dom.Attr; import javax.activation.DataHandler; import javax.xml.namespace.NamespaceContext; @@ -557,11 +556,7 @@ if (isStartElement() || (currentEvent == ATTRIBUTE)) { OMAttribute attrib = getAttribute((OMElement) lastNode, i); if (attrib != null) { - if (attrib.getNamespace() != null) { - returnString = attrib.getLocalName(); - } else { - returnString = ((Attr) attrib).getNodeName(); - } + returnString = attrib.getLocalName(); } } else { throw new IllegalStateException(