Example usage for org.apache.commons.vfs FileName getBaseName

List of usage examples for org.apache.commons.vfs FileName getBaseName

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileName getBaseName.

Prototype

public String getBaseName();

Source Link

Document

Returns the base name of this file.

Usage

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

/**
 * Attaches a child to this file. The parent IsoFileSystem calls this method when building the file index.
 *///from www .j a  v  a2  s .c o m
void attachChild(final FileName childName) {
    this.children.add(childName.getBaseName());
}

From source file:com.sonatype.nexus.plugin.groovyconsole.DefaultScriptStorage.java

private String getName(FileName name) {
    String baseName = name.getBaseName();
    baseName = baseName.substring(0, baseName.length() - DOT_GROOVY.length());
    return baseName;
}

From source file:com.sonatype.nexus.plugin.groovyconsole.DefaultScriptStorage.java

private boolean isScriptFile(FileObject file) {
    FileName name = file.getName();
    if (name.getBaseName().endsWith(DOT_GROOVY)) {
        return true;
    }/*from   w  ww. j  av a 2s  . co m*/
    return false;
}

From source file:com.adito.vfs.VFSLockManager.java

/**
 * @return <code>java.util.Collection<VFSFileLock></code> containing all the currently held locks
 *///from ww w . j  a  v a 2  s . c  om
public synchronized Collection<VFSFileLock> getCurrentLocks() {
    Collection<VFSFileLock> lockedFiles = new TreeSet<VFSFileLock>();
    for (Map.Entry<String, Collection<Lock>> entry : locksByHandle_.entrySet()) {
        String handle = entry.getKey();
        for (Lock lock : entry.getValue()) {
            try {
                FileObject file = lock.getResource().getFile();
                if (file != null) {
                    FileName name = file.getName();
                    String baseName = name.getBaseName();
                    String friendlyURI = DAVUtilities.stripUserInfo(name.getURI().toString());
                    boolean sessionsActive = areSessionsActive(lock);
                    lockedFiles.add(new VFSFileLock(baseName, friendlyURI, sessionsActive, handle));
                }
            } catch (IOException e) {
                // ignore
            }
        }
    }
    return lockedFiles;
}

From source file:net.sf.jvifm.ui.ZipLister.java

private void changeCurrentNode() {

    boolean hasMatchSelectedName = false;
    FileObject[] children = null;
    try {/*from w  w  w.j  a  v a2 s. c o  m*/
        children = currentFileObject.getChildren();
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (children == null)
        return;

    sortFiles(children);

    String selectedName = historyManager.getSelectedItem(currentFileObject.getName().getPath());
    table.removeAll();
    TableItem item;

    for (int i = 0; i < children.length; i++) {
        FileName fileName = children[i].getName();

        if (fileName.getBaseName().equals(selectedName)) {
            currentRow = i;
            hasMatchSelectedName = true;
        }

        item = new TableItem(table, SWT.NONE);
        item.setData("fileObject", children[i]);
        item.setText(fileName.getBaseName());

        try {
            FileType fileType = children[i].getType();
            FileContent fileContent = children[i].getContent();

            if (fileType.equals(FileType.FOLDER)) {
                item.setImage(folderImage);
                item.setText(1, "--");
                item.setText(2, StringUtil.formatDate(fileContent.getLastModifiedTime()));
            } else {
                item.setImage(fileImage);
                item.setText(1, StringUtil.formatSize(fileContent.getSize()));
                item.setText(2, StringUtil.formatDate(fileContent.getLastModifiedTime()));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    if (!hasMatchSelectedName)
        currentRow = 0;
    table.setSelection(currentRow);
    table.setFocus();

}

From source file:com.panet.imeta.job.Job.java

public void setInternalKettleVariables(VariableSpace var) {
    if (jobMeta != null && jobMeta.getFilename() != null) // we have a
    // finename// w ww . ja v a2 s . c  om
    // that's
    // defined.
    {
        try {
            FileObject fileObject = KettleVFS.getFileObject(jobMeta.getFilename());
            FileName fileName = fileObject.getName();

            // The filename of the transformation
            var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, fileName.getBaseName());

            // The directory of the transformation
            FileName fileDir = fileName.getParent();
            var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, fileDir.getURI());
        } catch (IOException e) {
            var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, "");
            var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, "");
        }
    } else {
        var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); //$NON-NLS-1$
        var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); //$NON-NLS-1$
    }

    // The name of the job
    var.setVariable(Const.INTERNAL_VARIABLE_JOB_NAME, Const.NVL(jobMeta.getName(), "")); //$NON-NLS-1$

    // The name of the directory in the repository
    var.setVariable(Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY,
            jobMeta.getDirectory() != null ? jobMeta.getDirectory().getPath() : ""); //$NON-NLS-1$

    // Undefine the transformation specific variables
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, null);
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, null);
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, null);
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, null);
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_NAME, null);
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY, null);
}

From source file:be.ibridge.kettle.job.JobMeta.java

/**
 * This method sets various internal kettle variables that can be used by the transformation.
 *//*from w  w w . j  av  a2s  . c o m*/
public void setInternalKettleVariables() {
    KettleVariables variables = KettleVariables.getInstance();

    if (filename != null) // we have a finename that's defined.
    {
        try {
            FileSystemManager fsManager = VFS.getManager();
            FileObject fileObject = fsManager.resolveFile(filename);
            FileName fileName = fileObject.getName();

            // The filename of the transformation
            variables.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, fileName.getBaseName());

            // The directory of the transformation
            FileName fileDir = fileName.getParent();
            variables.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, fileDir.getURI());
        } catch (IOException e) {
            variables.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, "");
            variables.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, "");
        }
    } else {
        variables.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); //$NON-NLS-1$
        variables.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); //$NON-NLS-1$
    }

    // The name of the job
    variables.setVariable(Const.INTERNAL_VARIABLE_JOB_NAME, Const.NVL(name, "")); //$NON-NLS-1$

    // The name of the directory in the repository
    variables.setVariable(Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY,
            directory != null ? directory.getPath() : ""); //$NON-NLS-1$
}

From source file:com.panet.imeta.job.JobMeta.java

/**
 * This method sets various internal kettle variables that can be used by
 * the transformation.//from  www.  j  av  a2  s.  com
 */
public void setInternalKettleVariables(VariableSpace var) {
    if (filename != null) // we have a filename that's defined.
    {
        try {
            FileObject fileObject = KettleVFS.getFileObject(filename);
            FileName fileName = fileObject.getName();

            // The filename of the transformation
            var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, fileName.getBaseName());

            // The directory of the transformation
            FileName fileDir = fileName.getParent();
            var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, fileDir.getURI());
        } catch (IOException e) {
            var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, "");
            var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, "");
        }
    } else {
        var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, ""); //$NON-NLS-1$
        var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, ""); //$NON-NLS-1$
    }

    // The name of the job
    var.setVariable(Const.INTERNAL_VARIABLE_JOB_NAME, Const.NVL(name, "")); //$NON-NLS-1$

    // The name of the directory in the repository
    var.setVariable(Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY,
            directory != null ? directory.getPath() : ""); //$NON-NLS-1$

    // Undefine the transformation specific variables:
    // transformations can't run jobs, so if you use these they are 99.99%
    // wrong.
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, null);
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, null);
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, null);
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, null);
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_NAME, null);
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY, null);
}

From source file:be.ibridge.kettle.trans.TransMeta.java

/**
     * This method sets various internal kettle variables that can be used by the transformation.
     *//*from w w w .  j ava  2s  .  c o  m*/
    public void setInternalKettleVariables() {
        KettleVariables variables = KettleVariables.getInstance();

        if (filename != null) // we have a finename that's defined.
        {
            try {
                FileSystemManager fsManager = VFS.getManager();
                FileObject fileObject = fsManager.resolveFile(filename);
                FileName fileName = fileObject.getName();

                // The filename of the transformation
                variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, fileName.getBaseName());

                // The directory of the transformation
                FileName fileDir = fileName.getParent();
                variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, fileDir.getURI());
            } catch (IOException e) {
                variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, "");
                variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, "");
            }
        } else {
            variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, "");
            variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, "");
        }

        // The name of the transformation
        variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_NAME, Const.NVL(name, ""));

        // The name of the directory in the repository
        variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY,
                directory != null ? directory.getPath() : "");
    }

From source file:com.panet.imeta.trans.TransMeta.java

public void setInternalKettleVariables(VariableSpace var) {
    if (!Const.isEmpty(filename)) // we have a finename that's defined.
    {//  www. ja  v  a2s  .c  o  m
        try {
            FileObject fileObject = KettleVFS.getFileObject(filename);
            FileName fileName = fileObject.getName();

            // The filename of the transformation
            var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, fileName.getBaseName());

            // The directory of the transformation
            FileName fileDir = fileName.getParent();
            var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, fileDir.getURI());
        } catch (IOException e) {
            var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, "");
            var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, "");
        }
    } else {
        var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, "");
        var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, "");
    }

    // The name of the transformation
    //
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_NAME, Const.NVL(name, ""));

    // The name of the directory in the repository
    //
    var.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY,
            directory != null ? directory.getPath() : "");

    // Here we don't remove the job specific parameters, as they may come in
    // handy.
    //
    if (var.getVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY) == null) {
        var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, "Parent Job File Directory"); //$NON-NLS-1$
    }
    if (var.getVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME) == null) {
        var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, "Parent Job Filename"); //$NON-NLS-1$
    }
    if (var.getVariable(Const.INTERNAL_VARIABLE_JOB_NAME) == null) {
        var.setVariable(Const.INTERNAL_VARIABLE_JOB_NAME, "Parent Job Name"); //$NON-NLS-1$
    }
    if (var.getVariable(Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY) == null) {
        var.setVariable(Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY, "Parent Job Repository Directory"); //$NON-NLS-1$        
    }
}