public abstract class Script extends Object implements OptionHandler, Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
Script.ScriptThread
The Thread for running a script.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
BACKUP_EXTENSION
the backup extension.
|
| Constructor and Description |
|---|
Script()
Initializes the script.
|
Script(Document doc)
Initializes the script.
|
Script(Document doc,
File file)
Initializes the script.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addScriptFinishedListener(ScriptExecutionListener l)
Adds the given listener to its internal list.
|
void |
empty()
Empties the document.
|
String |
getContent()
Returns the content.
|
abstract String |
getDefaultExtension()
Returns the default extension.
|
File |
getFilename()
Returns the current filename.
|
abstract ExtensionFileFilter[] |
getFilters()
Returns the extension filters for this type of script.
|
String |
getNewLine()
Returns the new line string in use.
|
String[] |
getOptions()
Gets the current settings of the script.
|
boolean |
isModified()
Returns whether the script is modified.
|
boolean |
isRunning()
Returns whether the script is still running.
|
Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
abstract Script.ScriptThread |
newThread(String[] args)
Returns a new thread to execute.
|
boolean |
open(File file)
Tries to open the file.
|
void |
removeScriptFinishedListener(ScriptExecutionListener l)
Removes the given listener from its internal list.
|
void |
run(File file,
String[] args)
Executes the script without loading it first.
|
static void |
runScript(Script script,
String[] args)
Runs the specified script.
|
boolean |
save()
Saves the file under with the current filename.
|
boolean |
saveAs(File file)
Saves the file under with the given filename (and updates the internal
filename).
|
void |
setContent(String value)
Sets the content.
|
void |
setOptions(String[] options)
Parses a given list of options.
|
void |
start(String[] args)
Executes the script.
|
void |
stop()
Stops the execution of the script.
|
String |
toString()
Returns the content as string.
|
public static final String BACKUP_EXTENSION
public Script()
public Script(Document doc)
doc - the document to use as basispublic Enumeration listOptions()
listOptions in interface OptionHandlerpublic void setOptions(String[] options) throws Exception
setOptions in interface OptionHandleroptions - the list of options as an array of stringsException - if an option is not supportedpublic String[] getOptions()
getOptions in interface OptionHandlerpublic abstract ExtensionFileFilter[] getFilters()
public abstract String getDefaultExtension()
saveAs(File)public File getFilename()
public String getNewLine()
public boolean isModified()
public String getContent()
public void setContent(String value)
value - the new contentpublic void empty()
public boolean open(File file)
file - the file to openpublic boolean save()
public boolean saveAs(File file)
file - the filename to write the content topublic abstract Script.ScriptThread newThread(String[] args)
args - optional commandline argumentspublic void start(String[] args) throws Exception
args - optional commandline arguments, can be nullException - if checks or execution failpublic void stop()
public void run(File file, String[] args)
file - the script to executeargs - the commandline parameters for the scriptpublic boolean isRunning()
public void addScriptFinishedListener(ScriptExecutionListener l)
l - the listener to addpublic void removeScriptFinishedListener(ScriptExecutionListener l)
l - the listener to removepublic String toString()
public static void runScript(Script script, String[] args) throws Exception
script - the script object to useargs - the commandline argumentsException - if execution failsCopyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.