Package mgui.pipelines
Class NativeProcess
java.lang.Object
mgui.pipelines.PipelineProcess
mgui.pipelines.NativeProcess
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,InterfaceObject
,NamedObject
,TreeObject
,CleanableObject
,XMLObject
,IconObject
public class NativeProcess extends PipelineProcess
Represents a native process; i.e., one which runs from the OS command console.
Specified by the command
, which is the native executable; and the
path
, which is a path to the desired version (an empty string results
in the system default).
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
command
protected java.util.HashMap<java.lang.Long,java.lang.Process>
current_system_processes
protected java.lang.String
path
protected java.lang.String
set_operator
Fields inherited from class mgui.pipelines.PipelineProcess
help_param, input_parameter, library, logger, name, output_parameter, parameters
-
Constructor Summary
Constructors Constructor Description NativeProcess(java.lang.String name, java.lang.String command)
NativeProcess(java.lang.String name, java.lang.String command, java.lang.String logger)
NativeProcess(java.lang.String name, java.lang.String command, java.lang.String logger, java.lang.String path)
NativeProcess(java.lang.String name, java.lang.String command, java.lang.String logger, java.lang.String path, java.lang.String set_operator)
NativeProcess(PipelineProcess process)
-
Method Summary
Modifier and Type Method Description java.lang.Object
clone()
java.lang.String
getCommand()
Returns the native command for this process.protected java.lang.String
getCommand(java.lang.String[] args)
java.lang.String
getFailureMessage()
Returns the message to be displayed when this process has failed.java.lang.String[]
getInputArgs(java.lang.String[] args, java.lang.String input_file)
Alters an argument array to set an input file for this process, and returns the result.javax.swing.Icon
getObjectIcon()
Returns theIcon
associated with this object.java.lang.String[]
getOutputArgs(java.lang.String[] args, java.lang.String output_file)
Alters an argument array to set an output file for this process, and returns the result.java.lang.String
getPath()
Returns the path to the native binaries for this process.java.lang.String
getSetOperator()
Returns the set operator character for this process.java.lang.String
getSuccessMessage()
Returns the message to be displayed when this process has succeeded.java.lang.String
getXML(int tab)
Returns this object's XML representation as a single string.boolean
interrupt(long uid)
Interrupts an instance of this processboolean
run(java.lang.String[] args, long uid)
Runs an instance of this processvoid
setCommand(java.lang.String command)
Sets the native command for this process.void
setFromProcess(PipelineProcess process)
void
setPath(java.lang.String path)
Sets the path to the native binaries for this process.void
setSetOperator(java.lang.String set_operator)
Sets the set operator character for this process.void
showHelp()
Attempt to display the associated help messagevoid
writeXML(int tab, java.io.Writer writer, ProgressUpdater progressBar)
Writes the XML representation of this object to file, asXMLType.Normal
.Methods inherited from class mgui.pipelines.PipelineProcess
addParameter, clean, destroy, getCompoundName, getDTD, getHelpParameter, getIcon, getInputParameter, getInstance, getLibrary, getLocalName, getLogger, getName, getOutputParameter, getParameter, getParameters, getShortXML, getTreeLabel, getXML, getXMLSchema, handleXMLElementEnd, handleXMLElementStart, handleXMLString, insertParameter, isDestroyed, issueTreeNode, removeParameter, setHelpParameter, setInputParameter, setLibrary, setLogger, setName, setOutputParameter, setParameters, setTreeNode, toString, updateLogger, writeXML, writeXML
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
command
protected java.lang.String command -
path
protected java.lang.String path -
set_operator
protected java.lang.String set_operator -
current_system_processes
protected java.util.HashMap<java.lang.Long,java.lang.Process> current_system_processes
-
-
Constructor Details
-
NativeProcess
-
NativeProcess
public NativeProcess(java.lang.String name, java.lang.String command) -
NativeProcess
public NativeProcess(java.lang.String name, java.lang.String command, java.lang.String logger) -
NativeProcess
public NativeProcess(java.lang.String name, java.lang.String command, java.lang.String logger, java.lang.String path) -
NativeProcess
public NativeProcess(java.lang.String name, java.lang.String command, java.lang.String logger, java.lang.String path, java.lang.String set_operator)
-
-
Method Details
-
setFromProcess
- Overrides:
setFromProcess
in classPipelineProcess
-
showHelp
public void showHelp()Description copied from class:PipelineProcess
Attempt to display the associated help message- Specified by:
showHelp
in classPipelineProcess
-
getObjectIcon
public javax.swing.Icon getObjectIcon()Description copied from interface:IconObject
Returns theIcon
associated with this object.- Specified by:
getObjectIcon
in interfaceIconObject
- Overrides:
getObjectIcon
in classPipelineProcess
- Returns:
-
getCommand
public java.lang.String getCommand()Returns the native command for this process.- Returns:
-
setSetOperator
public void setSetOperator(java.lang.String set_operator)Sets the set operator character for this process. E.g., for a function expecting -param_name param_value, the character is a space (default). For -param_name=param_value, the character is "=".- Parameters:
command
-
-
getSetOperator
public java.lang.String getSetOperator()Returns the set operator character for this process. E.g., for a function expecting -param_name param_value, the character is a space (default). For -param_name=param_value, the character is "=".- Returns:
-
setCommand
public void setCommand(java.lang.String command)Sets the native command for this process.- Parameters:
command
-
-
getPath
public java.lang.String getPath()Returns the path to the native binaries for this process.- Returns:
-
setPath
public void setPath(java.lang.String path)Sets the path to the native binaries for this process.- Parameters:
command
-
-
getInputArgs
public java.lang.String[] getInputArgs(java.lang.String[] args, java.lang.String input_file)Description copied from class:PipelineProcess
Alters an argument array to set an input file for this process, and returns the result.- Specified by:
getInputArgs
in classPipelineProcess
- Returns:
-
getOutputArgs
public java.lang.String[] getOutputArgs(java.lang.String[] args, java.lang.String output_file)Description copied from class:PipelineProcess
Alters an argument array to set an output file for this process, and returns the result.- Specified by:
getOutputArgs
in classPipelineProcess
- Returns:
-
getCommand
protected java.lang.String getCommand(java.lang.String[] args) -
run
Description copied from class:PipelineProcess
Runs an instance of this process- Specified by:
run
in classPipelineProcess
- Parameters:
args
- Arguments for the process- Returns:
- Throws:
PipelineException
-
interrupt
Description copied from class:PipelineProcess
Interrupts an instance of this process- Specified by:
interrupt
in classPipelineProcess
- Parameters:
uid
- The unique identifier of the process instance to interrupt- Returns:
- Throws:
PipelineException
-
getFailureMessage
public java.lang.String getFailureMessage()Description copied from class:PipelineProcess
Returns the message to be displayed when this process has failed.- Specified by:
getFailureMessage
in classPipelineProcess
- Returns:
-
getSuccessMessage
public java.lang.String getSuccessMessage()Description copied from class:PipelineProcess
Returns the message to be displayed when this process has succeeded.- Specified by:
getSuccessMessage
in classPipelineProcess
- Returns:
-
writeXML
public void writeXML(int tab, java.io.Writer writer, ProgressUpdater progressBar) throws java.io.IOExceptionDescription copied from interface:XMLObject
Writes the XML representation of this object to file, asXMLType.Normal
. The default format ofXMLFormat.Ascii
will be used. The basic contract for this method is that it should not write a newline character at its start or end.- Specified by:
writeXML
in interfaceXMLObject
- Overrides:
writeXML
in classPipelineProcess
- Parameters:
tab
- The number of tabs to place before the XML textwriter
- The writerprogressBar
- Optional progress updater (may benull
)- Throws:
java.io.IOException
-
getXML
public java.lang.String getXML(int tab)Description copied from interface:XMLObject
Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)
functions to write larger objects to file.- Specified by:
getXML
in interfaceXMLObject
- Overrides:
getXML
in classPipelineProcess
- Parameters:
tab
- The number of tabs to place before the opening XML wrapper- Returns:
-
clone
public java.lang.Object clone()- Specified by:
clone
in classPipelineProcess
-