本文整理汇总了Java中org.apache.commons.vfs.FileName.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java FileName.getParent方法的具体用法?Java FileName.getParent怎么用?Java FileName.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.vfs.FileName
的用法示例。
在下文中一共展示了FileName.getParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setInternalFilenameKettleVariables
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
private void setInternalFilenameKettleVariables(VariableSpace var) {
if (filename != null) // we have a filename that's defined.
{
try {
FileObject fileObject = KettleVFS.getFileObject(filename, var);
FileName fileName = fileObject.getName();
// The filename of the job
var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, fileName.getBaseName());
// The directory of the job
FileName fileDir = fileName.getParent();
var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, fileDir.getURI());
} catch (Exception 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$
}
}
示例2: setInternalFilenameKettleVariables
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
/**
* Sets the internal filename kettle variables.
*
* @param var the new internal filename kettle variables
*/
private void setInternalFilenameKettleVariables(VariableSpace var) {
if (filename != null) // we have a filename that's defined.
{
try {
FileObject fileObject = KettleVFS.getFileObject(filename, var);
FileName fileName = fileObject.getName();
// The filename of the job
var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_NAME, fileName.getBaseName());
// The directory of the job
FileName fileDir = fileName.getParent();
var.setVariable(Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, fileDir.getURI());
} catch (Exception 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$
}
}
示例3: setInternalKettleVariables
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
/**
* This method sets various internal kettle variables that can be used by
* the transformation.
*/
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);
}
示例4: setInternalKettleVariables
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
public void setInternalKettleVariables(VariableSpace var)
{
if (transMeta != null && !Const.isEmpty(transMeta.getFilename())) // we have a finename that's defined.
{
try
{
FileObject fileObject = KettleVFS.getFileObject(transMeta.getFilename());
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(transMeta.getName(), ""));
// TODO PUT THIS INSIDE OF THE "IF"
// The name of the directory in the repository
variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY, transMeta.getDirectory()!=null?transMeta.getDirectory().getPath():"");
// Here we don't clear the definition of the job specific parameters, as they may come in handy.
// A transformation can be called from a job and may inherit the job internal variables
// but the other around is not possible.
}
示例5: setInternalKettleVariables
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
public void setInternalKettleVariables(VariableSpace var)
{
if (transMeta != null && !Const.isEmpty(transMeta.getFilename())) // we have a finename that's defined.
{
try
{
FileObject fileObject = KettleVFS.getFileObject(transMeta.getFilename(), var);
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(KettleFileException 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(transMeta.getName(), ""));
// TODO PUT THIS INSIDE OF THE "IF"
// The name of the directory in the repository
variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY, transMeta.getRepositoryDirectory()!=null?transMeta.getRepositoryDirectory().getPath():"");
// Here we don't clear the definition of the job specific parameters, as they may come in handy.
// A transformation can be called from a job and may inherit the job internal variables
// but the other around is not possible.
}
示例6: setInternalFilenameKettleVariables
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
private void setInternalFilenameKettleVariables(VariableSpace var) {
// If we have a filename that's defined, set variables. If not, clear them.
//
if (!Const.isEmpty(filename))
{
try {
FileObject fileObject = KettleVFS.getFileObject(filename, var);
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 (KettleFileException e) {
log.logError("Unexpected error setting internal filename variables!", 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, "");
}
}
示例7: setInternalFilenameKettleVariables
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
/**
* Sets the internal filename kettle variables.
*
* @param var the new internal filename kettle variables
*/
private void setInternalFilenameKettleVariables(VariableSpace var) {
// If we have a filename that's defined, set variables. If not, clear them.
//
if (!Const.isEmpty(filename))
{
try {
FileObject fileObject = KettleVFS.getFileObject(filename, var);
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 (KettleFileException e) {
log.logError("Unexpected error setting internal filename variables!", 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, "");
}
}
示例8: getRoot
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
/**
* find the root of the filesystem.
* @return The root FileName.
*/
public FileName getRoot()
{
FileName root = this;
while (root.getParent() != null)
{
root = root.getParent();
}
return root;
}
示例9: setInternalKettleVariables
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
public void setInternalKettleVariables(VariableSpace var)
{
if (jobMeta != null && jobMeta.getFilename() !=null) // we have a finename 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);
}
示例10: setInternalKettleVariables
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
public void setInternalKettleVariables(VariableSpace var)
{
if (!Const.isEmpty(filename)) // we have a finename that's defined.
{
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$
}
}
示例11: setInternalKettleVariables
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
public void setInternalKettleVariables(VariableSpace var)
{
if (jobMeta != null && jobMeta.getFilename() !=null) // we have a finename that's defined.
{
try
{
FileObject fileObject = KettleVFS.getFileObject(jobMeta.getFilename(), this);
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(Exception 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.getRepositoryDirectory() != null ? jobMeta.getRepositoryDirectory().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);
}
示例12: setInternalKettleVariables
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
/**
* Sets the internal kettle variables.
*
* @param var the new internal kettle variables.
*/
public void setInternalKettleVariables(VariableSpace var)
{
if (jobMeta != null && jobMeta.getFilename() !=null) // we have a finename that's defined.
{
try
{
FileObject fileObject = KettleVFS.getFileObject(jobMeta.getFilename(), this);
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(Exception 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.getRepositoryDirectory() != null ? jobMeta.getRepositoryDirectory().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);
}
示例13: setInternalKettleVariables
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
/**
* Sets the internal kettle variables.
*
* @param var the new internal kettle variables
*/
public void setInternalKettleVariables(VariableSpace var)
{
if (transMeta != null && !Const.isEmpty(transMeta.getFilename())) // we have a finename that's defined.
{
try
{
FileObject fileObject = KettleVFS.getFileObject(transMeta.getFilename(), var);
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(KettleFileException 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(transMeta.getName(), ""));
// TODO PUT THIS INSIDE OF THE "IF"
// The name of the directory in the repository
variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY, transMeta.getRepositoryDirectory()!=null?transMeta.getRepositoryDirectory().getPath():"");
// Here we don't clear the definition of the job specific parameters, as they may come in handy.
// A transformation can be called from a job and may inherit the job internal variables
// but the other around is not possible.
}
示例14: init
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
public void init() throws FileSystemException {
super.init();
try {
// Build the index
List strongRef = new ArrayList( 100 );
Enumeration entries = getZipFile().entries();
while ( entries.hasMoreElements() ) {
ZipEntry entry = (ZipEntry) entries.nextElement();
FileName name = getFileSystemManager().resolveName( getRootName(), UriParser.encode( entry.getName() ) );
// Create the file
ZipFileObject fileObj;
if ( entry.isDirectory() && getFileFromCache( name ) != null ) {
fileObj = (ZipFileObject) getFileFromCache( name );
fileObj.setZipEntry( entry );
continue;
}
fileObj = createZipFileObject( name, entry );
putFileToCache( fileObj );
strongRef.add( fileObj );
fileObj.holdObject( strongRef );
// Make sure all ancestors exist
// TODO - create these on demand
ZipFileObject parent;
for ( FileName parentName = name.getParent();
parentName != null;
fileObj = parent, parentName = parentName.getParent() ) {
// Locate the parent
parent = (ZipFileObject) getFileFromCache( parentName );
if ( parent == null ) {
parent = createZipFileObject( parentName, null );
putFileToCache( parent );
strongRef.add( parent );
parent.holdObject( strongRef );
}
// Attach child to parent
parent.attachChild( fileObj.getName() );
}
}
} finally {
closeCommunicationLink();
}
}
示例15: init
import org.apache.commons.vfs.FileName; //导入方法依赖的package包/类
public void init() throws FileSystemException {
super.init();
// Build the index
try {
List strongRef = new ArrayList( 100 );
TarEntry entry;
while ( ( entry = getTarFile().getNextEntry() ) != null ) {
FileName name = getFileSystemManager().resolveName( getRootName(), UriParser.encode( entry.getName() ) );
// Create the file
TarFileObject fileObj;
if ( entry.isDirectory() && getFileFromCache( name ) != null ) {
fileObj = (TarFileObject) getFileFromCache( name );
fileObj.setTarEntry( entry );
continue;
}
fileObj = createTarFileObject( name, entry );
putFileToCache( fileObj );
strongRef.add( fileObj );
fileObj.holdObject( strongRef );
// Make sure all ancestors exist
// TODO - create these on demand
TarFileObject parent = null;
for ( FileName parentName = name.getParent();
parentName != null;
fileObj = parent, parentName = parentName.getParent() ) {
// Locate the parent
parent = (TarFileObject) getFileFromCache( parentName );
if ( parent == null ) {
parent = createTarFileObject( parentName, null );
putFileToCache( parent );
strongRef.add( parent );
parent.holdObject( strongRef );
}
// Attach child to parent
parent.attachChild( fileObj.getName() );
}
}
} catch ( IOException e ) {
throw new FileSystemException( e );
} finally {
closeCommunicationLink();
}
}