MCPcopy Create free account
hub / github.com/antlr/codebuff / DefaultScanner

Class DefaultScanner

output/java_guava/1.4.18/ClassPath.java:483–531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481 }
482
483 @VisibleForTesting
484 static final class DefaultScanner extends Scanner {
485 private final SetMultimap<ClassLoader, String> resources = MultimapBuilder.hashKeys().linkedHashSetValues().build();
486
487 ImmutableSet<ResourceInfo> getResources() {
488 ImmutableSet.Builder<ResourceInfo> builder = ImmutableSet.builder();
489 for (Map.Entry<ClassLoader, String> entry : resources.entries()) {
490 builder.add(ResourceInfo.of(entry.getValue(), entry.getKey()));
491 }
492 return builder.build();
493 }
494
495 @Override
496 protected void scanJarFile(ClassLoader classloader, JarFile file) {
497 Enumeration<JarEntry> entries = file.entries();
498 while (entries.hasMoreElements()) {
499 JarEntry entry = entries.nextElement();
500 if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME)) {
501 continue;
502 }
503 resources.get(classloader).add(entry.getName());
504 }
505 }
506
507 @Override
508 protected void scanDirectory(ClassLoader classloader, File directory) throws IOException {
509 scanDirectory(directory, classloader, "");
510 }
511
512 private void scanDirectory(File directory, ClassLoader classloader, String packagePrefix) throws IOException {
513 File[] files = directory.listFiles();
514 if (files == null) {
515 logger.warning("Cannot read directory " + directory);
516 // IO error, just skip the directory
517 return;
518 }
519 for (File f : files) {
520 String name = f.getName();
521 if (f.isDirectory()) {
522 scanDirectory(f, classloader, packagePrefix + name + "/");
523 } else {
524 String resourceName = packagePrefix + name;
525 if (!resourceName.equals(JarFile.MANIFEST_NAME)) {
526 resources.get(classloader).add(resourceName);
527 }
528 }
529 }
530 }
531 }
532
533 @VisibleForTesting
534 static String getClassName(String filename) {

Callers

nothing calls this directly

Calls 3

hashKeysMethod · 0.95
buildMethod · 0.45
linkedHashSetValuesMethod · 0.45

Tested by

no test coverage detected