public abstract class Script extends java.lang.Object implements OptionHandler, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Script.ScriptThread
The Thread for running a script.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BACKUP_EXTENSION
the backup extension.
|
Constructor and Description |
---|
Script()
Initializes the script.
|
Script(javax.swing.text.Document doc)
Initializes the script.
|
Script(javax.swing.text.Document doc,
java.io.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.
|
java.lang.String |
getContent()
Returns the content.
|
abstract java.lang.String |
getDefaultExtension()
Returns the default extension.
|
java.io.File |
getFilename()
Returns the current filename.
|
abstract ExtensionFileFilter[] |
getFilters()
Returns the extension filters for this type of script.
|
java.lang.String |
getNewLine()
Returns the new line string in use.
|
java.lang.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.
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
abstract Script.ScriptThread |
newThread(java.lang.String[] args)
Returns a new thread to execute.
|
boolean |
open(java.io.File file)
Tries to open the file.
|
void |
removeScriptFinishedListener(ScriptExecutionListener l)
Removes the given listener from its internal list.
|
void |
run(java.io.File file,
java.lang.String[] args)
Executes the script without loading it first.
|
static void |
runScript(Script script,
java.lang.String[] args)
Runs the specified script.
|
boolean |
save()
Saves the file under with the current filename.
|
boolean |
saveAs(java.io.File file)
Saves the file under with the given filename (and updates the internal
filename).
|
void |
setContent(java.lang.String value)
Sets the content.
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
void |
start(java.lang.String[] args)
Executes the script.
|
void |
stop()
Stops the execution of the script.
|
java.lang.String |
toString()
Returns the content as string.
|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
makeCopy
public static final java.lang.String BACKUP_EXTENSION
public Script()
public Script(javax.swing.text.Document doc)
doc
- the document to use as basispublic Script(javax.swing.text.Document doc, java.io.File file)
doc
- the document to use as basisfile
- the file to load (if not null)public java.util.Enumeration<Option> listOptions()
listOptions
in interface OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
setOptions
in interface OptionHandler
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public abstract ExtensionFileFilter[] getFilters()
public abstract java.lang.String getDefaultExtension()
saveAs(File)
public java.io.File getFilename()
public java.lang.String getNewLine()
public boolean isModified()
public java.lang.String getContent()
public void setContent(java.lang.String value)
value
- the new contentpublic void empty()
public boolean open(java.io.File file)
file
- the file to openpublic boolean save()
public boolean saveAs(java.io.File file)
file
- the filename to write the content topublic abstract Script.ScriptThread newThread(java.lang.String[] args)
args
- optional commandline argumentspublic void start(java.lang.String[] args) throws java.lang.Exception
args
- optional commandline arguments, can be nulljava.lang.Exception
- if checks or execution failpublic void stop()
public void run(java.io.File file, java.lang.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 java.lang.String toString()
toString
in class java.lang.Object
public static void runScript(Script script, java.lang.String[] args) throws java.lang.Exception
script
- the script object to useargs
- the commandline argumentsjava.lang.Exception
- if execution fails