|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.meshcms.util.DirectoryParser
Base class to perform operations on the contents of a directory.
Override the method preProcessDirectory
,
postProcessDirectory
and
processFile
to define the actions to be taken for files and
directories included in the processed directory. You can also override
preProcess
and postProcess
to do additional
operations before and after the directory parsing.
The directory to be parsed must be specified before starting by calling
on of the setInitialDir
methods. Then you can start the parsing
by calling process
or asinchronously by creating a new thread
and starting it.
Please note that this class is not recursive by default. You must
call setRecursive(true)
before processing if you want it to
process directory contents too.
Field Summary | |
protected java.io.File |
initialDir
|
protected boolean |
processStartDir
|
protected boolean |
recursive
|
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
DirectoryParser()
|
Method Summary | |
java.io.File |
getInitialDir()
Returns the directory to be processed. |
boolean |
isProcessStartDir()
Returns whether processDirectory will be called for the
base directory too. |
boolean |
isRecursive()
Returns whether directories will be processed recursively or not. |
boolean |
isSorted()
Returns whether files and directories will be sorted used a FileNameComparator or not. |
protected void |
postProcess()
This method is called at the end of the processing. |
protected void |
postProcessDirectory(java.io.File file,
Path path)
|
protected boolean |
preProcess()
This method is called during the process, but before any element has been processed. |
protected boolean |
preProcessDirectory(java.io.File file,
Path path)
|
void |
process()
Starts processing. |
protected void |
processFile(java.io.File file,
Path path)
This method will be called for any file found while parsing the base directory. |
void |
run()
Starts processing (in a separate thread if instantiated properly). |
void |
setInitialDir(java.io.File dir)
Sets the directory to be processed. |
void |
setInitialDir(java.lang.String dir)
Sets the directory to be processed. |
void |
setProcessStartDir(boolean processStartDir)
If true, processDirectory will be called for the
base directory too (default false). |
void |
setRecursive(boolean recursive)
If true, directories will be processed recursively (default false). |
void |
setSorted(boolean sorted)
If true, files and directories will be sorted used a FileNameComparator . |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.io.File initialDir
protected boolean recursive
protected boolean processStartDir
Constructor Detail |
public DirectoryParser()
Method Detail |
public void setRecursive(boolean recursive)
recursive
- it the directories will be processed recursivelypublic void setProcessStartDir(boolean processStartDir)
processDirectory
will be called for the
base directory too (default false).
processStartDir
- if to process the base directory too.#processDirectory
public boolean isRecursive()
setRecursive(boolean)
public boolean isProcessStartDir()
processDirectory
will be called for the
base directory too.
#processDirectory
,
setProcessStartDir(boolean)
public void setSorted(boolean sorted)
FileNameComparator
.
FileNameComparator
public boolean isSorted()
FileNameComparator
or not.
FileNameComparator
,
setSorted(boolean)
public void setInitialDir(java.lang.String dir)
File
is
created and setInitialDir(File)
is called.
dir
- the file path as a String
public void setInitialDir(java.io.File dir)
dir
- the directory path as a File
public java.io.File getInitialDir()
public void run()
public void process()
protected boolean preProcess()
The base implementation does nothing and returns true.
protected void postProcess()
preProcess()
returned false.
The base implementation does nothing.
protected boolean preProcessDirectory(java.io.File file, Path path)
protected void postProcessDirectory(java.io.File file, Path path)
protected void processFile(java.io.File file, Path path)
file
- the file to be processedpath
- the path of the file (relative to the base directory)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |