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 2005/04/02 21:18:54 UTC
cvs commit: xml-security/src/org/apache/xml/security/utils XMLUtils.java
raul 2005/04/02 11:18:54
Modified: src/org/apache/xml/security/utils XMLUtils.java
Log:
Remove log creation, classForName, nodeTypeString printing and all xerces and xalan version detection functions.
Revision Changes Path
1.46 +0 -276 xml-security/src/org/apache/xml/security/utils/XMLUtils.java
Index: XMLUtils.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/utils/XMLUtils.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- XMLUtils.java 2 Oct 2004 02:18:04 -0000 1.45
+++ XMLUtils.java 2 Apr 2005 19:18:54 -0000 1.46
@@ -21,8 +21,6 @@
import java.io.IOException;
import java.io.OutputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
@@ -47,10 +45,6 @@
*/
public class XMLUtils {
- /** {@link org.apache.commons.logging} logging facility */
- static org.apache.commons.logging.Log log =
- org.apache.commons.logging.LogFactory.getLog(XMLUtils.class.getName());
-
/**
* Constructor XMLUtils
*
@@ -115,276 +109,6 @@
}
return;
}
- /**
- * Method getXalanVersion
- *
- * @return
- */
- public static String getXalanVersion() {
-
- String version = XMLUtils.getXalan1Version();
-
- if (version != null) {
- return version;
- }
-
- version = XMLUtils.getXalan20Version();
-
- if (version != null) {
- return version;
- }
-
- version = XMLUtils.getXalan2Version();
-
- if (version != null) {
- return version;
- }
-
- return "Apache Xalan not installed";
-
- // return "Apache " + org.apache.xalan.processor.XSLProcessorVersion.S_VERSION;
- // return "Apache " + org.apache.xalan.Version.getVersion();
- }
-
- /**
- * Method getXercesVersion
- *
- * @return
- */
- public static String getXercesVersion() {
-
- String version = XMLUtils.getXerces1Version();
-
- if (version != null) {
- return version;
- }
-
- version = XMLUtils.getXerces2Version();
-
- if (version != null) {
- return version;
- }
-
- return "Apache Xerces not installed";
-
- // return "Apache " + org.apache.xerces.impl.Version.fVersion;
- // return "Apache " + org.apache.xerces.framework.Version.fVersion;
- }
-
- /**
- * Method getXalan1Version
- *
- * @return
- */
- private static String getXalan1Version() {
-
- try {
- final String XALAN1_VERSION_CLASS =
- "org.apache.xalan.xslt.XSLProcessorVersion";
- Class clazz = classForName(XALAN1_VERSION_CLASS);
-
- // Found Xalan-J 1.x, grab it's version fields
- StringBuffer buf = new StringBuffer();
- Field f = clazz.getField("PRODUCT");
-
- buf.append(f.get(null));
- buf.append(';');
-
- f = clazz.getField("LANGUAGE");
-
- buf.append(f.get(null));
- buf.append(';');
-
- f = clazz.getField("S_VERSION");
-
- buf.append(f.get(null));
- buf.append(';');
-
- return buf.toString();
- } catch (Exception e1) {
- return null;
- }
- }
-
- /**
- * Method getXalan20Version
- *
- * @return
- */
- private static String getXalan20Version() {
-
- try {
-
- // NOTE: This is the new Xalan 2.2+ version class
- final String XALAN2_2_VERSION_CLASS = "org.apache.xalan.Version";
- final String XALAN2_2_VERSION_METHOD = "getVersion";
- final Class noArgs[] = new Class[0];
- Class clazz = classForName(XALAN2_2_VERSION_CLASS);
- Method method = clazz.getMethod(XALAN2_2_VERSION_METHOD, noArgs);
- Object returnValue = method.invoke(null, new Object[0]);
-
- return (String) returnValue;
- } catch (Exception e2) {
- return null;
- }
- }
-
- /**
- * Method getXalan2Version
- *
- * @return
- */
- private static String getXalan2Version() {
-
- try {
-
- // NOTE: This is the old Xalan 2.0, 2.1, 2.2 version class,
- // is being replaced by class below
- final String XALAN2_VERSION_CLASS =
- "org.apache.xalan.processor.XSLProcessorVersion";
- Class clazz = classForName(XALAN2_VERSION_CLASS);
-
- // Found Xalan-J 2.x, grab it's version fields
- StringBuffer buf = new StringBuffer();
- Field f = clazz.getField("S_VERSION");
-
- buf.append(f.get(null));
-
- return buf.toString();
- } catch (Exception e2) {
- return null;
- }
- }
-
- /**
- * Method getXerces1Version
- *
- * @return
- */
- private static String getXerces1Version() {
-
- try {
- final String XERCES1_VERSION_CLASS =
- "org.apache.xerces.framework.Version";
- Class clazz = classForName(XERCES1_VERSION_CLASS);
-
- // Found Xerces-J 1.x, grab it's version fields
- Field f = clazz.getField("fVersion");
- String parserVersion = (String) f.get(null);
-
- return parserVersion;
- } catch (Exception e) {
- return null;
- }
- }
-
- /**
- * Method getXerces2Version
- *
- * @return
- */
- private static String getXerces2Version() {
-
- try {
- final String XERCES2_VERSION_CLASS = "org.apache.xerces.impl.Version";
- Class clazz = classForName(XERCES2_VERSION_CLASS);
-
- // Found Xerces-J 2.x, grab it's version fields
- Field f = clazz.getField("fVersion");
- String parserVersion = (String) f.get(null);
-
- return parserVersion;
- } catch (Exception e) {
- return null;
- }
- }
-
- /**
- * Worker method to load a class.
- * Factor out loading classes for future use and JDK differences.
- * Copied from javax.xml.*.FactoryFinder
- * @param className name of class to load from
- * an appropriate classLoader
- * @return the class asked for
- * @throws ClassNotFoundException
- */
- public static Class classForName(String className)
- throws ClassNotFoundException {
-
- ClassLoader classLoader = findClassLoader();
-
- if (classLoader == null) {
- return Class.forName(className);
- }
- return classLoader.loadClass(className);
- }
-
- /**
- * Worker method to figure out which ClassLoader to use.
- * For JDK 1.2 and later use the context ClassLoader.
- * Copied from javax.xml.*.FactoryFinder
- * @return the appropriate ClassLoader
- */
- protected static ClassLoader findClassLoader() {
-
- Method m = null;
-
- try {
- m = Thread.class.getMethod("getContextClassLoader", new Class[]{});
- } catch (NoSuchMethodException e) {
-
- // Assume that we are running JDK 1.1, use the current ClassLoader
- return XMLUtils.class.getClassLoader();
- }
-
- try {
- return (ClassLoader) m.invoke(Thread.currentThread(), new Object[]{});
- } catch (Exception e) {
- throw new RuntimeException(e.toString());
- }
- }
-
-
- /**
- * Method spitOutVersions
- *
- * @param log
- */
- public static void spitOutVersions(org.apache.commons.logging.Log log) {
- if (log.isDebugEnabled()) {
- log.debug(XMLUtils.getXercesVersion());
- log.debug(XMLUtils.getXalanVersion());
- }
- }
-
- /** Field nodeTypeString */
- private static String[] nodeTypeString = new String[]{ "", "ELEMENT",
- "ATTRIBUTE",
- "TEXT_NODE",
- "CDATA_SECTION",
- "ENTITY_REFERENCE",
- "ENTITY",
- "PROCESSING_INSTRUCTION",
- "COMMENT", "DOCUMENT",
- "DOCUMENT_TYPE",
- "DOCUMENT_FRAGMENT",
- "NOTATION" };
-
- /**
- * Transforms <code>org.w3c.dom.Node.XXX_NODE</code> NodeType values into
- * Strings.
- *
- * @param nodeType as taken from the {@link org.w3c.dom.Node#getNodeType} function
- * @return the String value.
- * @see org.w3c.dom.Node#getNodeType
- */
- public static String getNodeTypeString(short nodeType) {
-
- if ((nodeType > 0) && (nodeType < 13)) {
- return nodeTypeString[nodeType];
- }
- return "";
- }
/**