FileDocCategorySizeDatePackage
FileLister.javaAPI DocGlassfish v2 API4147Fri May 04 22:23:16 BST 2007com.sun.enterprise.config.backup.util

FileLister

public abstract class FileLister extends Object
author
bnevins
version

Fields Summary
private ArrayList
fileList
private File
mainRoot
private boolean
keepEmpty
Constructors Summary
FileLister(File root)

        mainRoot = root;
        fileList = new ArrayList();
    
Methods Summary
public java.lang.String[]getFiles()

        getFilesInternal(mainRoot);
        String[] files = new String[fileList.size()];
        
        if(files.length <= 0)
            return files;
        
        int len = 0;
        
        if(relativePath())
            len = mainRoot.getPath().length() + 1;
        
        for(int i = 0; i < files.length; i++)
        {
            files[i] = ((File)fileList.get(i)).getPath().substring(len).replace('\\", '/");
        }
        
        Arrays.sort(files, String.CASE_INSENSITIVE_ORDER);
        return files;
    
private voidgetFilesInternal(java.io.File root)

        File[] files = root.listFiles();
        
        for(int i = 0; i < files.length; i++)
        {
            if(files[i].isDirectory())
            {
                getFilesInternal(files[i]);
            }
            else
                fileList.add(files[i]);	// actual file
        }
        
        // add empty directory, if the option is turned on
        if(files.length <= 0 && keepEmpty)
            fileList.add(root);
    
public voidkeepEmptyDirectories()
Normally, we don't want a list of empty (leaf) directories. In case this is desired -- call this method. The default is to NOT keep empty directories in the list

        keepEmpty = true;
    
protected abstract booleanrelativePath()