public abstract class ProcessStep extends Object
Processor
.Modifier and Type | Field and Description |
---|---|
String |
stepName
The name of this processing step.
|
Modifier | Constructor and Description |
---|---|
protected |
ProcessStep(String stepName)
Constructs a processing step having specified name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
debugParameters(Map<String,String> parameters,
ProgressMonitor monitor)
Implementation helper: passes a debug message containing all the
parameters which are specific to this step to specified progress
monitor.
|
boolean |
equals(Object other) |
protected String[] |
getAllParameters(Map<String,String> parameters)
Implementation helper: returns all the parameters which are relevant
to this processing step.
|
protected boolean |
getBooleanParameter(Map<String,String> parameters,
String name,
boolean fallback)
Implementation helper: returns the boolean value of parameter
having specified name.
|
protected File |
getFileParameter(Map<String,String> parameters,
String name,
File fallback)
Implementation helper: returns the File value of parameter
having specified name.
|
protected int |
getIntParameter(Map<String,String> parameters,
String name,
int min,
int max,
int fallback)
Implementation helper: returns the boolean value of parameter
having specified name.
|
protected String |
getParameter(Map<String,String> parameters,
String name,
String fallback)
Implementation helper: returns the value of parameter
having specified name.
|
protected URL |
getURLParameter(Map<String,String> parameters,
String name,
URL fallback)
Implementation helper: returns the URL value of parameter
having specified name.
|
int |
hashCode() |
protected void |
illegalState(Class<?> expectedClass)
Implementation helper: raises a
IllegalArgumentException
when the state array does not contain an instance of specified
class. |
protected String |
joinAllParameters(Map<String,String> parameters,
String before,
String separ,
String after) |
protected void |
missingParameter(String name)
Implementation helper: raises a
IllegalArgumentException
when the parameters map does not contain parameter
having specified (unprefixed) name. |
protected String |
parameterName(String name)
Implementation helper: returns specified parameter name
after prefixing it with "
stepName . |
abstract void |
process(Object[] state,
Map<String,String> parameters,
int[] stepCounter,
ProgressMonitor monitor)
Execute this processing step.
|
protected void |
progress(String message,
int[] stepCounter,
ProgressMonitor monitor)
Implementation helper: increments the step counter and passes
current step count and specified message to specified progress monitor.
|
String |
toString() |
static URL |
urlOrFile(String path,
URL baseURL)
Implementation helper: returns an URL created from specified path.
|
protected ProcessStep(String stepName)
public abstract void process(Object[] state, Map<String,String> parameters, int[] stepCounter, ProgressMonitor monitor) throws Exception
state
- contains the current state of processing:
a Document
or a File
.
This object is used as the input of this step and thus, is processed by this step.
After its execution, this method generally updates
the state array with a new Document
or File
to pass the result/output of this step to the next step.
parameters
- all the parameters passed to the Processor
owning and thus executing this process step.
Parameters which are relevant to this processing step are prefixed
with "stepName
.".
stepCounter
- contains the rank of previously executed
processing step. Must be incremented by this method.monitor
- used to monitor the progress of the processing steps
Invoking convenience method progress(java.lang.String, int[], com.xmlmind.util.ProgressMonitor)
suffices to
make good use of both monitor and stepCounter.
Exception
- if for any reason, this method failsprotected final void progress(String message, int[] stepCounter, ProgressMonitor monitor) throws CanceledException
protected final void debugParameters(Map<String,String> parameters, ProgressMonitor monitor) throws CanceledException
protected final String joinAllParameters(Map<String,String> parameters, String before, String separ, String after)
protected final void illegalState(Class<?> expectedClass) throws IllegalArgumentException
IllegalArgumentException
when the state array does not contain an instance of specified
class.protected final void missingParameter(String name) throws IllegalArgumentException
IllegalArgumentException
when the parameters map does not contain parameter
having specified (unprefixed) name.protected final String parameterName(String name)
stepName
.".protected final String[] getAllParameters(Map<String,String> parameters)
parameters
- all the parameters passed to the Processor
owning and thus executing this process step.
Parameters which are relevant to this processing step are prefixed
with "stepName
.".
process(java.lang.Object[], java.util.Map<java.lang.String, java.lang.String>, int[], com.xmlmind.util.ProgressMonitor)
protected final String getParameter(Map<String,String> parameters, String name, String fallback)
parameters
- all the parameters passed to the Processor
owning and thus executing this process step.name
- unprefixed parameter namefallback
- value to be returned if parameter is not foundprotected final boolean getBooleanParameter(Map<String,String> parameters, String name, boolean fallback)
parameters
- all the parameters passed to the Processor
owning and thus executing this process step.name
- unprefixed parameter namefallback
- value to be returned if parameter is not found
or cannot be converted to a booleangetParameter(java.util.Map<java.lang.String, java.lang.String>, java.lang.String, java.lang.String)
protected final int getIntParameter(Map<String,String> parameters, String name, int min, int max, int fallback)
parameters
- all the parameters passed to the Processor
owning and thus executing this process step.name
- unprefixed parameter namemin
- minimum possible value for the parametermax
- maximum possible value for the parameterfallback
- value to be returned if parameter is not found
or cannot be converted to a int
which value is
between min and max inclusivegetParameter(java.util.Map<java.lang.String, java.lang.String>, java.lang.String, java.lang.String)
protected final File getFileParameter(Map<String,String> parameters, String name, File fallback)
parameters
- all the parameters passed to the Processor
owning and thus executing this process step.name
- unprefixed parameter namefallback
- value to be returned if parameter is not foundgetParameter(java.util.Map<java.lang.String, java.lang.String>, java.lang.String, java.lang.String)
protected final URL getURLParameter(Map<String,String> parameters, String name, URL fallback)
parameters
- all the parameters passed to the Processor
owning and thus executing this process step.name
- unprefixed parameter namefallback
- value to be returned if parameter is not found
or cannot be converted to an URL using urlOrFile(java.lang.String, java.net.URL)
getParameter(java.util.Map<java.lang.String, java.lang.String>, java.lang.String, java.lang.String)
public static final URL urlOrFile(String path, URL baseURL)
First, this function attempts to convert specified path to an URL.
If this fails, specified path is considered to be the name
of an existing file or directory. This filename is
converted to an URL using FileUtil.fileToURL(java.io.File)
.
path
- external form of an URL or the filename of an existing file
or directory.baseURL
- which base URL to use to resolve path
when it is a relative URL. May be null
.null
if specified path cannot be
converted to an URL