List of usage examples for org.apache.commons.vfs2 FileSelectInfo getDepth
int getDepth();
From source file:com.gs.obevo.util.vfs.BasicFileSelector.java
@Override public boolean includeFile(FileSelectInfo fileInfo) throws Exception { return fileInfo.getDepth() > 0 && this.fileFilter.accept(fileInfo); }
From source file:com.intridea.io.vfs.provider.s3.DepthFileSelector.java
@Override public boolean traverseDescendents(FileSelectInfo fileSelectInfo) throws Exception { return fileSelectInfo.getDepth() < maxDepth; }
From source file:com.intridea.io.vfs.provider.s3.DepthFileSelector.java
@Override public boolean includeFile(FileSelectInfo fileSelectInfo) throws Exception { int depth = fileSelectInfo.getDepth(); return depth >= minDepth && depth <= maxDepth; }
From source file:com.gs.obevo.util.vfs.BasicFileSelector.java
@Override public boolean traverseDescendents(FileSelectInfo fileInfo) throws Exception { if (fileInfo.getFile().getType() == FileType.FOLDER && fileInfo.getDepth() == 0) { return true; } else if (this.directoryFilter != null) { return this.directoryFilter.accept(fileInfo); } else {//from w w w. ja v a 2 s.c o m return this.traverseDescendents; } }
From source file:org.freedesktop.mime.DefaultMIMEService.java
@Override protected Collection<MIMEEntry> scanBase(FileObject base) throws IOException { FileObject[] d = listDirs(base); MimeBase mimeBase = new MimeBase(); mimeBases.put(base, mimeBase);/*from w ww . j av a 2 s . c om*/ if (d != null) { for (FileObject dir : d) { String family = dir.getName().getBaseName(); if (!family.equals("packages")) { Log.debug("Scanning family " + family); FileObject[] t = dir.findFiles(new FileSelector() { public boolean traverseDescendents(FileSelectInfo info) throws Exception { return info.getDepth() == 0; } public boolean includeFile(FileSelectInfo info) throws Exception { return info.getFile().getName().getBaseName().toLowerCase().endsWith(".xml"); } }); for (FileObject type : t) { String typeName = type.getName().getBaseName().substring(0, type.getName().getBaseName().length() - 4); MIMEEntry entry = new MIMEEntry(family, typeName, type); Log.debug(" Adding type " + entry.getInternalName()); mimeBase.byType.put(entry.getInternalName(), entry); } } } } return mimeBase.byType.values(); }
From source file:org.freedesktop.util.ExtensionSelector.java
public boolean traverseDescendents(FileSelectInfo info) throws Exception { return info.getDepth() == 0; }
From source file:org.pentaho.hadoop.shim.HadoopConfigurationLocator.java
/** * Attempt to find any Hadoop configuration as a direct descendant of the provided directory. * * @param baseDir Directory to look for Hadoop configurations in * @throws ConfigurationException/* ww w.ja v a2 s. c om*/ */ private void findHadoopConfigurations(FileObject baseDir, ActiveHadoopConfigurationLocator activeLocator) throws ConfigurationException { configurations = new HashMap<String, HadoopConfiguration>(); try { if (!baseDir.exists()) { throw new ConfigurationException(BaseMessages.getString(PKG, "Error.HadoopConfigurationDirectoryDoesNotExist", baseDir.getURL())); } for (FileObject f : baseDir.findFiles(new FileSelector() { @Override public boolean includeFile(FileSelectInfo info) throws Exception { return info.getDepth() == 1 && FileType.FOLDER.equals(info.getFile().getType()); } @Override public boolean traverseDescendents(FileSelectInfo info) throws Exception { return info.getDepth() == 0; } })) { // Only load the specified configuration (ID should match the basename, we allow case-insensitivity) if (f.getName().getBaseName().equalsIgnoreCase(activeLocator.getActiveConfigurationId())) { HadoopConfiguration config = loadHadoopConfiguration(f); if (config != null) { configurations.put(config.getIdentifier(), config); } } } } catch (FileSystemException ex) { throw new ConfigurationException(BaseMessages.getString(PKG, "Error.UnableToLoadConfigurations", baseDir.getName().getFriendlyURI()), ex); } }
From source file:org.pentaho.hadoop.shim.HadoopConfigurationLocator.java
private List<URL> findJarsIn(FileObject path, final int maxdepth, final Set<String> paths) throws FileSystemException { FileObject[] jars = path.findFiles(new FileSelector() { @Override// w w w. j a v a 2 s. com public boolean includeFile(FileSelectInfo info) throws Exception { for (String path : paths) { if (info.getFile().getURL().toString().endsWith(path)) { return false; } } return info.getFile().getName().getBaseName().endsWith(JAR_EXTENSION); } @Override public boolean traverseDescendents(FileSelectInfo info) throws Exception { for (String path : paths) { if (info.getFile().getURL().toString().endsWith(path)) { return false; } } return info.getDepth() <= maxdepth; } }); List<URL> jarUrls = new ArrayList<URL>(); for (FileObject jar : jars) { jarUrls.add(jar.getURL()); } return jarUrls; }
From source file:org.pentaho.metaverse.util.VfsDateRangeFilterTest.java
@Test public void testAccept_notFolder() throws Exception { filter = new VfsDateRangeFilter(format, start); FileSelectInfo fsi = mock(FileSelectInfo.class); FileObject fo = mock(FileObject.class); when(fo.getType()).thenReturn(FileType.FILE); when(fsi.getFile()).thenReturn(fo);//w ww. j ava 2s . c o m when(fsi.getDepth()).thenReturn(1); assertFalse(filter.includeFile(fsi)); }
From source file:org.pentaho.metaverse.util.VfsDateRangeFilterTest.java
@Test public void testAccept_startDateSet() throws Exception { filter = new VfsDateRangeFilter(format, start); FileSelectInfo fsi = mock(FileSelectInfo.class); FileObject fo = mock(FileObject.class); FileName fn = mock(FileName.class); when(fn.getBaseName()).thenReturn(end); when(fo.getType()).thenReturn(FileType.FOLDER); when(fo.getName()).thenReturn(fn);/*from ww w.java 2s . c o m*/ when(fsi.getFile()).thenReturn(fo); when(fsi.getDepth()).thenReturn(1); assertTrue(filter.includeFile(fsi)); when(fn.getBaseName()).thenReturn(start); assertTrue("Start date is not inclusive", filter.includeFile(fsi)); when(fn.getBaseName()).thenReturn("20000101"); assertFalse("Before start date was accepted", filter.includeFile(fsi)); }