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

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

本文整理了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

  1. /**
  2. * <p>Creates a new {@link XPathFactory} object for the specified
  3. * schema language.</p>
  4. *
  5. * @param uri
  6. * Identifies the underlying object model.
  7. *
  8. * @return <code>null</code> if the callee fails to create one.
  9. *
  10. * @throws NullPointerException
  11. * If the parameter is null.
  12. */
  13. public XPathFactory newFactory(String uri) {
  14. if (uri == null) {
  15. throw new NullPointerException("uri == null");
  16. }
  17. XPathFactory f = _newFactory(uri);
  18. if (debug) {
  19. if (f != null) {
  20. debugPrintln("factory '" + f.getClass().getName() + "' was found for " + uri);
  21. } else {
  22. debugPrintln("unable to find a factory for " + uri);
  23. }
  24. }
  25. return f;
  26. }

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

  1. if (debug) debugPrintln("Looking up system property '"+propertyName+"'" );
  2. String r = System.getProperty(propertyName);
  3. if (r != null && r.length() > 0) {
  4. if (debug) debugPrintln("The value is '"+r+"'");
  5. xpf = createInstance(r);
  6. if(xpf!=null) return xpf;
  7. } else if (debug) {
  8. debugPrintln("The property is undefined.");
  9. firstTime = false;
  10. if (f.exists()) {
  11. if (debug) debugPrintln("Read properties file " + f);
  12. cacheProps.load(new FileInputStream(f));
  13. if (debug) debugPrintln("found " + factoryClassName + " in $java.home/jaxp.properties");
  14. xpf = createInstance(factoryClassName);
  15. if(xpf != null){
  16. return xpf;
  17. for (URL resource : createServiceFileIterator()) {
  18. if (debug) debugPrintln("looking into " + resource);
  19. try {
  20. xpf = loadFromServicesFile(uri, resource.toExternalForm(), resource.openStream());
  21. if(xpf!=null) return xpf;
  22. } catch(IOException e) {
  23. if( debug ) {
  24. debugPrintln("failed to read "+resource);
  25. e.printStackTrace();

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

  1. /**
  2. * <p>Constructor that specifies <code>ClassLoader</code> to use
  3. * to find <code>SchemaFactory</code>.</p>
  4. *
  5. * @param loader
  6. * to be used to load resource, {@link SchemaFactory}, and
  7. * {@code SchemaFactoryLoader} implementations during
  8. * the resolution process.
  9. * If this parameter is null, the default system class loader
  10. * will be used.
  11. */
  12. public XPathFactoryFinder(ClassLoader loader) {
  13. this.classLoader = loader;
  14. if (debug) {
  15. debugDisplayClassLoader();
  16. }
  17. }

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

  1. if (debug) debugPrintln("instantiating "+className);
  2. Class clazz;
  3. if( classLoader!=null )
  4. else
  5. clazz = Class.forName(className);
  6. if(debug) debugPrintln("loaded it from "+which(clazz));
  7. Object o = clazz.newInstance();
  8. return (XPathFactory)o;
  9. if (debug) debugPrintln(className+" is not assignable to "+SERVICE_CLASS.getName());
  10. debugPrintln("failed to instantiate "+className);
  11. t.printStackTrace();

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

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

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

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

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

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

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

  1. private void debugDisplayClassLoader() {
  2. if (classLoader == Thread.currentThread().getContextClassLoader()) {
  3. debugPrintln("using thread context class loader (" + classLoader + ") for search");
  4. return;
  5. }
  6. if (classLoader==ClassLoader.getSystemClassLoader()) {
  7. debugPrintln("using system class loader (" + classLoader + ") for search");
  8. return;
  9. }
  10. debugPrintln("using class loader (" + classLoader + ") for search");
  11. }

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

  1. debugPrintln("Looking up system property '"+propertyName+"'" );
  2. String r = ss.getSystemProperty(propertyName);
  3. if(r!=null) {
  4. debugPrintln("The value is '"+r+"'");
  5. xpathFactory = createInstance(r);
  6. if(xpathFactory != null) return xpathFactory;
  7. } else
  8. debugPrintln("The property is undefined.");
  9. } catch( Throwable t ) {
  10. if( debug ) {
  11. debugPrintln("failed to look up system property '"+propertyName+"'" );
  12. t.printStackTrace();
  13. firstTime = false;
  14. if(ss.doesFileExist(f)){
  15. debugPrintln("Read properties file " + f);
  16. cacheProps.load(ss.getFileInputStream(f));
  17. debugPrintln("found " + factoryClassName + " in $java.home/jaxp.properties");
  18. xpathFactory = createInstance(factoryClassName);
  19. if(xpathFactory != null){
  20. return xpathFactory;
  21. Iterator sitr = createServiceFileIterator();
  22. while(sitr.hasNext()) {
  23. URL resource = (URL)sitr.next();
  24. debugPrintln("looking into " + resource);
  25. try {

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

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

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

  1. XPathFactory xPathFactory = null;
  2. debugPrintln("createInstance(" + className + ")");
  3. Class clazz = createClass(className);
  4. if (clazz == null) {
  5. debugPrintln("failed to getClass(" + className + ")");
  6. return null;
  7. debugPrintln("loaded " + className + " from " + which(clazz));
  8. xPathFactory = (XPathFactory) clazz.newInstance();
  9. } catch (ClassCastException classCastException) {
  10. debugPrintln("could not instantiate " + clazz.getName());
  11. if (debug) {
  12. classCastException.printStackTrace();
  13. debugPrintln("could not instantiate " + clazz.getName());
  14. if (debug) {
  15. illegalAccessException.printStackTrace();
  16. debugPrintln("could not instantiate " + clazz.getName());
  17. if (debug) {
  18. instantiationException.printStackTrace();

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

  1. final String isObjectModelSupportedMethod = "isObjectModelSupported";
  2. debugPrintln("Reading " + inputName);
  3. Class clazz = createClass(line);
  4. if (clazz == null) {
  5. continue;

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

  1. /**
  2. * Looks up a value in a property file
  3. * while producing all sorts of debug messages.
  4. *
  5. * @return null
  6. * if there was an error.
  7. */
  8. private XPathFactory loadFromProperty( String keyName, String resourceName, InputStream in )
  9. throws IOException {
  10. debugPrintln("Reading "+resourceName );
  11. Properties props = new Properties();
  12. props.load(in);
  13. in.close();
  14. String factoryClassName = props.getProperty(keyName);
  15. if(factoryClassName != null){
  16. debugPrintln("found "+keyName+" = " + factoryClassName);
  17. return createInstance(factoryClassName);
  18. } else {
  19. debugPrintln(keyName+" is not in the property file");
  20. return null;
  21. }
  22. }

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

  1. if (debug) debugPrintln("instanciating "+className);
  2. Class clazz;
  3. if( classLoader!=null )
  4. else
  5. clazz = Class.forName(className);
  6. if(debug) debugPrintln("loaded it from "+which(clazz));
  7. Object o = clazz.newInstance();
  8. return (XPathFactory)o;
  9. if (debug) debugPrintln(className+" is not assignable to "+SERVICE_CLASS.getName());
  10. } catch( Throwable t ) {
  11. if (debug) {
  12. debugPrintln("failed to instanciate "+className);
  13. t.printStackTrace();

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

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

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

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

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

  1. /**
  2. * Returns an {@link Iterator} that enumerates all
  3. * the META-INF/services files that we care.
  4. */
  5. private Iterable<URL> createServiceFileIterator() {
  6. if (classLoader == null) {
  7. URL resource = XPathFactoryFinder.class.getClassLoader().getResource(SERVICE_ID);
  8. return Collections.singleton(resource);
  9. } else {
  10. try {
  11. Enumeration<URL> e = classLoader.getResources(SERVICE_ID);
  12. if (debug && !e.hasMoreElements()) {
  13. debugPrintln("no "+SERVICE_ID+" file was found");
  14. }
  15. return Collections.list(e);
  16. } catch (IOException e) {
  17. if (debug) {
  18. debugPrintln("failed to enumerate resources "+SERVICE_ID);
  19. e.printStackTrace();
  20. }
  21. return Collections.emptySet();
  22. }
  23. }
  24. }

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

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

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

  1. if (debug) debugPrintln("Looking up system property '"+propertyName+"'" );
  2. String r = System.getProperty(propertyName);
  3. if (r != null && r.length() > 0) {
  4. if (debug) debugPrintln("The value is '"+r+"'");
  5. xpf = createInstance(r);
  6. if(xpf!=null) return xpf;
  7. } else if (debug) {
  8. debugPrintln("The property is undefined.");
  9. firstTime = false;
  10. if (f.exists()) {
  11. if (debug) debugPrintln("Read properties file " + f);
  12. cacheProps.load(new FileInputStream(f));
  13. if (debug) debugPrintln("found " + factoryClassName + " in $java.home/jaxp.properties");
  14. xpf = createInstance(factoryClassName);
  15. if(xpf != null){
  16. return xpf;
  17. for (URL resource : createServiceFileIterator()) {
  18. if (debug) debugPrintln("looking into " + resource);
  19. try {
  20. xpf = loadFromServicesFile(uri, resource.toExternalForm(), resource.openStream());
  21. if(xpf!=null) return xpf;
  22. } catch(IOException e) {
  23. if( debug ) {
  24. debugPrintln("failed to read "+resource);
  25. e.printStackTrace();

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

  1. /**
  2. * <p>Creates a new {@link XPathFactory} object for the specified
  3. * schema language.</p>
  4. *
  5. * @param uri
  6. * Identifies the underlying object model.
  7. *
  8. * @return <code>null</code> if the callee fails to create one.
  9. *
  10. * @throws NullPointerException
  11. * If the parameter is null.
  12. */
  13. public XPathFactory newFactory(String uri) {
  14. if(uri==null) throw new NullPointerException();
  15. XPathFactory f = _newFactory(uri);
  16. if (f != null) {
  17. debugPrintln("factory '" + f.getClass().getName() + "' was found for " + uri);
  18. } else {
  19. debugPrintln("unable to find a factory for " + uri);
  20. }
  21. return f;
  22. }

相关文章