Example usage for org.apache.commons.vfs2 FileSelectInfo FileSelectInfo

List of usage examples for org.apache.commons.vfs2 FileSelectInfo FileSelectInfo

Introduction

In this page you can find the example usage for org.apache.commons.vfs2 FileSelectInfo FileSelectInfo.

Prototype

FileSelectInfo

Source Link

Usage

From source file:org.fuin.vfs2.filter.BaseFilterTest.java

/**
 * Creates a file select info object for the given file.
 * /*from ww  w  .  j a v  a 2 s  .  c om*/
 * @param file
 *            File to create an info for.
 * 
 * @return File selct info.
 */
protected static FileSelectInfo createFSI(final File file) {
    try {
        final FileSystemManager fsManager = VFS.getManager();
        final FileObject fileObject = fsManager.toFileObject(file);
        return new FileSelectInfo() {
            @Override
            public FileObject getFile() {
                return fileObject;
            }

            @Override
            public int getDepth() {
                return 0;
            }

            @Override
            public FileObject getBaseFolder() {
                try {
                    return fileObject.getParent();
                } catch (FileSystemException ex) {
                    throw new RuntimeException(ex);
                }
            }
        };
    } catch (FileSystemException ex) {
        throw new RuntimeException(ex);
    }
}