S
- the script interfacepublic class JSScriptWrapper<S> extends AbstractScriptWrapper<S>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MIME
The Javascript scripts MIME type.
|
additionalHelpers, context, exListeners, firstException, hasCustomHelper, helper, importLines, logger, offset, optimLevel, scriptContent, source, VARIABLES_DECL_AFTER_CLASS_DECL, VARIABLES_DECL_BEFORE_CLASS_DECL
MODE_BLOCKING, MODE_NON_BLOCKING, OPTIM_LEVEL_DEFAULT, OPTIM_LEVEL_MAX, OPTIM_LEVEL_MIN
Constructor and Description |
---|
JSScriptWrapper() |
Modifier and Type | Method and Description |
---|---|
void |
cacheInvocableMethods()
Cache the invocable methods fore the current installed script.
|
boolean |
compilerIsStrict()
Return true if the compiler must be strict about interface methods implementations.
|
protected java.lang.Object |
createScriptObject(java.lang.String scriptContent)
Create the Javascript Object.
|
void |
executeInGraphicThread(short executeInGraphicThread)
Set the graphic framework in which the script must be executed.
|
protected ScriptException<S> |
getCompileException(java.lang.Exception e)
Return a proper exception from a Javascript compile-time exception, with the correct file and line number.
|
protected java.lang.String |
getDefaultContent()
Return the default content lines at the start of the script.
|
protected java.lang.String |
getDefaultDeclaration()
Return the default declaration lines at the start of the script.
|
protected java.lang.String |
getDefaultImports()
Return the default import lines at the start of the script.
|
protected java.lang.String |
getEnd()
Return the lines at the end of the script.
|
short |
getGraphicThreadExecution()
Return the graphic framework in which the script must be executed.
|
protected CachedMethodKey |
getInvocableMethodKey(java.lang.String name,
java.lang.Class<?>[] argTypes)
Return the key for the invocable method with a specified name and arguments.
|
java.util.Set<CachedMethodKey> |
getInvocableMethods()
Return the invocable methods for the current installed script.
|
java.util.Map<java.lang.String,java.util.Set<CachedMethodKey>> |
getInvocableMethodsByNames()
Return the invocable methods sorted by their names for the current installed script.
|
java.lang.String |
getMIME()
Return the script MIME.
|
JSScriptable |
getScriptable()
Return the scriptable allowing to define built-in function properties that can be called in the Javascript script.
|
ScriptException<S> |
getScriptException(java.lang.Throwable th)
Create a Script exception from a Throwable.
|
java.lang.String |
getScriptExtension()
Return the script file extension.
|
protected short |
getVariablesDeclarationsPosition()
Return the position of the variables declaration.
|
java.lang.Object |
invokeMethod(java.lang.String name,
java.lang.Object... args)
Invoke directly a method by reflection for the current installed script.
|
boolean |
isAutoCachingInvocableMethods()
Return true if a cache of invocable methods will be created each time the wrapper installs a new script.
|
boolean |
isInvocableMethodsEnabled()
Return true because the JSScriptWrapper allows invocable methods are enabled for this wrapper.
|
static boolean |
isJSException(java.lang.StackTraceElement st)
Return true if the StackTraceElement corresponds to a Javascript exception.
|
boolean |
isLibAvailable()
Return true if the Rhino library is available.
|
boolean |
isLibAvailable(java.lang.ClassLoader loader)
Return true if the Rhino library is available.
|
boolean |
isMultiImplementSupported()
Return true.
|
boolean |
isSingletonMethodEnabled()
Return true.
|
protected boolean |
parseScript(ScriptSource source,
ScriptContent content)
Parse the script content.
|
void |
setAutoCacheInvocableMethods(boolean autoCache)
Set if a cache of invocable methods will be created each time the wrapper installs a new script.
|
void |
setCompilerIsStrict(boolean compilerIsStrict)
Set if the compiler must be strict about interface methods implementations.
|
void |
setScriptable(JSScriptable scriptable)
Set a scriptable allowing to define built-in function properties that can be called in the Javascript script.
|
addAdditionalHelper, addExceptionListener, addImports, addImports, addImports, clearAdditionalHelpers, clearImports, convertPrimitiveArgument, countImportLines, createScriptContext, createScriptObject, err, getAdditionalHelpers, getClassLoader, getContextClassPath, getCustomImports, getExceptionListeners, getExecutionMode, getFilename, getHelperClassPath, getLineNumber, getLoggerClassPath, getOffset, getOptimizationLevel, getPreferredLogger, getRawScript, getScriptClassName, getScriptContent, getScriptContext, getScriptInterface, getScriptProxy, getSingletonMethod, getSource, hasAdditionalHelpers, hasScriptHelper, hasSingletonMethod, installScript, installScript, installScript, installScript, isLoggingExceptions, logExceptions, reInstallScript, reInstallScript, reInstallScript, removeExceptionListener, removeTabulations, setClassLoader, setExecutionMode, setOptimizationLevel, setScriptContext, setScriptLogger, startMethod
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
__step__, err, getLineNumber, getScript, getScriptProxy, getScriptProxyHandler, installScript, installScript, installScript, installScript, isDebugging, isDebugSupported, isInDebugSession, resetWrapperState
hasInvocableMethod, invokeMethod, isInvocableByName
public static final java.lang.String MIME
public boolean isLibAvailable()
public void executeInGraphicThread(short executeInGraphicThread)
GraphicFramework.NONE
: direct executionGraphicFramework.SWING
: execution in the Swing event threadGraphicFramework.JAVAFX
: execution in the JavaFX event threadexecuteInGraphicThread
- the graphic framework.public short getGraphicThreadExecution()
public void setCompilerIsStrict(boolean compilerIsStrict)
NotImplementedException
is an interface method with no default implementation does not exist in the Javascript script.compilerIsStrict
- true if the compiler must be strict about interface methods implementationspublic boolean compilerIsStrict()
public boolean isLibAvailable(java.lang.ClassLoader loader)
loader
- the Classloaderpublic java.lang.String getMIME()
public java.lang.String getScriptExtension()
public boolean isMultiImplementSupported()
public boolean isSingletonMethodEnabled()
public boolean isInvocableMethodsEnabled()
public boolean isAutoCachingInvocableMethods()
public void setAutoCacheInvocableMethods(boolean autoCache)
autoCache
- true if a cache of invocable methods will be created each time the wrapper installs a new scriptpublic void cacheInvocableMethods()
public java.util.Set<CachedMethodKey> getInvocableMethods()
public java.util.Map<java.lang.String,java.util.Set<CachedMethodKey>> getInvocableMethodsByNames()
protected CachedMethodKey getInvocableMethodKey(java.lang.String name, java.lang.Class<?>[] argTypes)
getInvocableMethodKey
in class AbstractScriptWrapper<S>
name
- the method nameargTypes
- the method argumentspublic java.lang.Object invokeMethod(java.lang.String name, java.lang.Object... args)
name
- the method nameargs
- the method argumentspublic void setScriptable(JSScriptable scriptable)
scriptable
- the scriptablepublic JSScriptable getScriptable()
protected java.lang.String getDefaultImports()
getDefaultImports
in class AbstractScriptWrapper<S>
protected short getVariablesDeclarationsPosition()
getVariablesDeclarationsPosition
in class AbstractScriptWrapper<S>
protected java.lang.String getDefaultDeclaration()
getDefaultDeclaration
in class AbstractScriptWrapper<S>
protected java.lang.String getEnd()
getEnd
in class AbstractScriptWrapper<S>
protected java.lang.String getDefaultContent()
getDefaultContent
in class AbstractScriptWrapper<S>
protected java.lang.Object createScriptObject(java.lang.String scriptContent) throws java.lang.Exception
createScriptObject
in class AbstractScriptWrapper<S>
scriptContent
- the script contentjava.lang.Exception
- if the script instance coult not be createdprotected boolean parseScript(ScriptSource source, ScriptContent content)
AbstractScriptWrapper
parseScript
in class AbstractScriptWrapper<S>
source
- the script sourcecontent
- the content objectpublic ScriptException<S> getScriptException(java.lang.Throwable th)
ScriptWrapper
th
- the Throwablepublic static boolean isJSException(java.lang.StackTraceElement st)
st
- the StackTraceElementprotected ScriptException<S> getCompileException(java.lang.Exception e)
getCompileException
in class AbstractScriptWrapper<S>
e
- the initial ExceptionCopyright © 2019-2024 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence