Class AbstractCommand
- java.lang.Object
-
- cbsw.AbstractCommand
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.swing.JButtonbuttonjava.lang.StringdataThe target method parameters.protected java.util.HashMap<java.lang.String,java.lang.String>dataMapA map of key/value pairs passed to the command.java.lang.StringlabelThe label that appears on the button associated with the command.protected javax.swing.JTextFieldstatusTFprotected booleanstopOnFailFlag to control behaviour on a FAIL response.java.lang.StringtargetClassThe static method's class.java.lang.StringtargetMethodThe method to call.
-
Constructor Summary
Constructors Constructor Description AbstractCommand()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclearStatus()Clears the text field.static java.lang.Objectexec(java.lang.Class<?> targetClass, java.lang.String targetMethod, java.lang.String[] targetArgs)Calls a static method by Java reflection.static java.lang.Objectexec(java.lang.Class<?> targetClass, java.lang.String targetMethod, java.util.HashMap<java.lang.String,java.lang.String> targetArgs)Calls a static method by Java reflection.abstract voidgo()Parses, calls and handles reponses for a command.voidsetButton(javax.swing.JButton button)Registers the button that executes the command.voidsetStatusTextField(javax.swing.JTextField statusTF)Registers a text field used to display messages.static java.lang.Stringshell(java.lang.String[] args)Invokes an OS shell script.static java.lang.Stringshell2(java.lang.String[] args)Invokes an OS shell script.
-
-
-
Field Detail
-
label
public java.lang.String label
The label that appears on the button associated with the command.
-
targetMethod
public java.lang.String targetMethod
The method to call.
-
targetClass
public java.lang.String targetClass
The static method's class.
-
stopOnFail
protected boolean stopOnFail
Flag to control behaviour on a FAIL response.
-
data
public java.lang.String data
The target method parameters.
-
dataMap
protected java.util.HashMap<java.lang.String,java.lang.String> dataMap
A map of key/value pairs passed to the command.
-
statusTF
protected javax.swing.JTextField statusTF
-
button
protected javax.swing.JButton button
-
-
Method Detail
-
go
public abstract void go() throws java.lang.ExceptionParses, calls and handles reponses for a command.
- Throws:
java.lang.Exception- The exception
-
exec
public static java.lang.Object exec(java.lang.Class<?> targetClass, java.lang.String targetMethod, java.lang.String[] targetArgs)Calls a static method by Java reflection.
- Parameters:
targetClass- The class of the method.targetMethod- The method.targetArgs- Command line parameters.- Returns:
- The command response
-
exec
public static java.lang.Object exec(java.lang.Class<?> targetClass, java.lang.String targetMethod, java.util.HashMap<java.lang.String,java.lang.String> targetArgs)Calls a static method by Java reflection.
- Parameters:
targetClass- The class of the method.targetMethod- The method.targetArgs- Map of parameters.- Returns:
- The command response
-
shell
public static java.lang.String shell(java.lang.String[] args)
Invokes an OS shell script.
Creates a process whose stdout is connected to an input channel.
Process completion is signalled by the process sending a completion response message. This method blocks until it receives the completion response message therefore the process should not write anything other than its completion response to its stdout or this method will return prematurely.
- Parameters:
args- {0=script-path,1...=command-parameters}- Returns:
- The command response.
-
shell2
public static java.lang.String shell2(java.lang.String[] args)
Invokes an OS shell script.
Creates a process whose stdout is connected to an input channel.
Process completion is signalled by the process sending a completion response message. This method blocks until it receives the completion response message therefore the process should not write anything other than its completion response to its stdout or this method will return prematurely.
- Parameters:
args- {0=script-path,1...=command-parameters}- Returns:
- The command response.
-
setStatusTextField
public void setStatusTextField(javax.swing.JTextField statusTF)
Registers a text field used to display messages.
- Parameters:
statusTF- The text field.
-
setButton
public void setButton(javax.swing.JButton button)
Registers the button that executes the command.
- Parameters:
button- The button.
-
clearStatus
public void clearStatus()
Clears the text field.
-
-