/** * Visit the virtual file system * * @param visitor the visitor * @throws IOException for any problem accessing the virtual file system * @throws IllegalArgumentException if the visitor is null * @throws IllegalStateException if the file is closed */ public void visit(VirtualFileVisitor visitor) throws IOException { visit(visitor, true); }
private synchronized void loadEntries() throws URISyntaxException, IOException { if (m_entries.size() == 0) { final VirtualFile root = VFS.getChild(m_url.toURI()); final String uriPath = m_url.toURI().getPath(); root.visit(new VirtualFileVisitor() { public void visit(VirtualFile vfile) { String entryPath = vfile.getPathName().substring(uriPath.length()); m_entries.put(entryPath, vfile); } public VisitorAttributes getAttributes() { return VisitorAttributes.RECURSE_LEAVES_ONLY; } }); } } }
private synchronized void loadEntries() throws URISyntaxException, IOException { if (m_entries.size() == 0) { final VirtualFile root = VFS.getChild(m_url.toURI()); final String uriPath = m_url.toURI().getPath(); root.visit(new VirtualFileVisitor() { public void visit(VirtualFile vfile) { String entryPath = vfile.getPathName().substring(uriPath.length()); m_entries.put(entryPath, vfile); } public VisitorAttributes getAttributes() { return VisitorAttributes.RECURSE_LEAVES_ONLY; } }); } } }
/** * Add all children as candidates * * @param context the structure context * @param attributes the visitor attributes uses {@link VisitorAttributes#DEFAULT} when null * @throws Exception for any error */ protected void addChildren(StructureContext context, VisitorAttributes attributes) throws Exception { if (context == null) throw new IllegalArgumentException("Null context"); VirtualFile file = context.getFile(); VirtualFileVisitor visitor = candidateStructureVisitorFactory.createVisitor(context, attributes); file.visit(visitor); }
/** * Get the classes we want to scan. * * @param unit the deployment unit * @param mainClassName the main class name * @param classpath the classpath * @return possible classes containing metadata annotations * @throws IOException for any error */ protected Collection<Class<?>> getClasses(VFSDeploymentUnit unit, String mainClassName, VirtualFile classpath) throws IOException { AnnotatedClassFilter classVisitor = new AnnotatedClassFilter(unit, unit.getClassLoader(), classpath, mainClassName); classpath.visit(classVisitor); Map<VirtualFile, Class<?>> classes = classVisitor.getAnnotatedClasses(); if (classes != null && classes.size() > 0) { if(log.isTraceEnabled()) log.trace("Annotated classes: " + classes); } else { classes = new HashMap<VirtualFile, Class<?>>(); } return classes.values(); }
/** * Get the children * * @param filter to filter the children * @return the children * @throws IOException for any problem accessing the virtual file system * @throws IllegalStateException if the file is closed or it is a leaf node */ public List<VirtualFile> getChildren(VirtualFileFilter filter) throws IOException { // isDirectory does the read security check if (!isDirectory()) { return Collections.emptyList(); } if (filter == null) { filter = MatchAllVirtualFileFilter.INSTANCE; } FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter, null); visit(visitor); return visitor.getMatched(); }
/** * Get all the children recursively<p> * <p/> * This always uses {@link VisitorAttributes#RECURSE} * * @param filter to filter the children * @return the children * @throws IOException for any problem accessing the virtual file system * @throws IllegalStateException if the file is closed or it is a leaf node */ public List<VirtualFile> getChildrenRecursively(VirtualFileFilter filter) throws IOException { // isDirectory does the read security check if (!isDirectory()) { return Collections.emptyList(); } if (filter == null) { filter = MatchAllVirtualFileFilter.INSTANCE; } FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter, VisitorAttributes.RECURSE); visit(visitor); return visitor.getMatched(); }
root.visit(visitor); } catch (IOException e) { index.clear();
root.visit(visitor); } catch (IOException e) { index.clear();
root.visit(visitor); } catch (IOException e) { index.clear();
root.visit(visitor); } catch (IOException e) { index.clear();
root.visit(visitor); } catch (IOException e) { index.clear();
/** * Determine the packages * * @param roots the roots * @param excludedRoots the excluded roots * @param exportAll the exportAll * @param included the included packages * @param excluded the excluded packages * @param excludedExport the excluded export packages * @return the packages */ public static Set<String> determineAllPackages(VirtualFile[] roots, VirtualFile[] excludedRoots, ExportAll exportAll, ClassFilter included, ClassFilter excluded, ClassFilter excludedExport) { PackageVisitor visitor = new PackageVisitor(roots, excludedRoots, exportAll, included, excluded, excludedExport); for (VirtualFile root : roots) { try { visitor.setRoot(root); root.visit(visitor); } catch (Exception e) { throw new Error("Error visiting " + root, e); } } return visitor.getPackages(); }
root.visit(vfsVisitor);
@Override protected boolean hasDeploymentContextBeenModified(VirtualFile root, VFSDeploymentContext deploymentContext) throws IOException { boolean modified = delegate.hasDeploymentContextBeenModified(root, deploymentContext); // it was not modifed & we're actually temped if (modified == false && root != deploymentContext.getRoot()) { // check for update or delete VirtualFile tempRoot = deploymentContext.getRoot(); UpdateDeleteVisitor udVisitor = new UpdateDeleteVisitor(filter, tempAttributes, getCache(), synchAdapter, root, tempRoot); tempRoot.visit(udVisitor); // check for addition AddVisitor addVisitor = new AddVisitor(filter, originalAttributes, getCache(), synchAdapter, root, tempRoot); root.visit(addVisitor); } return modified; }
root.visit(visitor);
/** * Create a new VFSFindEntriesEnumeration. * * @param root the root file * @param file the file to enumerate * @param filePattern the file pattern * @param recurse whether to recurse * @throws IOException for any error */ public VFSFindEntriesEnumeration(VirtualFile root, VirtualFile file, String filePattern, boolean recurse) throws IOException { if (root == null) throw MESSAGES.illegalArgumentNull("root"); if (file == null) throw MESSAGES.illegalArgumentNull("file"); String rootPath = root.getPathName(); VisitorAttributes attributes = new VisitorAttributes(); attributes.setIncludeRoot(false); attributes.setLeavesOnly(false); if (recurse) attributes.setRecurseFilter(MatchAllVirtualFileFilter.INSTANCE); VisitorImpl visitor = new VisitorImpl(rootPath, filePattern, attributes); file.visit(visitor); this.paths = visitor.paths.iterator(); }
private void visit(VirtualFileVisitor visitor, boolean root) throws IOException { final VisitorAttributes visitorAttributes = visitor.getAttributes(); if (root && visitorAttributes.isIncludeRoot()) { visitor.visit(this); } // isDirectory does the read security check if (!isDirectory()) { return; } for (VirtualFile child : getChildren()) { // Always visit a leaf, and visit directories when leaves only is false if (!child.isDirectory() || !visitorAttributes.isLeavesOnly()) { visitor.visit(child); } if (child.isDirectory() && visitorAttributes.isRecurse(child)) { child.visit(visitor, false); } } }
final List<VirtualFile> list = new ArrayList<VirtualFile>(1); try { deploymentRoot.visit(new VirtualFileVisitor() { public void visit(VirtualFile virtualFile) { if (virtualFile.getName().endsWith(".jar")) {