Example usage for org.apache.commons.vfs FileType FILE

List of usage examples for org.apache.commons.vfs FileType FILE

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileType FILE.

Prototype

FileType FILE

To view the source code for org.apache.commons.vfs FileType FILE.

Click Source Link

Document

A regular file.

Usage

From source file:com.jaspersoft.jasperserver.api.metadata.common.util.RepositoryFileSystem.java

/**
 * Finds a file in this file system.// w ww.ja v  a  2 s.c  o m
 *
 * @param nameStr URI
 * @return VFS FileObject
 * @throws FileSystemException
 */
@Override
public FileObject resolveFile(final String nameStr) throws FileSystemException {
    // Resolve the name, and create the file
    final FileName workingFileName = new RepositoryFileName(scheme, nameStr, FileType.FILE);
    return resolveFile(workingFileName);
}

From source file:com.rapleaf.ramhdfs.RamFileSystem.java

private static boolean isFile(FileObject fo) {
    try {/*from  w  w w . j av a  2s  .  c om*/
        return fo.getType() == FileType.FILE;
    } catch (FileSystemException e) {
        throw new RuntimeException(e);
    }
}

From source file:net.didion.loopy.vfs.provider.iso.IsoFileObject.java

/**
 * Sets the ISO9660FileEntry that backs this FileObject. This method is package-private because
 * IsoFileSystem pre-creates some directory entries when building the file index, and it needs
 * to set the backing entry after the fact.
 *
 * @param entry/*from  www .  j  a  v a2 s  . co m*/
 */
void setIsoEntry(final ISO9660FileEntry entry) {
    if (null != this.entry) {
        throw new RuntimeException("Cannot change the underlying entry once it has been set");
    }
    if (null == entry) {
        throw new IllegalArgumentException("'entry' cannot be null");
    }

    this.entry = entry;
    this.type = (entry.isDirectory()) ? FileType.FOLDER : FileType.FILE;
}

From source file:cc.aileron.dao.db.sql.G2DaoSqlMapImpl.java

@Override
public void compile(final Class<?> targetClass)
        throws IOException, ResourceNotFoundException, TemplateSyntaxEexception, ParserMethodNotFoundException {
    final String sqlDir = getDir(targetClass);
    if (StringUtils.isEmpty(sqlDir)) {
        return;/*from  w w w . ja v a  2  s . c  o  m*/
    }

    logger.trace("compile : {} @ {}", targetClass, sqlDir);

    final Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources(sqlDir);

    while (urls.hasMoreElements()) {
        final URL url = urls.nextElement();
        final Resource resource = ResourceConvertUtils.convertUrl(url);
        for (final FileObject file : resource.toFileObject().getChildren()) {
            final String name = file.getName().getBaseName().split("\\.")[0];

            logger.trace("load sql-file : {}.sql", name);

            if (!file.getType().equals(FileType.FILE) || !file.getName().getExtension().equals("sql")) {
                continue;
            }

            /*
             * SQL??
             */
            final Template template = compiler.compile(resource(file.getContent()).toString());

            /*
             * findBy -> find ????
             */
            final String key = name.replaceFirst("^findBy", "find").replaceFirst("^countBy", "count")
                    .replaceFirst("^updateBy", "update").replaceFirst("^deleteBy", "delete")
                    .replaceFirst("^executeBy", "execute");

            final HashMap<String, Template> m = sqlMap.get(targetClass);
            m.put(key, template);
            m.put(name, template);
        }
    }
}

From source file:com.github.stephenc.javaisotools.vfs.provider.iso.IsoFileObject.java

/**
 * Sets the Iso9660FileEntry that backs this FileObject. This method is package-private because IsoFileSystem
 * pre-creates some directory entries when building the file index, and it needs to set the backing entry after the
 * fact./*from  www.j  a  v a  2  s. c om*/
 */
void setIsoEntry(final Iso9660FileEntry entry) {
    if (null != this.entry) {
        throw new RuntimeException("Cannot change the underlying entry once it has been set");
    }
    if (null == entry) {
        throw new IllegalArgumentException("'entry' cannot be null");
    }

    this.entry = entry;
    this.type = (entry.isDirectory()) ? FileType.FOLDER : FileType.FILE;
}

From source file:cc.aileron.commons.util.ClassPattrnFinderUtils.java

/**
 * ??????//  w w w . ja v a 2 s .  c  o m
 * 
 * @param targetPackage
 * @param pattern
 * @return
 * @throws IOException
 * @throws URISyntaxException
 * @throws ResourceNotFoundException
 */
private static final List<Class<?>> tryGetClassNameList(final String targetPackage, final Pattern pattern)
        throws IOException, URISyntaxException, ResourceNotFoundException {
    final List<Class<?>> result = new ArrayList<Class<?>>();

    final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

    final String path = targetPackage.replace('.', '/') + "/";
    final Enumeration<URL> urls = classLoader.getResources(path);
    while (urls.hasMoreElements()) {
        final URL url = urls.nextElement();
        final Resource resource = ResourceConvertUtils.convertUrl(url);
        for (final FileObject file : resource.toFileObject().getChildren()) {
            final String name = file.getName().getBaseName().split("\\.")[0];
            if (!file.getType().equals(FileType.FILE) || !file.getName().getExtension().equals("class")) {
                continue;
            }
            if (pattern != null && !pattern.matcher(name).matches()) {
                continue;
            }

            final Class<?> classObject = getClass(targetPackage + "." + name);
            if (classObject != null) {
                result.add(classObject);
            }
        }
    }
    return result;
}

From source file:com.jaspersoft.jasperserver.api.metadata.common.util.RepositoryFileObject.java

@Override
protected FileType doGetType() throws Exception {

    if (folder != null) {
        return FileType.FOLDER;
    } else if (fileResource != null) {
        return FileType.FILE;
    } else {/*  w  ww .ja  v  a 2 s  . co m*/
        return FileType.IMAGINARY;
    }
}

From source file:com.thinkberg.vfs.s3.tests.S3FileProviderTest.java

public void testCreateFile() throws IOException {
    FileObject object = ROOT.resolveFile(FILE);
    assertFalse(object.exists());/*  w  w  w .j a v a 2 s.co m*/
    OutputStream os = object.getContent().getOutputStream();
    os.write(0xfc);
    os.close();
    assertTrue(object.exists());
    assertEquals(FileType.FILE, object.getType());
}

From source file:com.thinkberg.vfs.s3.tests.S3FileProviderTest.java

public void testCreateEmptyFile() throws IOException {
    FileObject object = ROOT.resolveFile(FILE + ".empty");
    assertFalse(object.exists());//from w  w w.  ja  va 2s  .c o m
    object.createFile();
    assertTrue(object.exists());
    assertEquals(FileType.FILE, object.getType());
}

From source file:com.panet.imeta.trans.steps.getfilesrowscount.GetFilesRowsCount.java

private void getRowNumber() throws KettleException {
    try {//from   w w  w  .  j a  va 2 s .  c o  m
        if (data.file.getType() == FileType.FILE) {
            data.fr = KettleVFS.getInputStream(data.file);
            data.isr = new InputStreamReader(new BufferedInputStream(data.fr, BUFFER_SIZE_INPUT_STREAM));

            int c = 0;
            data.lineStringBuffer.setLength(0);

            while (c >= 0) {
                c = data.isr.read();

                if (c == data.separator) {
                    // Move Row number pointer ahead
                    data.rownr++;
                }
            }
        }
        if (log.isDetailed())
            log.logDetailed(toString(), Messages.getString("GetFilesRowsCount.Log.RowsInFile",
                    data.file.toString(), "" + data.rownr));
    } catch (Exception e) {
        throw new KettleException(e);
    }

}