You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by ra...@apache.org on 2006/01/09 18:35:26 UTC

svn commit: r367347 - /xml/security/trunk/src/org/apache/xml/security/utils/XMLUtils.java

Author: raul
Date: Mon Jan  9 09:35:07 2006
New Revision: 367347

URL: http://svn.apache.org/viewcvs?rev=367347&view=rev
Log:
Use == instead of .equals() for interned string comparison(namespaces).

Modified:
    xml/security/trunk/src/org/apache/xml/security/utils/XMLUtils.java

Modified: xml/security/trunk/src/org/apache/xml/security/utils/XMLUtils.java
URL: http://svn.apache.org/viewcvs/xml/security/trunk/src/org/apache/xml/security/utils/XMLUtils.java?rev=367347&r1=367346&r2=367347&view=diff
==============================================================================
--- xml/security/trunk/src/org/apache/xml/security/utils/XMLUtils.java (original)
+++ xml/security/trunk/src/org/apache/xml/security/utils/XMLUtils.java Mon Jan  9 09:35:07 2006
@@ -53,7 +53,13 @@
 
       // we don't allow instantiation
    }
-
+   public static Element getNextElement(Node el) {
+	   while ((el!=null) && (el.getNodeType()!=Node.ELEMENT_NODE)) {
+		   el=el.getNextSibling();
+	   }
+	   return (Element)el;
+	   
+   }
    
    /**
     * @param rootNode
@@ -234,9 +240,8 @@
          return element;
       } 
          Element element = doc.createElementNS(Constants.SignatureSpecNS,
-                                               ds + ":" + elementName);
-
-         element.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + ds,
+                                               ds + ":" + elementName);         
+         element.setAttributeNS(Constants.NamespaceSpecNS, ElementProxy.getDefaultPrefixBindings(Constants.SignatureSpecNS),
                                 Constants.SignatureSpecNS);
 
          return element;
@@ -256,7 +261,7 @@
            String localName) {
 
       if ((element == null) ||
-          !Constants.SignatureSpecNS.equals(element.getNamespaceURI()) ){
+          Constants.SignatureSpecNS!=element.getNamespaceURI() ){
          return false;
       }
 
@@ -279,7 +284,7 @@
            String localName) {
 
       if ((element == null) || 
-            !EncryptionConstants.EncryptionSpecNS.equals(element.getNamespaceURI()) 
+            EncryptionConstants.EncryptionSpecNS!=element.getNamespaceURI() 
           ){
          return false;
       }
@@ -466,7 +471,7 @@
 
              	for (int i = 0; i < attributesLength; i++) {
              		Attr currentAttr = (Attr) attributes.item(i); 
-             		if (!namespaceNs.equals(currentAttr.getNamespaceURI()))
+             		if (namespaceNs!=currentAttr.getNamespaceURI())
              			continue;
              		if (childElement.hasAttributeNS(namespaceNs,
     							currentAttr.getLocalName())) {
@@ -508,7 +513,7 @@
    public static Element selectDsNode(Node sibling, String nodeName, int number) {
 	while (sibling!=null) {
 		if (nodeName.equals(sibling.getLocalName())
-				&& Constants.SignatureSpecNS.equals(sibling.getNamespaceURI())) {
+				&& Constants.SignatureSpecNS==sibling.getNamespaceURI()) {
 			if (number==0){
 				return (Element)sibling;
 			}
@@ -529,7 +534,7 @@
    public static Element selectXencNode(Node sibling, String nodeName, int number) {
 	while (sibling!=null) {
 		if (nodeName.equals(sibling.getLocalName())
-				&& EncryptionConstants.EncryptionSpecNS.equals(sibling.getNamespaceURI())) {
+				&& EncryptionConstants.EncryptionSpecNS==sibling.getNamespaceURI()) {
 			if (number==0){
 				return (Element)sibling;
 			}
@@ -588,7 +593,7 @@
    public static Element selectNode(Node sibling, String uri,String nodeName, int number) {
 	while (sibling!=null) {
 		if (nodeName.equals(sibling.getLocalName())
-				&& uri.equals(sibling.getNamespaceURI())) {
+				&& uri==sibling.getNamespaceURI()) {
 			if (number==0){
 				return (Element)sibling;
 			}
@@ -605,9 +610,42 @@
     * @return nodes with the constrain
     */
    public static Element[] selectDsNodes(Node sibling,String nodeName) {
-     return selectNodes(sibling,Constants.SignatureSpecNS,nodeName);
+     return selectConsecutiveNodes(sibling,Constants.SignatureSpecNS,nodeName);
+   }
+   /**
+    * @param sibling
+    * @param uri
+    * @param nodeName
+    * @return nodes with the constrain
+    */
+    public static Element[] selectConsecutiveNodes(Node sibling,String uri,String nodeName) {
+    	int size=20;
+    	Element[] a= new Element[size];
+    	int curr=0;
+    	//List list=new ArrayList();
+    	while (sibling!=null) {
+    		if (nodeName.equals(sibling.getLocalName())
+    				&& uri==sibling.getNamespaceURI()) {
+    			do {
+    				a[curr++]=(Element)sibling;
+    				if (size<=curr) {
+    					int cursize= size<<2;
+    					Element []cp=new Element[cursize];
+    					System.arraycopy(a,0,cp,0,size);
+    					a=cp;
+    					size=cursize;
+    				}
+    				sibling=sibling.getNextSibling();
+    			} while ((sibling!=null) && nodeName.equals(sibling.getLocalName())
+				&& uri==sibling.getNamespaceURI());    			
+    			break;
+    		}
+    		sibling=sibling.getNextSibling();
+    	}
+    	Element []af=new Element[curr];
+    	System.arraycopy(a,0,af,0,curr);
+    	return af;
    }
-   
    /**
     * @param sibling
     * @param uri
@@ -621,7 +659,7 @@
     	//List list=new ArrayList();
     	while (sibling!=null) {
     		if (nodeName.equals(sibling.getLocalName())
-    				&& uri.equals(sibling.getNamespaceURI())) {
+    				&& uri==sibling.getNamespaceURI()) {
     			a[curr++]=(Element)sibling;
     			if (size<=curr) {
     				int cursize= size<<2;