⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 environmentcheck.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    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 =        "com.sun.org.apache.xalan.internal.processor.XSLProcessorVersion";      Class clazz = ObjectFactory.findProviderClass(        XALAN2_VERSION_CLASS, ObjectFactory.findClassLoader(), true);      // 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));      h.put(VERSION + "xalan2x", buf.toString());    }    catch (Exception e2)    {      h.put(VERSION + "xalan2x", CLASS_NOTPRESENT);    }    try    {      // NOTE: This is the new Xalan 2.2+ version class      final String XALAN2_2_VERSION_CLASS =        "com.sun.org.apache.xalan.internal.Version";      final String XALAN2_2_VERSION_METHOD = "getVersion";      final Class noArgs[] = new Class[0];      Class clazz = ObjectFactory.findProviderClass(        XALAN2_2_VERSION_CLASS, ObjectFactory.findClassLoader(), true);      Method method = clazz.getMethod(XALAN2_2_VERSION_METHOD, noArgs);      Object returnValue = method.invoke(null, new Object[0]);      h.put(VERSION + "xalan2_2", (String)returnValue);    }    catch (Exception e2)    {      h.put(VERSION + "xalan2_2", CLASS_NOTPRESENT);    }  }  /**   * Report product version information from common parsers.   *   * Looks for version info in xerces.jar/xercesImpl.jar/crimson.jar.   *   * //@todo actually look up version info in crimson manifest   *   * @param h Hashtable to put information in   */  protected void checkParserVersion(Hashtable h)  {    if (null == h)      h = new Hashtable();    try    {      final String XERCES1_VERSION_CLASS = "com.sun.org.apache.xerces.internal.framework.Version";      Class clazz = ObjectFactory.findProviderClass(        XERCES1_VERSION_CLASS, ObjectFactory.findClassLoader(), true);      // Found Xerces-J 1.x, grab it's version fields      Field f = clazz.getField("fVersion");      String parserVersion = (String) f.get(null);      h.put(VERSION + "xerces1", parserVersion);    }    catch (Exception e)    {      h.put(VERSION + "xerces1", CLASS_NOTPRESENT);    }    // Look for xerces1 and xerces2 parsers separately    try    {      final String XERCES2_VERSION_CLASS = "com.sun.org.apache.xerces.internal.impl.Version";      Class clazz = ObjectFactory.findProviderClass(        XERCES2_VERSION_CLASS, ObjectFactory.findClassLoader(), true);      // Found Xerces-J 2.x, grab it's version fields      Field f = clazz.getField("fVersion");      String parserVersion = (String) f.get(null);      h.put(VERSION + "xerces2", parserVersion);    }    catch (Exception e)    {      h.put(VERSION + "xerces2", CLASS_NOTPRESENT);    }    try    {      final String CRIMSON_CLASS = "org.apache.crimson.parser.Parser2";      Class clazz = ObjectFactory.findProviderClass(        CRIMSON_CLASS, ObjectFactory.findClassLoader(), true);      //@todo determine specific crimson version      h.put(VERSION + "crimson", CLASS_PRESENT);    }    catch (Exception e)    {      h.put(VERSION + "crimson", CLASS_NOTPRESENT);    }  }  /**   * Report product version information from Ant.   *   * @param h Hashtable to put information in   */  protected void checkAntVersion(Hashtable h)  {    if (null == h)      h = new Hashtable();    try    {      final String ANT_VERSION_CLASS = "org.apache.tools.ant.Main";      final String ANT_VERSION_METHOD = "getAntVersion"; // noArgs      final Class noArgs[] = new Class[0];      Class clazz = ObjectFactory.findProviderClass(        ANT_VERSION_CLASS, ObjectFactory.findClassLoader(), true);      Method method = clazz.getMethod(ANT_VERSION_METHOD, noArgs);      Object returnValue = method.invoke(null, new Object[0]);      h.put(VERSION + "ant", (String)returnValue);    }    catch (Exception e)    {      h.put(VERSION + "ant", CLASS_NOTPRESENT);    }  }  /**   * Report version info from DOM interfaces.    *   * Currently distinguishes between pre-DOM level 2, the DOM    * level 2 working draft, the DOM level 2 final draft,    * and not found.   *   * @param h Hashtable to put information in   */  protected void checkDOMVersion(Hashtable h)  {    if (null == h)      h = new Hashtable();    final String DOM_LEVEL2_CLASS = "org.w3c.dom.Document";    final String DOM_LEVEL2_METHOD = "createElementNS";  // String, String    final String DOM_LEVEL2WD_CLASS = "org.w3c.dom.Node";    final String DOM_LEVEL2WD_METHOD = "supported";  // String, String    final String DOM_LEVEL2FD_CLASS = "org.w3c.dom.Node";    final String DOM_LEVEL2FD_METHOD = "isSupported";  // String, String    final Class twoStringArgs[] = { java.lang.String.class,                                    java.lang.String.class };    try    {      Class clazz = ObjectFactory.findProviderClass(        DOM_LEVEL2_CLASS, ObjectFactory.findClassLoader(), true);      Method method = clazz.getMethod(DOM_LEVEL2_METHOD, twoStringArgs);      // If we succeeded, we have loaded interfaces from a       //  level 2 DOM somewhere      h.put(VERSION + "DOM", "2.0");      try      {        // Check for the working draft version, which is         //  commonly found, but won't work anymore        clazz = ObjectFactory.findProviderClass(          DOM_LEVEL2WD_CLASS, ObjectFactory.findClassLoader(), true);        method = clazz.getMethod(DOM_LEVEL2WD_METHOD, twoStringArgs);        h.put(ERROR + VERSION + "DOM.draftlevel", "2.0wd");        h.put(ERROR, ERROR_FOUND);      }      catch (Exception e2)      {        try        {          // Check for the final draft version as well          clazz = ObjectFactory.findProviderClass(            DOM_LEVEL2FD_CLASS, ObjectFactory.findClassLoader(), true);          method = clazz.getMethod(DOM_LEVEL2FD_METHOD, twoStringArgs);          h.put(VERSION + "DOM.draftlevel", "2.0fd");        }        catch (Exception e3)        {          h.put(ERROR + VERSION + "DOM.draftlevel", "2.0unknown");          h.put(ERROR, ERROR_FOUND);        }      }    }    catch (Exception e)    {      h.put(ERROR + VERSION + "DOM",            "ERROR attempting to load DOM level 2 class: " + e.toString());      h.put(ERROR, ERROR_FOUND);    }    //@todo load an actual DOM implmementation and query it as well    //@todo load an actual DOM implmementation and check if     //  isNamespaceAware() == true, which is needed to parse     //  xsl stylesheet files into a DOM  }  /**   * Report version info from SAX interfaces.    *   * Currently distinguishes between SAX 2, SAX 2.0beta2,    * SAX1, and not found.   *   * @param h Hashtable to put information in   */  protected void checkSAXVersion(Hashtable h)  {    if (null == h)      h = new Hashtable();    final String SAX_VERSION1_CLASS = "org.xml.sax.Parser";    final String SAX_VERSION1_METHOD = "parse";  // String    final String SAX_VERSION2_CLASS = "org.xml.sax.XMLReader";    final String SAX_VERSION2_METHOD = "parse";  // String    final String SAX_VERSION2BETA_CLASSNF = "org.xml.sax.helpers.AttributesImpl";    final String SAX_VERSION2BETA_METHODNF = "setAttributes";  // Attributes    final Class oneStringArg[] = { java.lang.String.class };    // Note this introduces a minor compile dependency on SAX...    final Class attributesArg[] = { org.xml.sax.Attributes.class };    try    {      // This method was only added in the final SAX 2.0 release;       //  see changes.html "Changes from SAX 2.0beta2 to SAX 2.0prerelease"      Class clazz = ObjectFactory.findProviderClass(        SAX_VERSION2BETA_CLASSNF, ObjectFactory.findClassLoader(), true);      Method method = clazz.getMethod(SAX_VERSION2BETA_METHODNF, attributesArg);      // If we succeeded, we have loaded interfaces from a       //  real, final SAX version 2.0 somewhere      h.put(VERSION + "SAX", "2.0");    }    catch (Exception e)    {      // If we didn't find the SAX 2.0 class, look for a 2.0beta2      h.put(ERROR + VERSION + "SAX",            "ERROR attempting to load SAX version 2 class: " + e.toString());      h.put(ERROR, ERROR_FOUND);                  try      {        Class clazz = ObjectFactory.findProviderClass(          SAX_VERSION2_CLASS, ObjectFactory.findClassLoader(), true);        Method method = clazz.getMethod(SAX_VERSION2_METHOD, oneStringArg);        // If we succeeded, we have loaded interfaces from a         //  SAX version 2.0beta2 or earlier; these might work but         //  you should really have the final SAX 2.0         h.put(VERSION + "SAX-backlevel", "2.0beta2-or-earlier");      }      catch (Exception e2)      {        // If we didn't find the SAX 2.0beta2 class, look for a 1.0 one        h.put(ERROR + VERSION + "SAX",              "ERROR attempting to load SAX version 2 class: " + e.toString());        h.put(ERROR, ERROR_FOUND);                  try        {          Class clazz = ObjectFactory.findProviderClass(            SAX_VERSION1_CLASS, ObjectFactory.findClassLoader(), true);          Method method = clazz.getMethod(SAX_VERSION1_METHOD, oneStringArg);          // If we succeeded, we have loaded interfaces from a           //  SAX version 1.0 somewhere; which won't work very           //  well for JAXP 1.1 or beyond!          h.put(VERSION + "SAX-backlevel", "1.0");        }        catch (Exception e3)        {          // If we didn't find the SAX 2.0 class, look for a 1.0 one          // Note that either 1.0 or no SAX are both errors          h.put(ERROR + VERSION + "SAX-backlevel",                "ERROR attempting to load SAX version 1 class: " + e3.toString());                    }      }    }  }  /**    * Manual table of known .jar sizes.     * Only includes shipped versions of certain projects.   * key=jarsize, value=jarname ' from ' distro name   * Note assumption: two jars cannot have the same size!   *   * @see #getApparentVersion(String, long)   */  private static Hashtable jarVersions = new Hashtable();  /**    * Static initializer for jarVersions table.     * Doing this just once saves time and space.   *   * @see #getApparentVersion(String, long)   */  static   {    // Note: hackish Hashtable, this could use improvement    jarVersions.put(new Long(857192), "xalan.jar from xalan-j_1_1");    jarVersions.put(new Long(440237), "xalan.jar from xalan-j_1_2");    jarVersions.put(new Long(436094), "xalan.jar from xalan-j_1_2_1");    jarVersions.put(new Long(426249), "xalan.jar from xalan-j_1_2_2");    jarVersions.put(new Long(702536), "xalan.jar from xalan-j_2_0_0");    jarVersions.put(new Long(720930), "xalan.jar from xalan-j_2_0_1");    jarVersions.put(new Long(732330), "xalan.jar from xalan-j_2_1_0");    jarVersions.put(new Long(872241), "xalan.jar from xalan-j_2_2_D10");    jarVersions.put(new Long(882739), "xalan.jar from xalan-j_2_2_D11");    jarVersions.put(new Long(923866), "xalan.jar from xalan-j_2_2_0");    jarVersions.put(new Long(905872), "xalan.jar from xalan-j_2_3_D1");    jarVersions.put(new Long(906122), "xalan.jar from xalan-j_2_3_0");    jarVersions.put(new Long(906248), "xalan.jar from xalan-j_2_3_1");    jarVersions.put(new Long(983377), "xalan.jar from xalan-j_2_4_D1");        jarVersions.put(new Long(997276), "xalan.jar from xalan-j_2_4_0");    jarVersions.put(new Long(1031036), "xalan.jar from xalan-j_2_4_1");        // Stop recording xalan.jar sizes as of Xalan Java 2.5.0        jarVersions.put(new Long(596540), "xsltc.jar from xalan-j_2_2_0");    jarVersions.put(new Long(590247), "xsltc.jar from xalan-j_2_3_D1");    jarVersions.put(new Long(589914), "xsltc.jar from xalan-j_2_3_0");    jarVersions.put(new Long(589915), "xsltc.jar from xalan-j_2_3_1");    jarVersions.put(new Long(1306667), "xsltc.jar from xalan-j_2_4_D1");         jarVersions.put(new Long(1328227), "xsltc.jar from xalan-j_2_4_0");    jarVersions.put(new Long(1344009), "xsltc.jar from xalan-j_2_4_1");    jarVersions.put(new Long(1348361), "xsltc.jar from xalan-j_2_5_D1");        // Stop recording xsltc.jar sizes as of Xalan Java 2.5.0    jarVersions.put(new Long(1268634), "xsltc.jar-bundled from xalan-j_2_3_0");    jarVersions.put(new Long(100196), "xml-apis.jar from xalan-j_2_2_0 or xalan-j_2_3_D1");    jarVersions.put(new Long(108484), "xml-apis.jar from xalan-j_2_3_0, or xalan-j_2_3_1 from xml-commons-1.0.b2");    jarVersions.put(new Long(109049), "xml-apis.jar from xalan-j_2_4_0 from xml-commons RIVERCOURT1 branch");    jarVersions.put(new Long(113749), "xml-apis.jar from xalan-j_2_4_1 from factoryfinder-build of xml-commons RIVERCOURT1");    jarVersions.put(new Long(124704), "xml-apis.jar from tck-jaxp-1_2_0 branch of xml-commons");    jarVersions.put(new Long(124724), "xml-apis.jar from tck-jaxp-1_2_0 branch of xml-commons, tag: xml-commons-external_1_2_01");    jarVersions.put(new Long(194205), "xml-apis.jar from head branch of xml-commons, tag: xml-commons-external_1_3_02");    // If the below were more common I would update it to report     //  errors better; but this is so old hardly anyone has it    jarVersions.put(new Long(424490), "xalan.jar from Xerces Tools releases - ERROR:DO NOT USE!");    jarVersions.put(new Long(1591855), "xerces.jar from xalan-j_1_1 from xerces-1...");    jarVersions.put(new Long(1498679), "xerces.jar from xalan-j_1_2 from xerces-1_2_0.bin");    jarVersions.put(new Long(1484896), "xerces.jar from xalan-j_1_2_1 from xerces-1_2_1.bin");    jarVersions.put(new Long(804460),  "xerces.jar from xalan-j_1_2_2 from xerces-1_2_2.bin");    jarVersions.put(new Long(1499244), "xerces.jar from xalan-j_2_0_0 from xerces-1_2_3.bin");    jarVersions.put(new Long(1605266), "xerces.jar from xalan-j_2_0_1 from xerces-1_3_0.bin");    jarVersions.put(new Long(904030), "xerces.jar from xalan-j_2_1_0 from xerces-1_4.bin");    jarVersions.put(new Long(904030), "xerces.jar from xerces-1_4_0.bin");    jarVersions.put(new Long(1802885), "xerces.jar from xerces-1_4_2.bin");    jarVersions.put(new Long(1734594), "xerces.jar from Xerces-J-bin.2.0.0.beta3");    jarVersions.put(new Long(1808883), "xerces.jar from xalan-j_2_2_D10,D11,D12 or xerces-1_4_3.bin");    jarVersions.put(new Long(1812019), "xerces.jar from xalan-j_2_2_0");    jarVersions.put(new Long(1720292), "xercesImpl.jar from xalan-j_2_3_D1");    jarVersions.put(new Long(1730053), "xercesImpl.jar from xalan-j_2_3_0 or xalan-j_2_3_1 from xerces-2_0_0");    jarVersions.put(new Long(1728861), "xercesImpl.jar from xalan-j_2_4_D1 from xerces-2_0_1");        jarVersions.put(new Long(972027), "xercesImpl.jar from xalan-j_2_4_0 from xerces-2_1");    jarVersions.put(new Long(831587), "xercesImpl.jar from xalan-j_2_4_1 from xerces-2_2");     jarVersions.put(new Long(891817), "xercesImpl.jar from xalan-j_2_5_D1 from xerces-2_3");      jarVersions.put(new Long(895924), "xercesImpl.jar from xerces-2_4");    jarVersions.put(new Long(1010806), "xercesImpl.jar from Xerces-J-bin.2.6.2");     jarVersions.put(new Long(1203860), "xercesImpl.jar from Xerces-J-bin.2.7.1");                               jarVersions.put(new Long(37485), "xalanj1compat.jar from xalan-j_2_0_0");    jarVersions.put(new Long(38100), "xalanj1compat.jar from xalan-j_2_0_1");    jarVersions.put(new Long(18779), "xalanservlet.jar from xalan-j_2_0_0");    jarVersions.put(new Long(21453), "xalanservlet.jar from xalan-j_2_0_1");    jarVersions.put(new Long(24826), "xalanservlet.jar from xalan-j_2_3_1 or xalan-j_2_4_1");        jarVersions.put(new Long(24831), "xalanservlet.jar from xalan-j_2_4_1");    // Stop recording xalanservlet.jar sizes as of Xalan Java 2.5.0; now a .war file        // For those who've downloaded JAXP from sun    jarVersions.put(new Long(5618), "jaxp.jar from jaxp1.0.1");    jarVersions.put(new Long(136133), "parser.jar from jaxp1.0.1");    jarVersions.put(new Long(28404), "jaxp.jar from jaxp-1.1");    jarVersions.put(new Long(187162), "crimson.jar from jaxp-1.1");    jarVersions.put(new Long(801714), "xalan.jar from jaxp-1.1");    jarVersions.put(new Long(196399), "crimson.jar from crimson-1.1.1");    jarVersions.put(new Long(33323), "jaxp.jar from crimson-1.1.1 or jakarta-ant-1.4.1b1");    jarVersions.put(new Long(152717), "crimson.jar from crimson-1.1.2beta2");    jarVersions.put(new Long(88143), "xml-apis.jar from crimson-1.1.2beta2");    jarVersions.put(new Long(206384), "crimson.jar from crimson-1.1.3 or jakarta-ant-1.4.1b1");    // jakarta-ant: since many people use ant these days    jarVersions.put(new Long(136198), "parser.jar from jakarta-ant-1.3 or 1.2");    jarVersions.put(new Long(5537), "jaxp.jar from jakarta-ant-1.3 or 1.2");  }  /** Simple PrintWriter we send output to; defaults to System.out.  */  protected PrintWriter outWriter = new PrintWriter(System.out, true);  /**   * Bottleneck output: calls outWriter.println(s).     * @param s String to print   */  protected void logMsg(String s)  {    outWriter.println(s);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -