/** * @see org.apache.commons.io.DirectoryWalker#handleFile(java.io.File, int, java.util.Collection) */ @SuppressWarnings("unchecked") @Override protected void handleFile(File file, int depth, Collection results) throws IOException { String absFilename = FilenameUtils.normalize(file.getAbsolutePath()); String relFilename = absFilename.substring(startDirnameLength+1); String classname = Converter.resourceToClass(relFilename); results.add(classname); }
private static void addElementsFromArchive(Collection<String> elements, File archive, String suffix) throws IOException { Collection<String> allElements = readElementsFromNestedArchive(archive); for(String resource : allElements) { if (resource.endsWith(suffix)) { elements.add(Converter.resourceToClass(resource)); } } }
/** * Adds the classes from archive. * * @param classSet the class set * @param archive the archive * * @throws IOException Signals that an I/O exception has occurred. */ @ProfileMe private static void addClassesFromArchive(final Set<String> classSet, final File archive) throws IOException { ZipFile zipFile = new ZipFile(archive); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); String name = entry.getName(); if (name.endsWith(".class")) { classSet.add(Converter.resourceToClass(name)); } } }
/** * Walk thru the directories and return all class files as classname, e.g. a * file java/lang/String.class should be returned as "java.lang.String". * <p> * See also <a href= * "http://commons.apache.org/io/api-release/org/apache/commons/io/DirectoryWalker.html"> * DirectoryWalker</a>. * </p> * * @return a collection of classnames * @throws IOException * Signals that an I/O exception has occurred. */ public Collection<String> getClasses() throws IOException { Collection<String> resources = this.getResources(); Collection<String> classes = new ArrayList<>(resources.size()); for (String res : resources) { classes.add(Converter.resourceToClass(res)); } return classes; }