Class ScriptWrapper


  • public class ScriptWrapper
    extends java.lang.Object
    • Constructor Detail

      • ScriptWrapper

        public ScriptWrapper()
      • ScriptWrapper

        public ScriptWrapper​(java.lang.String name,
                             java.lang.String description,
                             java.lang.String engineName,
                             ScriptType type,
                             boolean enabled,
                             java.io.File file)
      • ScriptWrapper

        public ScriptWrapper​(java.lang.String name,
                             java.lang.String description,
                             ScriptEngineWrapper engine,
                             ScriptType type,
                             boolean enabled,
                             java.io.File file)
      • ScriptWrapper

        protected ScriptWrapper​(java.lang.String name,
                                java.lang.String description,
                                java.lang.String engineName,
                                java.lang.String typeName,
                                boolean enabled,
                                java.io.File file)
    • Method Detail

      • getName

        public java.lang.String getName()
      • setName

        public void setName​(java.lang.String name)
      • getDescription

        public java.lang.String getDescription()
      • setDescription

        public void setDescription​(java.lang.String description)
      • getEngine

        public ScriptEngineWrapper getEngine()
        Gets the script engine wrapper. Might be null if the engine is not installed or was not yet set.
        Returns:
        the engine of the script, or null if not installed or was not yet set
      • setEngineName

        public void setEngineName​(java.lang.String engineName)
      • getEngineName

        public java.lang.String getEngineName()
      • setType

        public void setType​(ScriptType type)
      • getTypeName

        public java.lang.String getTypeName()
      • getContents

        public java.lang.String getContents()
      • setContents

        public void setContents​(java.lang.String contents)
      • getModCount

        public int getModCount()
        Gets the mod count.

        The value is different each time the contents of the script change.

        Returns:
        the mod count.
        Since:
        2.10.0
      • getLastOutput

        public java.lang.String getLastOutput()
      • setLastOutput

        public void setLastOutput​(java.lang.String lastOutput)
      • isChanged

        public boolean isChanged()
      • setChanged

        public void setChanged​(boolean changed)
      • isEnabled

        public boolean isEnabled()
      • setEnabled

        public void setEnabled​(boolean enabled)
        Sets if this script is enabled.

        It's not possible to enable scripts without engine.

        Parameters:
        enabled - true if the script should be enabled, false otherwise
        See Also:
        getEngine()
      • getLastErrorDetails

        public java.lang.String getLastErrorDetails()
      • setLastErrorDetails

        public void setLastErrorDetails​(java.lang.String lastErrorDetails)
      • getLastException

        public java.lang.Exception getLastException()
      • setLastException

        public void setLastException​(java.lang.Exception lastException)
      • isError

        public boolean isError()
      • setError

        public void setError​(boolean error)
      • isLoadOnStart

        public boolean isLoadOnStart()
      • setLoadOnStart

        public void setLoadOnStart​(boolean loadOnStart)
      • getFile

        public java.io.File getFile()
      • setFile

        public void setFile​(java.io.File file)
      • getInterface

        public <T> T getInterface​(java.lang.Class<T> class1)
                           throws javax.script.ScriptException,
                                  java.io.IOException
        Throws:
        javax.script.ScriptException
        java.io.IOException
      • isRunableStandalone

        @Deprecated
        public boolean isRunableStandalone()
        Deprecated.
      • isRunnableStandalone

        public boolean isRunnableStandalone()
      • getWriter

        public java.io.Writer getWriter()
        Gets the writer which will be written to every time this script runs (if any)
        Returns:
      • setWriter

        public void setWriter​(java.io.Writer writer)
        Set a writer which will be written to every time this script runs
        Parameters:
        writer -
      • reloadScript

        public void reloadScript()
                          throws java.io.IOException
        Reloads the script. It should only be called if the script has already been loaded via loadScript(Charset)
        Throws:
        java.io.IOException
        Since:
        2.8.0
      • hasChangedOnDisk

        public boolean hasChangedOnDisk()
        Returns true if the script has changed on disk since it was loaded into this class
        Returns:
        true if the script has changed on disk since it was loaded into this class
        Since:
        2.8.0