当前位置: 首页>>代码示例>>Java>>正文


Java ResourceInfo.getResourceName方法代码示例

本文整理汇总了Java中com.google.common.reflect.ClassPath.ResourceInfo.getResourceName方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceInfo.getResourceName方法的具体用法?Java ResourceInfo.getResourceName怎么用?Java ResourceInfo.getResourceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.reflect.ClassPath.ResourceInfo的用法示例。


在下文中一共展示了ResourceInfo.getResourceName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ApiDocumentMetadata

import com.google.common.reflect.ClassPath.ResourceInfo; //导入方法依赖的package包/类
/**
 * 
 * @param document The resource pointing to the document to be represented
 * @param docSuffix The portion of the filename that should be removed for Title generation
 */
public ApiDocumentMetadata(ResourceInfo document, String docSuffix) {
	this.document = document;

	String name = document.getResourceName();
	String title = name;
	if (name.contains("/") && !name.endsWith("/")) {
		name = name.substring(name.lastIndexOf("/") + 1);
		title = StringUtils.capitalize(name).replace(docSuffix, "");
	}
	this.path = name;
	this.title = title;
}
 
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:18,代码来源:ApiDocumentMetadata.java

示例2: data

import com.google.common.reflect.ClassPath.ResourceInfo; //导入方法依赖的package包/类
@Parameters(name = "{index}: {0}")
public static Iterable<Object[]> data() throws IOException {
  Path testDataPath = Paths.get("com/google/googlejavaformat/java/testdata");
  ClassLoader classLoader = FormatterIntegrationTest.class.getClassLoader();
  Map<String, String> inputs = new TreeMap<>();
  Map<String, String> outputs = new TreeMap<>();
  for (ResourceInfo resourceInfo : ClassPath.from(classLoader).getResources()) {
    String resourceName = resourceInfo.getResourceName();
    Path resourceNamePath = Paths.get(resourceName);
    if (resourceNamePath.startsWith(testDataPath)) {
      Path subPath = testDataPath.relativize(resourceNamePath);
      assertEquals("bad testdata file names", 1, subPath.getNameCount());
      String baseName = getNameWithoutExtension(subPath.getFileName().toString());
      String extension = getFileExtension(subPath.getFileName().toString());
      String contents;
      try (InputStream stream =
          FormatterIntegrationTest.class.getClassLoader().getResourceAsStream(resourceName)) {
        contents = CharStreams.toString(new InputStreamReader(stream, UTF_8));
      }
      switch (extension) {
        case "input":
          inputs.put(baseName, contents);
          break;
        case "output":
          outputs.put(baseName, contents);
          break;
        default:
      }
    }
  }
  List<Object[]> testInputs = new ArrayList<>();
  assertEquals("unmatched inputs and outputs", inputs.size(), outputs.size());
  for (Map.Entry<String, String> entry : inputs.entrySet()) {
    String fileName = entry.getKey();
    String input = inputs.get(fileName);
    assertTrue("unmatched input", outputs.containsKey(fileName));
    String expectedOutput = outputs.get(fileName);
    testInputs.add(new Object[] {fileName, input, expectedOutput});
  }
  return testInputs;
}
 
开发者ID:google,项目名称:google-java-format,代码行数:42,代码来源:FormatterIntegrationTest.java


注:本文中的com.google.common.reflect.ClassPath.ResourceInfo.getResourceName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。