public final void traverse(P path, Visitor<P> visitor) throws IOException { // This is OK as it always return true @SuppressWarnings("unchecked") Filter<P> filter = NULL; traverse(path, filter, visitor); }
public final void traverse(P path, Visitor<P> visitor) throws IOException { // This is OK as it always return true @SuppressWarnings("unchecked") Filter<P> filter = NULL; traverse(path, filter, visitor); }
public final void dump(P path, final Appendable appendable) throws IOException { final StringBuilder prefix = new StringBuilder(); traverse(path, new Visitor<P>() { public void enterDir(P dir, String name) throws IOException { if (name.length() > 0) { prefix.append('/').append(name); } } public void file(P file, String name) throws IOException { appendable.append(prefix).append(name).append("\n"); } public void leaveDir(P dir, String name) throws IOException { if (name.length() > 0) { prefix.setLength(prefix.length() - 1 - name.length()); } } }); }
public final void dump(P path, final Appendable appendable) throws IOException { final StringBuilder prefix = new StringBuilder(); traverse(path, new Visitor<P>() { public void enterDir(P dir, String name) throws IOException { if (name.length() > 0) { prefix.append('/').append(name); } } public void file(P file, String name) throws IOException { appendable.append(prefix).append(name).append("\n"); } public void leaveDir(P dir, String name) throws IOException { if (name.length() > 0) { prefix.setLength(prefix.length() - 1 - name.length()); } } }); }
public final void traverse(Filter<P> filter, Visitor<P> visitor) throws IOException { traverse(getRoot(), filter, visitor); }
public final void traverse(Visitor<P> visitor) throws IOException { traverse(getRoot(), visitor); }
public final void traverse(Filter<P> filter, Visitor<P> visitor) throws IOException { traverse(getRoot(), filter, visitor); }
public final void traverse(Visitor<P> visitor) throws IOException { traverse(getRoot(), visitor); }
public final int size(final int mode) throws IOException { switch (mode) { case DIR: case PATH: case FILE: break; default: throw new IllegalArgumentException("Illegal mode " + mode); } final AtomicInteger size = new AtomicInteger(); traverse(new Visitor.Default<P>() { @Override public void enterDir(P dir, String name) throws IOException { if (getLastModified(dir) > 0 && (mode == PATH || mode == DIR)) { size.incrementAndGet(); } } @Override public void file(P file, String name) throws IOException { if (getLastModified(file) > 0 && (mode == PATH || mode == FILE)) { size.incrementAndGet(); } } }); return size.get(); }
public final int size(final int mode) throws IOException { switch (mode) { case DIR: case PATH: case FILE: break; default: throw new IllegalArgumentException("Illegal mode " + mode); } final AtomicInteger size = new AtomicInteger(); traverse(new Visitor.Default<P>() { @Override public void enterDir(P dir, String name) throws IOException { if (getLastModified(dir) > 0 && (mode == PATH || mode == DIR)) { size.incrementAndGet(); } } @Override public void file(P file, String name) throws IOException { if (getLastModified(file) > 0 && (mode == PATH || mode == FILE)) { size.incrementAndGet(); } } }); return size.get(); }
private <P> Collection<JavaFileObject> getFromSourcePath(final SimpleFileManager<P> fileManager) throws IOException { final ArrayList<JavaFileObject> javaFiles = new ArrayList<JavaFileObject>(); final StringBuilder buffer = new StringBuilder(); fileManager.getFileSystem().traverse(new Visitor.Default<P>() { @Override public void enterDir(Object dir, String name) throws IOException { if (name.length() > 0) { buffer.append(name).append('.'); } } public void file(P file, String name) throws IOException { if (name.endsWith(".java")) { FileKey key = FileKey.newJavaName(buffer.substring(0, buffer.length() - 1), name); JavaFileObject fileObject = fileManager.getReadable(key); javaFiles.add(fileObject); } } @Override public void leaveDir(Object dir, String name) throws IOException { if (name.length() > 0) { buffer.setLength(buffer.length() - name.length() - 1); } } }); return javaFiles; }
private <P> Collection<JavaFileObject> getFromSourcePath(final SimpleFileManager<P> fileManager) throws IOException { final ArrayList<JavaFileObject> javaFiles = new ArrayList<JavaFileObject>(); final StringBuilder buffer = new StringBuilder(); fileManager.getFileSystem().traverse(new Visitor.Default<P>() { @Override public void enterDir(Object dir, String name) throws IOException { if (name.length() > 0) { buffer.append(name).append('.'); } } public void file(P file, String name) throws IOException { if (name.endsWith(".java")) { FileKey key = FileKey.newJavaName(buffer.substring(0, buffer.length() - 1), name); JavaFileObject fileObject = fileManager.getReadable(key); javaFiles.add(fileObject); } } @Override public void leaveDir(Object dir, String name) throws IOException { if (name.length() > 0) { buffer.setLength(buffer.length() - name.length() - 1); } } }); return javaFiles; }
fs.traverse(scanner, new Visitor<P>() {
fs.traverse(scanner, new Visitor<P>() {
final ArrayList<String> beanClasses = new ArrayList<String>(); for (final ReadFileSystem fileSystem : fileSystems) { fileSystem.traverse(new Visitor.Default() { @Override public void enterDir(Object dir, String name) throws IOException {
final ArrayList<String> beanClasses = new ArrayList<String>(); for (final ReadFileSystem fileSystem : fileSystems) { fileSystem.traverse(new Visitor.Default() { @Override public void enterDir(Object dir, String name) throws IOException {
public final void traverse(P path, Filter<P> filter, Visitor<P> visitor) throws IOException { String name = getName(path); if (isDir(path)) { if (filter.acceptDir(path, name)) { visitor.enterDir(path, name); for (Iterator<P> i = getChildren(path);i.hasNext();) { P child = i.next(); traverse(child, filter, visitor); } visitor.leaveDir(path, name); } } else if (filter.acceptFile(path, name)) { visitor.file(path, name); } }
public final void traverse(P path, Filter<P> filter, Visitor<P> visitor) throws IOException { String name = getName(path); if (isDir(path)) { if (filter.acceptDir(path, name)) { visitor.enterDir(path, name); for (Iterator<P> i = getChildren(path);i.hasNext();) { P child = i.next(); traverse(child, filter, visitor); } visitor.leaveDir(path, name); } } else if (filter.acceptFile(path, name)) { visitor.file(path, name); } }