Package net.sourceforge.jiu.ops
Class BatchProcessorOperation
- java.lang.Object
-
- net.sourceforge.jiu.ops.Operation
-
- net.sourceforge.jiu.ops.BatchProcessorOperation
-
- Direct Known Subclasses:
ColorIndexer
public abstract class BatchProcessorOperation extends Operation
Abstract base class to do batch processing on files and complete directory trees. For a non-abstract extension of this operation, you must implementprocessFile(java.lang.String, java.lang.String, java.lang.String)
.- Since:
- 0.11.0
- Author:
- Marco Schmidt
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
collectErrors
private Vector
directoryTrees
private Vector
errorMessages
private Vector
inputFileNames
private String
outputDirectory
private boolean
overwrite
-
Constructor Summary
Constructors Constructor Description BatchProcessorOperation()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addDirectoryTree(String rootDirectoryName)
Adds the argument to the list of directories to be completely processed.void
addDirectoryTree(String rootDirectoryName, String outputRootDirectoryName)
Adds the first argument to the list of directories to be completely processed, writes all output files to the directory tree specified by the second argument.void
addInputFileName(String fileName)
Adds a single name to the list of file names to be processed.void
addInputFileNames(Vector fileNameList)
Adds a number of file names to the internal list of file names to be processed.Vector
getErrorMessages()
Returns a list of error messages collected during the execution ofprocess()
.boolean
getOverwrite()
Returns the current overwrite setting.void
process()
Processes all directory trees and files given to this operation, callingprocessFile(java.lang.String, java.lang.String, java.lang.String)
on each file name.private void
processDirectoryTree(String fromDir, String toDir)
abstract void
processFile(String inputDirectory, String inputFileName, String outputDirectory)
Method to be called on each file given to this operation.void
setCollectErrorMessages(boolean collectErrorMessages)
Specifies whether error messages are supposed to be collected during the execution ofprocess()
.void
setOutputDirectory(String outputDirectoryName)
Specifies the output directory for all single files.void
setOverwrite(boolean newValue)
Specify whether existing files are to be overwritten.-
Methods inherited from class net.sourceforge.jiu.ops.Operation
addProgressListener, addProgressListeners, getAbort, removeProgressListener, setAbort, setProgress, setProgress
-
-
-
-
Method Detail
-
addDirectoryTree
public void addDirectoryTree(String rootDirectoryName)
Adds the argument to the list of directories to be completely processed.- Parameters:
rootDirectoryName
- name of the root of the directory tree, can be any valid directory name
-
addDirectoryTree
public void addDirectoryTree(String rootDirectoryName, String outputRootDirectoryName)
Adds the first argument to the list of directories to be completely processed, writes all output files to the directory tree specified by the second argument.- Parameters:
rootDirectoryName
- name of the root of the directory tree, can be any valid directory nameoutputRootDirectoryName
- name of the root of the directory tree, can be any valid directory name
-
addInputFileName
public void addInputFileName(String fileName)
Adds a single name to the list of file names to be processed.- Parameters:
fileName
- name to be added to list
-
addInputFileNames
public void addInputFileNames(Vector fileNameList)
Adds a number of file names to the internal list of file names to be processed.- Parameters:
fileNameList
- list of file names, each object in the list must be a String
-
getErrorMessages
public Vector getErrorMessages()
Returns a list of error messages collected during the execution ofprocess()
.- Returns:
- list of error messages, each object is a String
-
getOverwrite
public boolean getOverwrite()
Returns the current overwrite setting.- Returns:
- whether existing files are to be overwritten
-
process
public void process()
Processes all directory trees and files given to this operation, callingprocessFile(java.lang.String, java.lang.String, java.lang.String)
on each file name.
-
processFile
public abstract void processFile(String inputDirectory, String inputFileName, String outputDirectory)
Method to be called on each file given to this operation. Non-abstract heirs of this class must implement this method to add functionality.- Parameters:
inputDirectory
- name of directory where the file to be processed residesinputFileName
- name of file to be processedoutputDirectory
- output directory for that file, need not necessarily be used
-
setCollectErrorMessages
public void setCollectErrorMessages(boolean collectErrorMessages)
Specifies whether error messages are supposed to be collected during the execution ofprocess()
.- Parameters:
collectErrorMessages
- if true, error messages will be collected, otherwise not- See Also:
getErrorMessages()
-
setOutputDirectory
public void setOutputDirectory(String outputDirectoryName)
Specifies the output directory for all single files. Note that you can specify different output directories when dealing with directory trees.- Parameters:
outputDirectoryName
- name of output directory
-
setOverwrite
public void setOverwrite(boolean newValue)
Specify whether existing files are to be overwritten.- Parameters:
newValue
- if true, files are overwritten, otherwise not- See Also:
getOverwrite()
-
-