javax.xml.xpath.XPathFactoryFinder类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中javax.xml.xpath.XPathFactoryFinder类的一些代码示例,展示了XPathFactoryFinder类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XPathFactoryFinder类的具体详情如下:
包路径:javax.xml.xpath.XPathFactoryFinder
类名称:XPathFactoryFinder

XPathFactoryFinder介绍

[英]Implementation of XPathFactory#newInstance(String).
[中]XPathFactory#newInstance(字符串)的实现。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * <p>Creates a new {@link XPathFactory} object for the specified
 * schema language.</p>
 *
 * @param uri
 *       Identifies the underlying object model.
 *
 * @return <code>null</code> if the callee fails to create one.
 *
 * @throws NullPointerException
 *      If the parameter is null.
 */
public XPathFactory newFactory(String uri) {
  if (uri == null) {
    throw new NullPointerException("uri == null");
  }
  XPathFactory f = _newFactory(uri);
  if (debug) {
    if (f != null) {
      debugPrintln("factory '" + f.getClass().getName() + "' was found for " + uri);
    } else {
      debugPrintln("unable to find a factory for " + uri);
    }
  }
  return f;
}

代码示例来源:origin: robovm/robovm

if (debug) debugPrintln("Looking up system property '"+propertyName+"'" );
  String r = System.getProperty(propertyName);
  if (r != null && r.length() > 0) {
    if (debug) debugPrintln("The value is '"+r+"'");
    xpf = createInstance(r);
    if(xpf!=null)    return xpf;
  } else if (debug) {
    debugPrintln("The property is undefined.");
        firstTime = false;
        if (f.exists()) {
          if (debug) debugPrintln("Read properties file " + f);
          cacheProps.load(new FileInputStream(f));
  if (debug) debugPrintln("found " + factoryClassName + " in $java.home/jaxp.properties");
    xpf = createInstance(factoryClassName);
    if(xpf != null){
      return xpf;
for (URL resource : createServiceFileIterator()) {
  if (debug) debugPrintln("looking into " + resource);
  try {
    xpf = loadFromServicesFile(uri, resource.toExternalForm(), resource.openStream());
    if(xpf!=null)    return xpf;
  } catch(IOException e) {
    if( debug ) {
      debugPrintln("failed to read "+resource);
      e.printStackTrace();

代码示例来源:origin: robovm/robovm

/**
 * <p>Constructor that specifies <code>ClassLoader</code> to use
 * to find <code>SchemaFactory</code>.</p>
 *
 * @param loader
 *      to be used to load resource, {@link SchemaFactory}, and
 *      {@code SchemaFactoryLoader} implementations during
 *      the resolution process.
 *      If this parameter is null, the default system class loader
 *      will be used.
 */
public XPathFactoryFinder(ClassLoader loader) {
  this.classLoader = loader;
  if (debug) {
    debugDisplayClassLoader();
  }
}

代码示例来源:origin: robovm/robovm

if (debug) debugPrintln("instantiating "+className);
Class clazz;
if( classLoader!=null )
else
  clazz = Class.forName(className);
if(debug)       debugPrintln("loaded it from "+which(clazz));
Object o = clazz.newInstance();
  return (XPathFactory)o;
if (debug) debugPrintln(className+" is not assignable to "+SERVICE_CLASS.getName());
  debugPrintln("failed to instantiate "+className);
  t.printStackTrace();

代码示例来源:origin: robovm/robovm

if (debug) debugPrintln("Reading " + resourceName );
      XPathFactory foundFactory = createInstance(factoryClassName);
      if (foundFactory.isObjectModelSupported(uri)) {
        resultFactory = foundFactory;

代码示例来源:origin: robovm/robovm

classLoader = Thread.currentThread().getContextClassLoader();
XPathFactory xpathFactory = new XPathFactoryFinder(classLoader).createInstance(factoryClassName);
if (xpathFactory == null || !xpathFactory.isObjectModelSupported(uri)) {
  throw new XPathFactoryConfigurationException(

代码示例来源:origin: robovm/robovm

XPathFactory xpathFactory = new XPathFactoryFinder(classLoader).newFactory(uri);
if (xpathFactory == null) {
  throw new XPathFactoryConfigurationException(

代码示例来源:origin: robovm/robovm

private void debugDisplayClassLoader() {
  if (classLoader == Thread.currentThread().getContextClassLoader()) {
    debugPrintln("using thread context class loader (" + classLoader + ") for search");
    return;
  }
  if (classLoader==ClassLoader.getSystemClassLoader()) {
    debugPrintln("using system class loader (" + classLoader + ") for search");
    return;
  }
  debugPrintln("using class loader (" + classLoader + ") for search");
}

代码示例来源:origin: javax.xml.parsers/jaxp-api

debugPrintln("Looking up system property '"+propertyName+"'" );
  String r = ss.getSystemProperty(propertyName);
  if(r!=null) {
    debugPrintln("The value is '"+r+"'");
    xpathFactory = createInstance(r);
    if(xpathFactory != null)    return xpathFactory;
  } else
    debugPrintln("The property is undefined.");
} catch( Throwable t ) {
  if( debug ) {
    debugPrintln("failed to look up system property '"+propertyName+"'" );
    t.printStackTrace();
        firstTime = false;
        if(ss.doesFileExist(f)){
          debugPrintln("Read properties file " + f);                                
          cacheProps.load(ss.getFileInputStream(f));
  debugPrintln("found " + factoryClassName + " in $java.home/jaxp.properties"); 
    xpathFactory = createInstance(factoryClassName);
    if(xpathFactory != null){
      return xpathFactory;
Iterator sitr = createServiceFileIterator();
while(sitr.hasNext()) {
  URL resource = (URL)sitr.next();
  debugPrintln("looking into " + resource);
  try {

代码示例来源:origin: robovm/robovm

private static String which( Class clazz ) {
  return which( clazz.getName(), clazz.getClassLoader() );
}

代码示例来源:origin: javax.xml.parsers/jaxp-api

XPathFactory xPathFactory = null;
debugPrintln("createInstance(" + className + ")");
Class clazz = createClass(className);
if (clazz == null) {
    debugPrintln("failed to getClass(" + className + ")");
    return null;	
debugPrintln("loaded " + className + " from " + which(clazz));
    xPathFactory = (XPathFactory) clazz.newInstance();
} catch (ClassCastException classCastException) {
    debugPrintln("could not instantiate " + clazz.getName());
    if (debug) {
        classCastException.printStackTrace();
    debugPrintln("could not instantiate " + clazz.getName());
    if (debug) {
        illegalAccessException.printStackTrace();
    debugPrintln("could not instantiate " + clazz.getName());
    if (debug) {
        instantiationException.printStackTrace();

代码示例来源:origin: javax.xml.parsers/jaxp-api

final String isObjectModelSupportedMethod = "isObjectModelSupported";
debugPrintln("Reading " + inputName);
    Class clazz = createClass(line);
    if (clazz == null) {
        continue;

代码示例来源:origin: javax.xml.parsers/jaxp-api

/**
 * Looks up a value in a property file
 * while producing all sorts of debug messages.
 * 
 * @return null
 *      if there was an error.
 */
private XPathFactory loadFromProperty( String keyName, String resourceName, InputStream in )
  throws IOException {
  debugPrintln("Reading "+resourceName );
  
  Properties props = new Properties();
  props.load(in);
  in.close();
  String factoryClassName = props.getProperty(keyName);
  if(factoryClassName != null){
    debugPrintln("found "+keyName+" = " + factoryClassName);
    return createInstance(factoryClassName);
  } else {
    debugPrintln(keyName+" is not in the property file");
    return null;
  }
}

代码示例来源:origin: org.apache.servicemix.specs/org.apache.servicemix.specs.jaxp-api-1.4

if (debug) debugPrintln("instanciating "+className);
  Class clazz;
  if( classLoader!=null )
  else
    clazz = Class.forName(className);
  if(debug)       debugPrintln("loaded it from "+which(clazz));
  Object o = clazz.newInstance();
    return (XPathFactory)o;
  if (debug) debugPrintln(className+" is not assignable to "+SERVICE_CLASS.getName());
} catch( Throwable t ) {
  if (debug) {
    debugPrintln("failed to instanciate "+className);
    t.printStackTrace();

代码示例来源:origin: MobiVM/robovm

classLoader = Thread.currentThread().getContextClassLoader();
XPathFactory xpathFactory = new XPathFactoryFinder(classLoader).createInstance(factoryClassName);
if (xpathFactory == null || !xpathFactory.isObjectModelSupported(uri)) {
  throw new XPathFactoryConfigurationException(

代码示例来源:origin: MobiVM/robovm

XPathFactory xpathFactory = new XPathFactoryFinder(classLoader).newFactory(uri);
if (xpathFactory == null) {
  throw new XPathFactoryConfigurationException(

代码示例来源:origin: robovm/robovm

/**
 * Returns an {@link Iterator} that enumerates all
 * the META-INF/services files that we care.
 */
private Iterable<URL> createServiceFileIterator() {
  if (classLoader == null) {
    URL resource = XPathFactoryFinder.class.getClassLoader().getResource(SERVICE_ID);
    return Collections.singleton(resource);
  } else {
    try {
      Enumeration<URL> e = classLoader.getResources(SERVICE_ID);
      if (debug && !e.hasMoreElements()) {
        debugPrintln("no "+SERVICE_ID+" file was found");
      }
      return Collections.list(e);
    } catch (IOException e) {
      if (debug) {
        debugPrintln("failed to enumerate resources "+SERVICE_ID);
        e.printStackTrace();
      }
      return Collections.emptySet();
    }
  }
}

代码示例来源:origin: MobiVM/robovm

private static String which( Class clazz ) {
  return which( clazz.getName(), clazz.getClassLoader() );
}

代码示例来源:origin: MobiVM/robovm

if (debug) debugPrintln("Looking up system property '"+propertyName+"'" );
  String r = System.getProperty(propertyName);
  if (r != null && r.length() > 0) {
    if (debug) debugPrintln("The value is '"+r+"'");
    xpf = createInstance(r);
    if(xpf!=null)    return xpf;
  } else if (debug) {
    debugPrintln("The property is undefined.");
        firstTime = false;
        if (f.exists()) {
          if (debug) debugPrintln("Read properties file " + f);
          cacheProps.load(new FileInputStream(f));
  if (debug) debugPrintln("found " + factoryClassName + " in $java.home/jaxp.properties");
    xpf = createInstance(factoryClassName);
    if(xpf != null){
      return xpf;
for (URL resource : createServiceFileIterator()) {
  if (debug) debugPrintln("looking into " + resource);
  try {
    xpf = loadFromServicesFile(uri, resource.toExternalForm(), resource.openStream());
    if(xpf!=null)    return xpf;
  } catch(IOException e) {
    if( debug ) {
      debugPrintln("failed to read "+resource);
      e.printStackTrace();

代码示例来源:origin: javax.xml.parsers/jaxp-api

/**
 * <p>Creates a new {@link XPathFactory} object for the specified
 * schema language.</p>
 * 
 * @param uri
 *       Identifies the underlying object model.
 * 
 * @return <code>null</code> if the callee fails to create one.
 * 
 * @throws NullPointerException
 *      If the parameter is null.
 */
public XPathFactory newFactory(String uri) {
  if(uri==null)        throw new NullPointerException();
  XPathFactory f = _newFactory(uri);
  if (f != null) {
    debugPrintln("factory '" + f.getClass().getName() + "' was found for " + uri);
  } else {
    debugPrintln("unable to find a factory for " + uri);
  }
  return f;
}

相关文章