com.google.common.reflect.ClassPath.toFile()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(164)

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

ClassPath.toFile介绍

暂无

代码示例

代码示例来源:origin: google/guava

@VisibleForTesting
static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
 LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 for (URL url : getClassLoaderUrls(classloader)) {
  if (url.getProtocol().equals("file")) {
   File file = toFile(url);
   if (!entries.containsKey(file)) {
    entries.put(file, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: google/guava

builder.add(toFile(url));

代码示例来源:origin: google/j2objc

@VisibleForTesting
static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
 LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 for (URL url : getClassLoaderUrls(classloader)) {
  if (url.getProtocol().equals("file")) {
   File file = toFile(url);
   if (!entries.containsKey(file)) {
    entries.put(file, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: google/guava

public void testToFile() throws Exception {
 assertThat(ClassPath.toFile(new URL("file:///c:/Documents%20and%20Settings/")))
   .isEqualTo(new File("/c:/Documents and Settings/"));
 assertThat(ClassPath.toFile(new URL("file:///c:/Documents ~ Settings, or not/11-12 12:05")))
   .isEqualTo(new File("/c:/Documents ~ Settings, or not/11-12 12:05"));
}

代码示例来源:origin: google/guava

@AndroidIncompatible // works in newer Android versions but fails at the version we test with
public void testToFile_AndroidIncompatible() throws Exception {
 assertThat(ClassPath.toFile(new URL("file:///c:\\Documents ~ Settings, or not\\11-12 12:05")))
   .isEqualTo(new File("/c:\\Documents ~ Settings, or not\\11-12 12:05"));
 assertThat(ClassPath.toFile(new URL("file:///C:\\Program Files\\Apache Software Foundation")))
   .isEqualTo(new File("/C:\\Program Files\\Apache Software Foundation/"));
 assertThat(ClassPath.toFile(new URL("file:///C:\\\u20320 \u22909"))) // Chinese Ni Hao
   .isEqualTo(new File("/C:\\\u20320 \u22909"));
}

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

@VisibleForTesting
static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
 LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 for (URL url : getClassLoaderUrls(classloader)) {
  if (url.getProtocol().equals("file")) {
   File file = toFile(url);
   if (!entries.containsKey(file)) {
    entries.put(file, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: google/j2objc

builder.add(toFile(url));

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

builder.add(toFile(url));

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

@VisibleForTesting
static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
 LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 for (URL url : getClassLoaderUrls(classloader)) {
  if (url.getProtocol().equals("file")) {
   File file = toFile(url);
   if (!entries.containsKey(file)) {
    entries.put(file, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

@VisibleForTesting
static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) {
 LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap();
 // Search parent first, since it's the order ClassLoader#loadClass() uses.
 ClassLoader parent = classloader.getParent();
 if (parent != null) {
  entries.putAll(getClassPathEntries(parent));
 }
 for (URL url : getClassLoaderUrls(classloader)) {
  if (url.getProtocol().equals("file")) {
   File file = toFile(url);
   if (!entries.containsKey(file)) {
    entries.put(file, classloader);
   }
  }
 }
 return ImmutableMap.copyOf(entries);
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

builder.add(toFile(url));

代码示例来源:origin: org.jboss.eap/wildfly-client-all

builder.add(toFile(url));

代码示例来源:origin: com.google.guava/guava-tests

public void testToFile() throws Exception {
 assertThat(ClassPath.toFile(new URL("file:///c:/Documents%20and%20Settings/")))
   .isEqualTo(new File("/c:/Documents and Settings/"));
 assertThat(ClassPath.toFile(new URL("file:///c:/Documents ~ Settings, or not/11-12 12:05")))
   .isEqualTo(new File("/c:/Documents ~ Settings, or not/11-12 12:05"));
}

代码示例来源:origin: com.google.guava/guava-tests

@AndroidIncompatible // works in newer Android versions but fails at the version we test with
public void testToFile_AndroidIncompatible() throws Exception {
 assertThat(ClassPath.toFile(new URL("file:///c:\\Documents ~ Settings, or not\\11-12 12:05")))
   .isEqualTo(new File("/c:\\Documents ~ Settings, or not\\11-12 12:05"));
 assertThat(ClassPath.toFile(new URL("file:///C:\\Program Files\\Apache Software Foundation")))
   .isEqualTo(new File("/C:\\Program Files\\Apache Software Foundation/"));
 assertThat(ClassPath.toFile(new URL("file:///C:\\\u20320 \u22909")))  // Chinese Ni Hao
   .isEqualTo(new File("/C:\\\u20320 \u22909"));
}

相关文章