use of java.util.Hashtable in project robovm by robovm.
the class EnvironmentCheck method checkJAXPVersion.
/**
* Report version information about JAXP interfaces.
*
* Currently distinguishes between JAXP 1.0.1 and JAXP 1.1,
* and not found; only tests the interfaces, and does not
* check for reference implementation versions.
*
* @param h Hashtable to put information in
*/
protected void checkJAXPVersion(Hashtable h) {
if (null == h)
h = new Hashtable();
final Class[] noArgs = new Class[0];
Class clazz = null;
try {
final String JAXP1_CLASS = "javax.xml.parsers.DocumentBuilder";
final String JAXP11_METHOD = "getDOMImplementation";
clazz = ObjectFactory.findProviderClass(JAXP1_CLASS, ObjectFactory.findClassLoader(), true);
Method method = clazz.getMethod(JAXP11_METHOD, noArgs);
// If we succeeded, we at least have JAXP 1.1 available
h.put(VERSION + "JAXP", "1.1 or higher");
} catch (Exception e) {
if (null != clazz) {
// We must have found the class itself, just not the
// method, so we (probably) have JAXP 1.0.1
h.put(ERROR + VERSION + "JAXP", "1.0.1");
h.put(ERROR, ERROR_FOUND);
} else {
// We couldn't even find the class, and don't have
// any JAXP support at all, or only have the
// transform half of it
h.put(ERROR + VERSION + "JAXP", CLASS_NOTPRESENT);
h.put(ERROR, ERROR_FOUND);
}
}
}
use of java.util.Hashtable in project robovm by robovm.
the class EnvironmentCheck method checkDOMVersion.
/**
* 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";
// String, String
final String DOM_LEVEL2_METHOD = "createElementNS";
final String DOM_LEVEL2WD_CLASS = "org.w3c.dom.Node";
// String, String
final String DOM_LEVEL2WD_METHOD = "supported";
final String DOM_LEVEL2FD_CLASS = "org.w3c.dom.Node";
// String, String
final String DOM_LEVEL2FD_METHOD = "isSupported";
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
}
use of java.util.Hashtable in project robovm by robovm.
the class EnvironmentCheck method checkPathForJars.
/**
* Cheap-o listing of specified .jars found in the classpath.
*
* cp should be separated by the usual File.pathSeparator. We
* then do a simplistic search of the path for any requested
* .jar filenames, and return a listing of their names and
* where (apparently) they came from.
*
* @param cp classpath to search
* @param jars array of .jar base filenames to look for
*
* @return Vector of Hashtables filled with info about found .jars
* @see #jarNames
* @see #logFoundJars(Vector, String)
* @see #appendFoundJars(Node, Document, Vector, String )
* @see #getApparentVersion(String, long)
*/
protected Vector checkPathForJars(String cp, String[] jars) {
if ((null == cp) || (null == jars) || (0 == cp.length()) || (0 == jars.length))
return null;
Vector v = new Vector();
StringTokenizer st = new StringTokenizer(cp, File.pathSeparator);
while (st.hasMoreTokens()) {
// Look at each classpath entry for each of our requested jarNames
String filename = st.nextToken();
for (int i = 0; i < jars.length; i++) {
if (filename.indexOf(jars[i]) > -1) {
File f = new File(filename);
if (f.exists()) {
// the details of that .jar file
try {
Hashtable h = new Hashtable(2);
// Note "-" char is looked for in appendFoundJars
h.put(jars[i] + "-path", f.getAbsolutePath());
// report the apparent version of the file we've found
if (!("xalan.jar".equalsIgnoreCase(jars[i]))) {
h.put(jars[i] + "-apparent.version", getApparentVersion(jars[i], f.length()));
}
v.addElement(h);
} catch (Exception e) {
/* no-op, don't add it */
}
} else {
Hashtable h = new Hashtable(2);
// Note "-" char is looked for in appendFoundJars
h.put(jars[i] + "-path", WARNING + " Classpath entry: " + filename + " does not exist");
h.put(jars[i] + "-apparent.version", CLASS_NOTPRESENT);
v.addElement(h);
}
}
}
}
return v;
}
use of java.util.Hashtable in project robovm by robovm.
the class EnvironmentCheck method logFoundJars.
/**
* Print out report of .jars found in a classpath.
*
* Takes the information encoded from a checkPathForJars()
* call and dumps it out to our PrintWriter.
*
* @param v Vector of Hashtables of .jar file info
* @param desc description to print out in header
*
* @return false if OK, true if any .jars were reported
* as having errors
* @see #checkPathForJars(String, String[])
*/
protected boolean logFoundJars(Vector v, String desc) {
if ((null == v) || (v.size() < 1))
return false;
boolean errors = false;
logMsg("#---- BEGIN Listing XML-related jars in: " + desc + " ----");
for (int i = 0; i < v.size(); i++) {
Hashtable subhash = (Hashtable) v.elementAt(i);
for (Enumeration keys = subhash.keys(); keys.hasMoreElements(); ) /* no increment portion */
{
Object key = keys.nextElement();
String keyStr = (String) key;
try {
if (keyStr.startsWith(ERROR)) {
errors = true;
}
logMsg(keyStr + "=" + subhash.get(keyStr));
} catch (Exception e) {
errors = true;
logMsg("Reading-" + key + "= threw: " + e.toString());
}
}
}
logMsg("#----- END Listing XML-related jars in: " + desc + " -----");
return errors;
}
use of java.util.Hashtable in project robovm by robovm.
the class EnvironmentCheck method checkEnvironment.
/**
* Programmatic entrypoint: Report on basic Java environment
* and CLASSPATH settings that affect Xalan.
*
* <p>Note that this class is not advanced enough to tell you
* everything about the environment that affects Xalan, and
* sometimes reports errors that will not actually affect
* Xalan's behavior. Currently, it very simplistically
* checks the JVM's environment for some basic properties and
* logs them out; it will report a problem if it finds a setting
* or .jar file that is <i>likely</i> to cause problems.</p>
*
* <p>Advanced users can peruse the code herein to help them
* investigate potential environment problems found; other users
* may simply send the output from this tool along with any bugs
* they submit to help us in the debugging process.</p>
*
* @param pw PrintWriter to send output to; can be sent to a
* file that will look similar to a Properties file; defaults
* to System.out if null
* @return true if your environment appears to have no major
* problems; false if potential environment problems found
* @see #getEnvironmentHash()
*/
public boolean checkEnvironment(PrintWriter pw) {
// Use user-specified output writer if non-null
if (null != pw)
outWriter = pw;
// Setup a hash to store various environment information in
Hashtable hash = getEnvironmentHash();
// Check for ERROR keys in the hashtable, and print report
boolean environmentHasErrors = writeEnvironmentReport(hash);
if (environmentHasErrors) {
// Note: many logMsg calls have # at the start to
// fake a property-file like output
logMsg("# WARNING: Potential problems found in your environment!");
logMsg("# Check any 'ERROR' items above against the Xalan FAQs");
logMsg("# to correct potential problems with your classes/jars");
logMsg("# http://xml.apache.org/xalan-j/faq.html");
if (null != outWriter)
outWriter.flush();
return false;
} else {
logMsg("# YAHOO! Your environment seems to be OK.");
if (null != outWriter)
outWriter.flush();
return true;
}
}
Aggregations