in jaxp-api-1.4/src/main/java/javax/xml/xpath/XPathFactoryFinder.java [305:364]
private XPathFactory loadFromServicesFile(String uri, String resourceName, InputStream in) {
if (debug) debugPrintln("Reading " + resourceName );
BufferedReader rd;
try {
rd = new BufferedReader(new InputStreamReader(in, "UTF-8"), DEFAULT_LINE_LENGTH);
} catch (java.io.UnsupportedEncodingException e) {
rd = new BufferedReader(new InputStreamReader(in), DEFAULT_LINE_LENGTH);
}
String factoryClassName = null;
XPathFactory resultFactory = null;
// See spec for provider-configuration files: http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Provider%20Configuration%20File
while (true) {
try {
factoryClassName = rd.readLine();
} catch (IOException x) {
// No provider found
break;
}
if (factoryClassName != null) {
// Ignore comments in the provider-configuration file
int hashIndex = factoryClassName.indexOf('#');
if (hashIndex != -1) {
factoryClassName = factoryClassName.substring(0, hashIndex);
}
// Ignore leading and trailing whitespace
factoryClassName = factoryClassName.trim();
// If there's no text left or if this was a blank line, go to the next one.
if (factoryClassName.length() == 0) {
continue;
}
try {
// Found the right XPathFactory if its isObjectModelSupported(String uri) method returns true.
XPathFactory foundFactory = (XPathFactory) createInstance(factoryClassName);
if (foundFactory.isObjectModelSupported(uri)) {
resultFactory = foundFactory;
break;
}
}
catch (Exception e) {}
}
else {
break;
}
}
try {
// try to close the reader.
rd.close();
}
// Ignore the exception.
catch (IOException exc) {}
return resultFactory;
}