public class DefaultScriptingScript extends AbstractScript implements ScriptingScript
Modifier and Type | Class and Description |
---|---|
static class |
DefaultScriptingScript.OutputWriter |
Modifier and Type | Field and Description |
---|---|
protected javax.script.CompiledScript |
compiledCode |
protected javax.script.ScriptEngine |
engine |
protected java.lang.String |
extension |
protected java.lang.String |
langName |
protected java.lang.String |
librarySuffix |
protected boolean |
useSysPath |
enabled, isolationGroup
changeListener, createdBy, description, id, manager, name, parent, saved, typename, version
ISOLATION_HIGH, ISOLATION_LOW
Modifier | Constructor and Description |
---|---|
|
DefaultScriptingScript(ScriptingFolder parent,
ScriptingManager manager,
java.lang.String id) |
|
DefaultScriptingScript(ScriptingFolder parent,
ScriptingManager manager,
java.lang.String id,
java.lang.String langName) |
protected |
DefaultScriptingScript(ScriptingFolder parent,
java.lang.String typename,
ScriptingManager manager,
java.lang.String id) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
__call__() |
java.lang.Object |
__call__(java.lang.Object[] args) |
java.lang.Object |
__getattr__(java.lang.String name) |
void |
__setattr__(java.lang.String name,
java.lang.Object value) |
void |
addDisposable(Disposable disposable) |
void |
addObserver(Observer o) |
void |
addStderrWriter(java.io.Writer err) |
void |
addStdoutWriter(java.io.Writer out) |
void |
compile() |
protected void |
console_println(java.lang.String s) |
void |
create(ScriptingFolder folder,
java.lang.String id,
java.lang.String language) |
void |
deleteObserver(Observer o) |
void |
deleteObservers() |
ScriptingUnit |
get(java.io.File file) |
ScriptingUnit |
get(java.lang.String name) |
java.lang.String |
getCode()
Returns the ScriptingScript's code.
|
protected java.lang.String |
getCodeToInitializeEngine() |
javax.script.ScriptEngine |
getEngine() |
java.lang.String |
getExtension() |
java.util.List<java.io.File> |
getFiles()
Return a list of the files that use this unit with out the inf file.
|
java.lang.String[] |
getIconNames()
Gets the name of the icons associated to the ScriptingUnit type.
|
java.lang.String |
getLangName()
Returns the languange in which the ScriptingScript is written.
|
java.util.List<java.io.File> |
getLibFolders() |
java.lang.String |
getLibrarySuffix() |
java.lang.String |
getMainName()
Returns the name of the main function in the ScriptingScript's code
|
java.lang.String |
getMimeType() |
java.util.List<java.lang.String> |
getNames()
Returns the list of names defined in this script.
|
java.lang.String |
getNewTemplate() |
java.io.File |
getResource(java.lang.String filename)
Return a resource File that is beside this script.
|
java.io.File |
getScriptFile() |
DefaultScriptingScript.OutputWriter |
getStderr() |
DefaultScriptingScript.OutputWriter |
getStdout() |
java.lang.String |
getText()
Returns the text associated to this unit.
|
int |
hashCode() |
java.lang.Object |
invokeFunction(java.lang.String name,
java.lang.Object[] args)
Executes a function from the Script's code
|
java.lang.Object |
invokeMethod(java.lang.Object obj,
java.lang.String name,
java.lang.Object[] args)
Executes a method from the Script's code
|
void |
load(ScriptingFolder folder,
java.lang.String id) |
protected void |
loadInf(Ini prefs) |
java.lang.Object |
main()
Run the main function of this script.
|
java.lang.Object |
main(java.lang.Object... args)
Run the main function of this script.
|
boolean |
move(ScriptingFolder target)
Moves a ScriptingUnitfrom the current directory to the new location.
|
protected void |
notifyErrors(java.lang.Exception exception,
java.lang.String command) |
void |
put(java.lang.String name,
java.lang.Object value) |
boolean |
remove() |
void |
removeStderrWriter(java.io.Writer err) |
void |
removeStdoutWriter(java.io.Writer out) |
boolean |
rename(java.lang.String newId)
Changes the ID of a ScriptingUnit and the name of the files and/or directories associated
|
java.lang.Object |
run()
Executes the code of a ScriptBaseScript.
|
java.lang.Object |
run(java.lang.Object[] args)
Executes the code of a ScriptBaseScript.
|
void |
runAsTask(java.lang.Object[] args)
Executes the code of a ScriptBaseScript in a separated thread
|
void |
save()
Persists the current status of a ScriptingScript with the content associated.
|
protected void |
save(Ini prefs) |
void |
setCode(java.lang.String code)
Sets a the code associated with a ScriptingScript.
|
void |
setExtension(java.lang.String extension) |
protected void |
setLangName(java.lang.String langName) |
void |
setLibrarySuffix(java.lang.String librarySuffix) |
void |
setMainName(java.lang.String mainName)
Stablishes a new main main function in the ScriptingScript's code.
|
void |
setText(java.lang.String text)
Sets a the text associated to this unit.
|
getIsolationGroup, isEnabled, registerDataFolder, setEnabled, setIsolationGroup
addPropertyChangeListener, create, equals, firePropertyChange, firePropertyChangeListener, getCreatedBy, getDescription, getFile, getFileResource, getId, getInfBoolean, getInfInt, getInfString, getInfValue, getManager, getName, getParent, getProperties, getProperty, getTypeName, getURL, getUserPath, getVersion, isASystemUnit, isSaved, reload, setCreatedBy, setDescription, setId, setName, setParent, setProperty, setSaved, setVersion, toString
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
registerDataFolder
getIsolationGroup, isEnabled, setEnabled, setIsolationGroup
addPropertyChangeListener, getCreatedBy, getDescription, getFile, getFileResource, getId, getName, getParent, getProperties, getProperty, getTypeName, getUserPath, getVersion, isASystemUnit, isSaved, reload, setCreatedBy, setDescription, setName, setProperty, setSaved, setVersion
equals, getName, getTypeName, getURL
protected java.lang.String langName
protected java.lang.String extension
protected java.lang.String librarySuffix
protected javax.script.ScriptEngine engine
protected javax.script.CompiledScript compiledCode
protected boolean useSysPath
protected DefaultScriptingScript(ScriptingFolder parent, java.lang.String typename, ScriptingManager manager, java.lang.String id)
public DefaultScriptingScript(ScriptingFolder parent, ScriptingManager manager, java.lang.String id)
public DefaultScriptingScript(ScriptingFolder parent, ScriptingManager manager, java.lang.String id, java.lang.String langName)
public int hashCode()
hashCode
in interface Script
hashCode
in class AbstractUnit
public void addStdoutWriter(java.io.Writer out)
addStdoutWriter
in interface ScriptingBaseScript
public void addStderrWriter(java.io.Writer err)
addStderrWriter
in interface ScriptingBaseScript
public void removeStdoutWriter(java.io.Writer out)
removeStdoutWriter
in interface ScriptingBaseScript
public void removeStderrWriter(java.io.Writer err)
removeStderrWriter
in interface ScriptingBaseScript
public java.lang.Object __getattr__(java.lang.String name)
public void __setattr__(java.lang.String name, java.lang.Object value)
public java.lang.Object __call__()
public java.lang.Object __call__(java.lang.Object[] args)
public DefaultScriptingScript.OutputWriter getStdout()
public DefaultScriptingScript.OutputWriter getStderr()
protected void notifyErrors(java.lang.Exception exception, java.lang.String command)
public java.lang.String getCode()
ScriptingScript
getCode
in interface ScriptingScript
getCode
in interface Script
public void setCode(java.lang.String code)
ScriptingScript
setCode
in interface ScriptingScript
setCode
in interface Script
code
- String that contains the new code.public java.lang.String getLibrarySuffix()
getLibrarySuffix
in interface ScriptingBaseScript
public void setLibrarySuffix(java.lang.String librarySuffix)
setLibrarySuffix
in interface ScriptingBaseScript
public java.util.List<java.io.File> getLibFolders()
protected java.lang.String getCodeToInitializeEngine()
public javax.script.ScriptEngine getEngine()
protected void loadInf(Ini prefs)
loadInf
in class AbstractScript
public void load(ScriptingFolder folder, java.lang.String id)
load
in interface Unit
load
in class AbstractUnit
public void save()
ScriptingScript
save
in interface ScriptingScript
save
in interface ScriptingText
protected void save(Ini prefs)
save
in class AbstractScript
public java.lang.String getLangName()
ScriptingScript
getLangName
in interface ScriptingScript
protected void setLangName(java.lang.String langName)
public java.lang.String[] getIconNames()
ScriptingUnit
getIconNames
in interface ScriptingUnit
public java.lang.String getMainName()
ScriptingScript
getMainName
in interface ScriptingScript
public void setMainName(java.lang.String mainName)
ScriptingScript
setMainName
in interface ScriptingScript
mainName
- String that contains the new main function name.public java.util.List<java.io.File> getFiles()
ScriptingUnit
getFiles
in interface ScriptingUnit
public java.lang.String getExtension()
public void setExtension(java.lang.String extension)
public void addObserver(Observer o)
addObserver
in interface Observable
public void deleteObserver(Observer o)
deleteObserver
in interface Observable
public void deleteObservers()
deleteObservers
in interface Observable
public void put(java.lang.String name, java.lang.Object value)
put
in interface ScriptingBaseScript
put
in interface Script
public void compile()
compile
in interface ScriptingBaseScript
public void addDisposable(Disposable disposable)
public java.lang.Object main()
public java.lang.Object main(java.lang.Object... args)
args
- public java.lang.Object run()
ScriptingBaseScript
run
in interface ScriptingBaseScript
public java.lang.Object run(java.lang.Object[] args)
ScriptingBaseScript
run
in interface ScriptingBaseScript
args
- Contains the input parameters to run the ScriptBaseScript.public java.lang.Object invokeFunction(java.lang.String name, java.lang.Object[] args)
ScriptingScript
invokeFunction
in interface ScriptingScript
invokeFunction
in interface Script
name
- method's name to executeargs
- input parameters of the methodpublic java.io.File getScriptFile()
getScriptFile
in interface ScriptingBaseScript
public java.lang.Object invokeMethod(java.lang.Object obj, java.lang.String name, java.lang.Object[] args) throws java.lang.NoSuchMethodException
ScriptingScript
invokeMethod
in interface ScriptingScript
obj
- this Object represents the script's codename
- method's name to executeargs
- input parameters of the methodjava.lang.NoSuchMethodException
- If there isn't a main function to begin the executionpublic java.io.File getResource(java.lang.String filename)
ScriptingBaseScript
getResource
in interface ScriptingBaseScript
public java.lang.String getMimeType()
getMimeType
in interface ScriptingScript
getMimeType
in interface ScriptingText
protected void console_println(java.lang.String s)
console_println
in class AbstractUnit
public void runAsTask(java.lang.Object[] args)
ScriptingBaseScript
runAsTask
in interface ScriptingBaseScript
args
- Contains the input parameters to run the ScriptBaseScript.public boolean remove()
remove
in interface ScriptingUnit
public void create(ScriptingFolder folder, java.lang.String id, java.lang.String language)
public java.lang.String getNewTemplate()
public ScriptingUnit get(java.lang.String name)
public ScriptingUnit get(java.io.File file)
public boolean move(ScriptingFolder target)
ScriptingUnit
move
in interface ScriptingUnit
target
- ScriptingFolder
that represents the destination..public boolean rename(java.lang.String newId)
ScriptingUnit
rename
in interface ScriptingUnit
newId
- String that contains the new Id.public java.util.List<java.lang.String> getNames()
Script
public java.lang.String getText()
ScriptingText
getText
in interface ScriptingText
public void setText(java.lang.String text)
ScriptingText
setText
in interface ScriptingText
text
- String to assign to this unit.