|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--xbn.XBNObject | +--xbn.util.DirFile
[Deprecated for DirScan] Represents a directory, and all files/directories/sub-directories/... therein. Every sub-directory in this one is another DirFile object.
Source code: DirFile.java
This class is meant to be useful, not fast.
import xbn.util.DirFile;
public class XmplDirFile {
public static void main(String[] as_cmdLineParams) {
DirFile df = new DirFile("."); //The directory you're executing this from
System.out.println(df.toString());
listFiles(df, " ");
}
public static void listFiles(DirFile df, String s_dbgPrefix) {
for(int i = 0; i < df.getCountSubFiles(); i++) {
System.out.println(s_dbgPrefix + df.getSubFile(i).getFileObjectThis().getName());
}
for(int i = 0; i < df.getCountSubDirs(); i++) {
System.out.println(s_dbgPrefix + "[" + df.getSubDir(i).getFileObjectThis().getName() + "]");
listFiles(df.getSubDir(i), (s_dbgPrefix + " "));
}
}
}
Fields inherited from class xbn.XBNObject |
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP |
Constructor Summary | |
DirFile(String s_basePath)
Create a DirFile. |
|
DirFile(String s_basePath,
FileFilter file_filter)
Create a DirFile. |
|
DirFile(String s_basePath,
FileFilter file_filter,
Outputter o_utputter)
Create a DirFile. |
|
DirFile(String s_basePath,
int i_levelsToAnalyze)
Create a DirFile. |
|
DirFile(String s_basePath,
int i_levelsToAnalyze,
FileFilter file_filter)
Create a DirFile. |
|
DirFile(String s_basePath,
int i_levelsToAnalyze,
FileFilter file_filter,
Outputter o_utputter)
Create a DirFile. |
|
DirFile(String s_basePath,
int i_levelsToAnalyze,
Outputter o_utputter)
Create a DirFile. |
|
DirFile(String s_basePath,
Outputter o_utputter)
Create a DirFile. |
Method Summary | |
int |
getCountSubDirs()
How many sub-directories exist in this directory? |
int |
getCountSubFiles()
How many sub-files exist in this directory? |
File |
getFileObjBaseDir()
Get the java.io.File representing the base directory. |
File |
getFileObjectBaseDir()
Deprecated. Use getFileObjBaseDir. |
File |
getFileObjectThis()
Deprecated. Use getFileObjThis. |
File |
getFileObjThis()
Get the java.io.File representing this file/directory. |
int |
getLevelsBelowBaseDir()
How many levels below the base directory is this file/dir? |
int |
getLevelsToAnalyze()
How many levels of sub-directories (and their contents) should be analyzed? |
String |
getRelativeDirectory()
Deprecated. Use getRelDir. |
String |
getRelDir()
Get the relative path of this DirFile. |
DirFile |
getSubDir(int i_dx)
Get the sub directory at the requested array index. |
DirFile |
getSubFile(int i_dx)
Get the sub file at the requested array index. |
boolean |
haveContentsBeenAnalyzed()
Does this DirFile represent a directory, and have its contents been analyzed? |
boolean |
isDirectory()
Does this DirFile object represent a directory? |
boolean |
isFile()
Does this DirFile object represent a file? |
String |
toString()
Get some information about this DirFile. |
Methods inherited from class xbn.XBNObject |
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public DirFile(String s_basePath)
public DirFile(String s_basePath, Outputter o_utputter)
Create a DirFile.
Equal to DirFile(s_basePath, -1, o_utputter)
public DirFile(String s_basePath, int i_levelsToAnalyze)
public DirFile(String s_basePath, int i_levelsToAnalyze, Outputter o_utputter)
Create a DirFile.
Equal to DirFile(s_basePath, i_levelsToAnalyze, null, o_utputter)
public DirFile(String s_basePath, FileFilter file_filter)
Create a DirFile.
Equal to DirFile(s_basePath, -1, file_filter)
Note: To pass in file_filter as null, use
(new DirFile("Base path", (FileFilter)file_filter))
public DirFile(String s_basePath, int i_levelsToAnalyze, FileFilter file_filter)
public DirFile(String s_basePath, FileFilter file_filter, Outputter o_utputter)
Create a DirFile.
Equal to DirFile(s_basePath, -1, null)
public DirFile(String s_basePath, int i_levelsToAnalyze, FileFilter file_filter, Outputter o_utputter)
Create a DirFile.
s_basePath
- The full path (including the final File.separator) of the base directory. May not be null, and must represent a directory that exists.i_levelsToAnalyze
- The number of levels to analyze. must be greater than -2. See getLevelsToAnalyze.file_filter
- The java.io.FileFilter object to define the specific files and directories that should be retrieved. If all files are desired, set this to null.Method Detail |
public File getFileObjectThis()
Get the java.io.File representing this file/directory.
getFileObjThis()
public File getFileObjectBaseDir()
Get the java.io.File representing the base directory.
getFileObjBaseDir()
public String getRelativeDirectory()
Get the relative path of this DirFile.
getRelDir()
public File getFileObjBaseDir()
Get the java.io.File representing the base directory.
If getFileObjThis equals getFileObjBaseDir, then this DirFile is the base directory.
public File getFileObjThis()
Get the java.io.File representing this file/directory.
If getFileObjBaseDir equals getFileObjThis, then this DirFile is the base directory.
public String getRelDir()
Get the relative path of this DirFile.
dir\sub_dir\another_sub_dir
For example, if...
Then this function would return "sub_dir\another_sub_dir"
public int getCountSubDirs()
How many sub-directories exist in this directory?
public int getCountSubFiles()
How many sub-files exist in this directory?
public DirFile getSubFile(int i_dx)
Get the sub file at the requested array index.
i_dx
- The array index of the sub file you wish to retrieve. Must range zero..[getCountSubFiles - 1], inclusive.AssertException
- public DirFile getSubDir(int i_dx)
Get the sub directory at the requested array index.
i_dx
- The array index of the sub directory you wish to retrieve. Must range zero..[getCountSubDirs - 1], inclusive.AssertException
- public boolean isDirectory()
Does this DirFile object represent a directory?
public boolean isFile()
Does this DirFile object represent a file?
public boolean haveContentsBeenAnalyzed()
Does this DirFile represent a directory, and have its contents been analyzed?
Depending on the value of getLevelsToAnalyze, this directory (if it is a directory) may not be analyzed or recognized by this DirFile. In other words, this directory may be at the bottom level, in which case its contents are ignored. This is not a statement to whether the directory contains zero or [not-zero] objects in it.
public int getLevelsBelowBaseDir()
How many levels below the base directory is this file/dir?
public int getLevelsToAnalyze()
How many levels of sub-directories (and their contents) should be analyzed?
public String toString()
Get some information about this DirFile.
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.
http://sourceforge.net/projects/xbnjava