本文整理汇总了Java中org.apache.commons.vfs2.FileSelectInfo类的典型用法代码示例。如果您正苦于以下问题:Java FileSelectInfo类的具体用法?Java FileSelectInfo怎么用?Java FileSelectInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileSelectInfo类属于org.apache.commons.vfs2包,在下文中一共展示了FileSelectInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: includeFile
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
/**
* Determines if a file or folder should be selected.
*/
public boolean includeFile(final FileSelectInfo fileInfo)
throws FileSystemException
{
final FileObject file = fileInfo.getFile();
if (file == currentFolder)
{
// Pop current folder
assertEquals(0, children.size());
currentFolder = currentFolder.getParent();
currentFolderInfo = currentFolderInfo.getParent();
children = stack.remove(0);
}
final String baseName = file.getName().getBaseName();
final FileInfo childInfo = getChild(baseName);
assertSame(childInfo.type, file.getType());
final boolean isChild = children.remove(baseName);
assertTrue(isChild);
files.add(file);
return true;
}
示例2: includeOne
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
public static boolean includeOne(FileSelector selector, FileObject resource, FileSelectInfo info)
throws FileSystemException, Exception {
switch(resource.getType()) {
case FILE:
if(!selector.includeFile(info)) {
return false;
}
break;
case FOLDER:
if(!selector.traverseDescendents(info)) {
return false;
}
break;
case FILE_OR_FOLDER:
case IMAGINARY:
if(!selector.includeFile(info) || !selector.traverseDescendents(info)) {
return false;
}
break;
}
return true;
}
示例3: accept
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
/**
* Checks to see if the file can be written to.
*
* @param fileInfo
* the File to check
*
* @return {@code true} if the file can be written to, otherwise
* {@code false}.
*/
@Override
public boolean accept(final FileSelectInfo fileInfo) {
try {
final FileSystem fileSystem = fileInfo.getFile().getFileSystem();
if (fileInfo.getFile().exists()) {
if (!fileSystem.hasCapability(Capability.WRITE_CONTENT)) {
return false;
}
return fileInfo.getFile().isWriteable();
} else {
if (!fileSystem.hasCapability(Capability.CREATE)) {
return false;
}
return fileInfo.getFile().getParent().isWriteable();
}
} catch (final FileSystemException ex) {
throw new RuntimeException(ex);
}
}
示例4: accept
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
/**
* Checks to see if the size of the file is favorable.
* <p>
* If size equals threshold and smaller files are required, file <b>IS
* NOT</b> selected. If size equals threshold and larger files are required,
* file <b>IS</b> selected.
* <p>
* Non-existing files return always false (will never be accepted).
*
* @param fileInfo
* the File to check
*
* @return true if the filename matches
*/
@Override
public boolean accept(final FileSelectInfo fileInfo) {
try {
final FileObject file = fileInfo.getFile();
if (!file.exists()) {
return false;
}
final FileContent content = file.getContent();
try {
final long length = content.getSize();
final boolean smaller = length < size;
return acceptLarger ? !smaller : smaller;
} finally {
content.close();
}
} catch (final FileSystemException ex) {
throw new RuntimeException(ex);
}
}
示例5: accept
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
/**
* Checks to see if the file is empty. A non-existing file is also
* considered empty.
*
* @param fileInfo
* the file or directory to check
*
* @return {@code true} if the file or directory is <i>empty</i>, otherwise
* {@code false}.
*/
@Override
public boolean accept(final FileSelectInfo fileInfo) {
final FileObject file = fileInfo.getFile();
try {
if (!file.exists()) {
return true;
}
if (file.getType() == FileType.FOLDER) {
final FileObject[] files = file.getChildren();
return files == null || files.length == 0;
}
final FileContent content = file.getContent();
try {
return content.getSize() == 0;
} finally {
content.close();
}
} catch (final FileSystemException ex) {
throw new RuntimeException(ex);
}
}
示例6: testAccept
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
@Test
public void testAccept() {
FileSelectInfo any = createFSI(new File("anyfile"));
// Empty
assertThat(new OrFileFilter().accept(any)).isFalse();
// True
assertThat(new OrFileFilter(new True()).accept(any)).isTrue();
assertThat(new OrFileFilter(new True(), new True()).accept(any)).isTrue();
assertThat(new OrFileFilter(new False(), new True()).accept(any)).isTrue();
assertThat(new OrFileFilter(new True(), new False()).accept(any)).isTrue();
// False
assertThat(new OrFileFilter(new False()).accept(any)).isFalse();
assertThat(new OrFileFilter(new False(), new False()).accept(any)).isFalse();
}
示例7: testAccept
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
@Test
public void testAccept() {
FileSelectInfo any = createFSI(new File("anyfile"));
// Empty
assertThat(new AndFileFilter().accept(any)).isFalse();
// True
assertThat(new AndFileFilter(new True()).accept(any)).isTrue();
assertThat(new AndFileFilter(new True(), new True()).accept(any)).isTrue();
// False
assertThat(new AndFileFilter(new False()).accept(any)).isFalse();
assertThat(new AndFileFilter(new False(), new False()).accept(any)).isFalse();
assertThat(new AndFileFilter(new False(), new True()).accept(any)).isFalse();
assertThat(new AndFileFilter(new True(), new False()).accept(any)).isFalse();
}
示例8: includeFile
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
public boolean includeFile( FileSelectInfo info ) {
boolean returncode = false;
try {
if ( !info.getFile().toString().equals( sourceFolder ) ) {
// Pass over the Base folder itself
String short_filename = info.getFile().getName().getBaseName();
if ( info.getFile().getParent().equals( info.getBaseFolder() )
|| ( !info.getFile().getParent().equals( info.getBaseFolder() ) && includeSubfolders ) ) {
if ( ( info.getFile().getType() == FileType.FILE && fileWildcard == null )
|| ( info.getFile().getType() == FileType.FILE && fileWildcard != null && GetFileWildcard(
short_filename, fileWildcard ) ) ) {
returncode = true;
}
}
}
} catch ( Exception e ) {
logError( "Error while finding files ... in ["
+ info.getFile().toString() + "]. Exception :" + e.getMessage() );
returncode = false;
}
return returncode;
}
示例9: includeFile
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
public boolean includeFile( FileSelectInfo info ) {
boolean returncode = false;
try {
if ( !info.getFile().toString().equals( sourceFolder ) ) {
// Pass over the Base folder itself
String short_filename = info.getFile().getName().getBaseName();
if ( info.getFile().getParent().equals( info.getBaseFolder() )
|| ( ( !info.getFile().getParent().equals( info.getBaseFolder() ) && meta.isIncludeSubFolders() ) ) ) {
if ( ( info.getFile().getType() == FileType.FILE && fileWildcard == null )
|| ( info.getFile().getType() == FileType.FILE && fileWildcard != null && GetFileWildcard(
short_filename, fileWildcard ) ) ) {
returncode = true;
}
}
}
} catch ( Exception e ) {
logError( BaseMessages.getString( PKG, "Mail.Error.FindingFiles", info.getFile().toString(), e
.getMessage() ) );
returncode = false;
}
return returncode;
}
示例10: getFileSelectInfo
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
private FileSelectInfo getFileSelectInfo(String fileBaseName) {
FileName fileNameObject = mock(FileName.class);
when(fileNameObject.getBaseName()).thenReturn(fileBaseName);
org.apache.commons.vfs2.FileObject file = mock(org.apache.commons.vfs2.FileObject.class);
when(file.getName()).thenReturn(fileNameObject);
FileSelectInfo info = mock(FileSelectInfo.class);
when(info.getFile()).thenReturn(file);
return info;
}
示例11: traverseDescendents
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
@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 {
return this.traverseDescendents;
}
}
示例12: accept
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
@Override
public boolean accept(FileSelectInfo fileInfo) {
try {
return fileInfo.getFile().getType() == FileType.FOLDER;
} catch (FileSystemException e) {
throw new RuntimeException(e);
}
}
示例13: accept
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
@Override
public boolean accept(FileSelectInfo fileInfo) {
for (FileFilter f : this.filters) {
if (!f.accept(fileInfo)) {
return false;
}
}
return true;
}
示例14: accept
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
@Override
public boolean accept(FileSelectInfo fileInfo) {
for (FileFilter f : this.filters) {
if (f.accept(fileInfo)) {
return true;
}
}
return false;
}
示例15: traverseDescendents
import org.apache.commons.vfs2.FileSelectInfo; //导入依赖的package包/类
/**
* Determines whether a folder should be traversed.
*/
public boolean traverseDescendents(final FileSelectInfo fileInfo)
throws FileSystemException
{
// Check that the given file is a folder
final FileObject folder = fileInfo.getFile();
assertSame(FileType.FOLDER, folder.getType());
// Locate the info for the folder
final String baseName = folder.getName().getBaseName();
if (currentFolder == null)
{
assertEquals(rootFile.baseName, baseName);
currentFolderInfo = rootFile;
}
else
{
assertSame(currentFolder, folder.getParent());
// Locate the info for the child, and make sure it is folder
currentFolderInfo = getChild(baseName);
assertSame(FileType.FOLDER, currentFolderInfo.type);
}
// Push the folder
stack.add(0, children);
children = new HashSet<String>(currentFolderInfo.children.keySet());
currentFolder = folder;
return true;
}