Return-Path: X-Original-To: apmail-ws-commits-archive@minotaur.apache.org Delivered-To: apmail-ws-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A02F8D16E for ; Wed, 5 Sep 2012 08:20:51 +0000 (UTC) Received: (qmail 53509 invoked by uid 500); 5 Sep 2012 08:20:51 -0000 Delivered-To: apmail-ws-commits-archive@ws.apache.org Received: (qmail 53421 invoked by uid 500); 5 Sep 2012 08:20:48 -0000 Mailing-List: contact commits-help@ws.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ws.apache.org Delivered-To: mailing list commits@ws.apache.org Received: (qmail 53354 invoked by uid 99); 5 Sep 2012 08:20:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Sep 2012 08:20:46 +0000 X-ASF-Spam-Status: No, hits=-1998.0 required=5.0 tests=ALL_TRUSTED,FB_GET_MEDS X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Sep 2012 08:20:44 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id AB2562388A3F; Wed, 5 Sep 2012 08:19:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1381057 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/ axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ Date: Wed, 05 Sep 2012 08:19:36 -0000 To: commits@ws.apache.org From: veithen@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120905081936.AB2562388A3F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: veithen Date: Wed Sep 5 08:19:35 2012 New Revision: 1381057 URL: http://svn.apache.org/viewvc?rev=1381057&view=rev Log: Use a single set of constants (namely the ones already defined by the JRE) for "http://www.w3.org/2000/xmlns/" and "xmlns". They are only relevant for DOM, so we don't need to define our own constants. Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSDeclIterator.java webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java?rev=1381057&r1=1381056&r2=1381057&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java Wed Sep 5 08:19:35 2012 @@ -19,6 +19,8 @@ package org.apache.axiom.om; +import javax.xml.XMLConstants; + /** Interface OMConstants */ public interface OMConstants { @@ -60,7 +62,14 @@ public interface OMConstants { String XMLNS_URI = "http://www.w3.org/XML/1998/namespace"; + /** + * @deprecated Use {@link XMLConstants#XMLNS_ATTRIBUTE_NS_URI} instead. + */ String XMLNS_NS_URI = "http://www.w3.org/2000/xmlns/"; + + /** + * @deprecated Use {@link XMLConstants#XMLNS_ATTRIBUTE} instead. + */ String XMLNS_NS_PREFIX = "xmlns"; String XMLNS_PREFIX = Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java?rev=1381057&r1=1381056&r2=1381057&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java Wed Sep 5 08:19:35 2012 @@ -34,6 +34,7 @@ import org.w3c.dom.Node; import org.w3c.dom.Text; import org.w3c.dom.TypeInfo; +import javax.xml.XMLConstants; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; @@ -108,9 +109,9 @@ public class AttrImpl extends RootNode i this(ownerDocument, factory); this.localName = name; //If this is a default namespace attr - if (OMConstants.XMLNS_NS_PREFIX.equals(name)) { + if (XMLConstants.XMLNS_ATTRIBUTE.equals(name)) { this.namespace = new OMNamespaceImpl( - OMConstants.XMLNS_NS_URI, OMConstants.XMLNS_NS_PREFIX); + XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE); } this.type = OMConstants.XMLATTRTYPE_CDATA; } @@ -139,7 +140,7 @@ public class AttrImpl extends RootNode i public String getNodeName() { return (this.namespace != null && !"".equals(this.namespace.getPrefix()) && - !(OMConstants.XMLNS_NS_PREFIX.equals(this.localName))) + !(XMLConstants.XMLNS_ATTRIBUTE.equals(this.localName))) ? this.namespace.getPrefix() + ":" + this.localName : this.localName; } @@ -207,10 +208,10 @@ public class AttrImpl extends RootNode i // / public String getName() { if (this.namespace != null) { - if ((OMConstants.XMLNS_NS_PREFIX.equals(this.localName))) { + if ((XMLConstants.XMLNS_ATTRIBUTE.equals(this.localName))) { return this.localName; - } else if (OMConstants.XMLNS_NS_URI.equals(this.namespace.getNamespaceURI())) { - return OMConstants.XMLNS_NS_PREFIX + ":" + this.localName; + } else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(this.namespace.getNamespaceURI())) { + return XMLConstants.XMLNS_ATTRIBUTE + ":" + this.localName; } else if (this.namespace.getPrefix().equals("")) { return this.localName; } else { Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1381057&r1=1381056&r2=1381057&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java Wed Sep 5 08:19:35 2012 @@ -20,7 +20,6 @@ package org.apache.axiom.om.impl.dom; import org.apache.axiom.om.OMCloneOptions; -import org.apache.axiom.om.OMConstants; import org.apache.axiom.om.OMDocument; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; @@ -52,6 +51,7 @@ import org.w3c.dom.NodeList; import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.Text; +import javax.xml.XMLConstants; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import java.io.OutputStream; @@ -135,7 +135,7 @@ public class DocumentImpl extends RootNo String localName = DOMUtil.getLocalName(qualifiedName); String prefix = DOMUtil.getPrefix(qualifiedName); - if (!OMConstants.XMLNS_NS_PREFIX.equals(localName)) { + if (!XMLConstants.XMLNS_ATTRIBUTE.equals(localName)) { this.checkQName(prefix, localName); } else { return this.createAttribute(localName); @@ -288,7 +288,7 @@ public class DocumentImpl extends RootNo Attr attr = (Attr) sourceAttrs.item(index); if (attr.getNamespaceURI() != null && !attr.getNamespaceURI().equals( - OMConstants.XMLNS_NS_URI)) { + XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) { Attr newAttr = (Attr) importNode(attr, true); newElement.setAttributeNodeNS(newAttr); } else { // if (attr.getLocalName() == null) { @@ -308,7 +308,7 @@ public class DocumentImpl extends RootNo newNode = createAttribute(importedNode.getNodeName()); } else { //Check whether it is a default ns decl - if (OMConstants.XMLNS_NS_PREFIX.equals(importedNode.getNodeName())) { + if (XMLConstants.XMLNS_ATTRIBUTE.equals(importedNode.getNodeName())) { newNode = createAttribute(importedNode.getNodeName()); } else { String ns = importedNode.getNamespaceURI(); Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1381057&r1=1381056&r2=1381057&view=diff ============================================================================== --- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java (original) +++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java Wed Sep 5 08:19:35 2012 @@ -50,6 +50,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.TypeInfo; +import javax.xml.XMLConstants; import javax.xml.namespace.NamespaceContext; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; @@ -364,14 +365,14 @@ public class ElementImpl extends ParentN // check whether the attr is in use attrImpl.checkInUse(); - if (attr.getNodeName().startsWith(OMConstants.XMLNS_NS_PREFIX + ":")) { + if (attr.getNodeName().startsWith(XMLConstants.XMLNS_ATTRIBUTE + ":")) { // This is a ns declaration this.declareNamespace(attr.getNodeValue(), DOMUtil .getLocalName(attr.getName())); //Don't add this to attr list, since its a namespace return attr; - } else if (attr.getNodeName().equals(OMConstants.XMLNS_NS_PREFIX)) { + } else if (attr.getNodeName().equals(XMLConstants.XMLNS_ATTRIBUTE)) { this.declareDefaultNamespace(attr.getValue()); //Don't add this to attr list, since its a namespace @@ -398,10 +399,10 @@ public class ElementImpl extends ParentN null); throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg); } - if (name.startsWith(OMConstants.XMLNS_NS_PREFIX + ":")) { + if (name.startsWith(XMLConstants.XMLNS_ATTRIBUTE + ":")) { // This is a ns declaration this.declareNamespace(value, DOMUtil.getLocalName(name)); - } else if (name.equals(OMConstants.XMLNS_NS_PREFIX)) { + } else if (name.equals(XMLConstants.XMLNS_ATTRIBUTE)) { this.declareDefaultNamespace(value); } else { this.setAttributeNode(new AttrImpl(ownerDocument(), name, value, @@ -610,7 +611,7 @@ public class ElementImpl extends ParentN } public OMNamespace addNamespaceDeclaration(String uri, String prefix) { - setAttributeNS(OMConstants.XMLNS_NS_URI, prefix.length() == 0 ? OMConstants.XMLNS_NS_PREFIX : OMConstants.XMLNS_NS_PREFIX + ":" + prefix, uri); + setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix.length() == 0 ? XMLConstants.XMLNS_ATTRIBUTE : XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix, uri); return new OMNamespaceImpl(uri, prefix); } @@ -630,15 +631,15 @@ public class ElementImpl extends ParentN throw new IllegalArgumentException("Cannot bind a prefix to the empty namespace name"); } - if (!namespace.getPrefix().startsWith(OMConstants.XMLNS_NS_PREFIX)) { - setAttributeNS(OMConstants.XMLNS_NS_URI, prefix.length() == 0 ? OMConstants.XMLNS_NS_PREFIX : OMConstants.XMLNS_NS_PREFIX + ":" + prefix, namespace.getNamespaceURI()); + if (!namespace.getPrefix().startsWith(XMLConstants.XMLNS_ATTRIBUTE)) { + setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix.length() == 0 ? XMLConstants.XMLNS_ATTRIBUTE : XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix, namespace.getNamespaceURI()); } } return namespace; } public void undeclarePrefix(String prefix) { - setAttributeNS(OMConstants.XMLNS_NS_URI, prefix.length() == 0 ? OMConstants.XMLNS_NS_PREFIX : OMConstants.XMLNS_NS_PREFIX + ":" + prefix, ""); + setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix.length() == 0 ? XMLConstants.XMLNS_ATTRIBUTE : XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix, ""); } public OMNamespace declareNamespace(String uri, String prefix) { @@ -658,12 +659,12 @@ public class ElementImpl extends ParentN "the namespace information of the element"); } - setAttributeNS(OMConstants.XMLNS_NS_URI, OMConstants.XMLNS_NS_PREFIX, uri); + setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE, uri); return new OMNamespaceImpl(uri, ""); } public OMNamespace getDefaultNamespace() { - Attr decl = (Attr)attributes.getNamedItemNS(OMConstants.XMLNS_NS_URI, OMConstants.XMLNS_NS_PREFIX); + Attr decl = (Attr)attributes.getNamedItemNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE); if (decl != null) { String uri = decl.getValue(); return uri.length() == 0 ? null : new OMNamespaceImpl(uri, ""); @@ -713,7 +714,7 @@ public class ElementImpl extends ParentN public OMNamespace findNamespaceURI(String prefix) { if (attributes != null) { - Attr decl = (Attr)attributes.getNamedItemNS(OMConstants.XMLNS_NS_URI, prefix.length() == 0 ? OMConstants.XMLNS_NS_PREFIX : prefix); + Attr decl = (Attr)attributes.getNamedItemNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix.length() == 0 ? XMLConstants.XMLNS_ATTRIBUTE : prefix); if (decl != null) { String namespaceURI = decl.getValue(); if (prefix != null && prefix.length() > 0 && namespaceURI.length() == 0) { @@ -740,8 +741,8 @@ public class ElementImpl extends ParentN private OMNamespace findDeclaredNamespace(String uri, String prefix) { if (uri == null) { - Attr decl = (Attr)attributes.getNamedItemNS(OMConstants.XMLNS_NS_URI, - prefix.length() == 0 ? OMConstants.XMLNS_NS_PREFIX : prefix); + Attr decl = (Attr)attributes.getNamedItemNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, + prefix.length() == 0 ? XMLConstants.XMLNS_ATTRIBUTE : prefix); return decl == null ? null : new OMNamespaceImpl(decl.getValue(), prefix); } // If the prefix is available and uri is available and its the xml @@ -754,7 +755,7 @@ public class ElementImpl extends ParentN if (prefix == null || "".equals(prefix)) { for (int i=0; i 0 ? value : null; - } else if (attrPrefix != null && attrPrefix.equals("xmlns") + } else if (attrPrefix != null && attrPrefix.equals(XMLConstants.XMLNS_ATTRIBUTE) && attr.getLocalName().equals(specifiedPrefix)) { return value.length() > 0 ? value : null; }