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/06/07 23:50:04 UTC
svn commit: r412569 -
/xml/security/trunk/src/org/apache/xml/security/utils/XMLUtils.java
Author: raul
Date: Wed Jun 7 14:50:04 2006
New Revision: 412569
URL: http://svn.apache.org/viewvc?rev=412569&view=rev
Log:
Cache signature elements names (prefix:tagname).
Less object creation.
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/viewvc/xml/security/trunk/src/org/apache/xml/security/utils/XMLUtils.java?rev=412569&r1=412568&r2=412569&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 Wed Jun 7 14:50:04 2006
@@ -21,8 +21,10 @@
import java.io.IOException;
import java.io.OutputStream;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Map;
import java.util.Set;
import org.apache.xml.security.c14n.CanonicalizationException;
@@ -214,6 +216,8 @@
}
+ static final String dsPrefix= Constants.getSignatureSpecNSprefix();
+ static Map namePrefixes=new HashMap();
/**
* Creates an Element in the XML Signature specification namespace.
*
@@ -227,10 +231,9 @@
if (doc == null) {
throw new RuntimeException("Document is null");
}
+
- String ds = Constants.getSignatureSpecNSprefix();
-
- if ((ds == null) || (ds.length() == 0)) {
+ if ((dsPrefix == null) || (dsPrefix.length() == 0)) {
Element element = doc.createElementNS(Constants.SignatureSpecNS,
elementName);
@@ -239,9 +242,16 @@
return element;
}
- Element element = doc.createElementNS(Constants.SignatureSpecNS,
- ds + ":" + elementName);
- element.setAttributeNS(Constants.NamespaceSpecNS, ElementProxy.getDefaultPrefixBindings(Constants.SignatureSpecNS),
+ String namePrefix=(String) namePrefixes.get(elementName);
+ if (namePrefix==null) {
+ StringBuffer tag=new StringBuffer(dsPrefix);
+ tag.append(':');
+ tag.append(elementName);
+ namePrefix=tag.toString();
+ namePrefixes.put(elementName,namePrefix);
+ }
+ Element element = doc.createElementNS(Constants.SignatureSpecNS, namePrefix);
+ element.setAttributeNS(Constants.NamespaceSpecNS, dsPrefix,
Constants.SignatureSpecNS);
return element;