public class FScript
extends java.lang.Object
This class encapsulates the script-specific logic, which, due to its size and complexity, is kept separate from the "DefaultFormContext" class. It uses a "SoftReferenceCache" to manage script objects, preventing memory leaks while retaining frequently used scripts. The methods are designed to work with various scripting languages (BeanShell, Groovy) and provide robust error handling and parameter passing.
Modifier and Type | Field and Description |
---|---|
static java.util.Map<java.lang.String,java.lang.Class> |
DEFAULT_PARM_MAP
A map of default parameter names to their types.
|
static java.lang.String[] |
DEFAULT_PARM_NAMES
Default parameter names used in script evaluation contexts.
|
static java.lang.Class[] |
DEFAULT_PARM_TYPES
Default parameter types corresponding to the names in
DEFAULT_PARM_NAMES . |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
eval(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg)
Evaluates a script with default arguments and returns an Object.
|
static java.lang.Object |
eval(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg,
boolean showException)
Evaluates a script with default arguments and returns an Object.
|
static java.lang.Object |
eval(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg,
java.util.Map parameters)
Evaluates a script with additional arguments provided in a parameter map.
|
static java.lang.Object |
eval(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg,
java.util.Map parameters,
boolean showException)
Evaluates a script with additional arguments provided in a parameter map.
|
static java.lang.Object |
eval(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg,
java.lang.String[] argNames,
java.lang.Class[] argTypes,
java.lang.Object[] argValues)
Evaluates a script with additional arguments and returns an Object.
|
static java.lang.Object |
eval(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg,
java.lang.String[] argNames,
java.lang.Class[] argTypes,
java.lang.Object[] argValues,
boolean showException)
Evaluates a script with additional arguments and returns an Object.
|
static java.lang.Object |
eval(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg,
java.lang.String[] argNames,
java.lang.Class[] argTypes,
java.lang.Object[] argValues,
boolean showException,
boolean allowDeclare)
Evaluates a script with additional arguments and returns an Object.
|
static boolean |
evalAsBool(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg)
Evaluates a script and returns a boolean value.
|
static boolean |
evalAsBool(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg,
boolean nullValue)
Evaluates a script and returns a boolean value.
|
static boolean |
evalAsBool(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg,
boolean nullValue,
boolean showException)
Evaluates a script and returns a boolean value.
|
static boolean |
evalAsBool(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg,
java.lang.String[] argNames,
java.lang.Class[] argTypes,
java.lang.Object[] argValues)
Evaluates a script with additional parameters and returns a boolean value.
|
static boolean |
evalAsBool(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg,
java.lang.String[] argNames,
java.lang.Class[] argTypes,
java.lang.Object[] argValues,
boolean nullValue)
Evaluates a script with additional parameters and returns a boolean value.
|
static boolean |
evalAsBool(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg,
java.lang.String[] argNames,
java.lang.Class[] argTypes,
java.lang.Object[] argValues,
boolean nullValue,
boolean showException)
Evaluates a script with additional parameters and returns a boolean value.
|
static java.lang.String |
getLanguage(electric.xml.Element _el)
Retrieves the scripting language from an XML element's 'language' attribute.
|
static java.lang.Object |
runAndDeclare(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg)
Runs a script and allows it to declare new variables.
|
static java.lang.Object |
runAndDeclare(FormElementI fe,
FormContextI ftx,
electric.xml.Element el,
java.lang.Object errMsg,
boolean showException)
Runs a script and allows it to declare new variables.
|
public static final java.lang.String[] DEFAULT_PARM_NAMES
public static final java.lang.Class[] DEFAULT_PARM_TYPES
DEFAULT_PARM_NAMES
.public static final java.util.Map<java.lang.String,java.lang.Class> DEFAULT_PARM_MAP
public static boolean evalAsBool(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg)
false
is returned.
This is a convenience method that delegates to the comprehensive _eval
method.fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.false
if null.public static boolean evalAsBool(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg, boolean nullValue)
_eval
method.fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.nullValue
- The default boolean value to return if the script result is null.nullValue
if null.public static boolean evalAsBool(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg, boolean nullValue, boolean showException)
_eval
method.fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.nullValue
- The default boolean value to return if the script result is null.showException
- If true
, an error dialog is shown to the user on exception.nullValue
if null.public static boolean evalAsBool(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg, java.lang.String[] argNames, java.lang.Class[] argTypes, java.lang.Object[] argValues)
false
is returned.
This is a convenience method that delegates to the comprehensive _eval
method.fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.argNames
- An array of names for the additional script arguments.argTypes
- An array of types for the additional script arguments.argValues
- An array of values for the additional script arguments.false
if null.public static boolean evalAsBool(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg, java.lang.String[] argNames, java.lang.Class[] argTypes, java.lang.Object[] argValues, boolean nullValue)
_eval
method.fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.argNames
- An array of names for the additional script arguments.argTypes
- An array of types for the additional script arguments.argValues
- An array of values for the additional script arguments.nullValue
- The default boolean value to return if the script result is null.nullValue
if null.public static boolean evalAsBool(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg, java.lang.String[] argNames, java.lang.Class[] argTypes, java.lang.Object[] argValues, boolean nullValue, boolean showException)
_eval
method.fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.argNames
- An array of names for the additional script arguments.argTypes
- An array of types for the additional script arguments.argValues
- An array of values for the additional script arguments.nullValue
- The default boolean value to return if the script result is null.showException
- If true
, an error dialog is shown to the user on exception.nullValue
if null.public static java.lang.Object eval(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg)
_eval
method.fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.public static java.lang.Object eval(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg, boolean showException)
_eval
method.fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.showException
- If true
, an error dialog is shown to the user on exception.public static java.lang.Object runAndDeclare(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg)
_eval
method.fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.public static java.lang.Object runAndDeclare(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg, boolean showException)
_eval
method.fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.showException
- If true
, an error dialog is shown to the user on exception.public static java.lang.Object eval(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg, java.lang.String[] argNames, java.lang.Class[] argTypes, java.lang.Object[] argValues)
_eval
method.fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.argNames
- An array of names for the additional script arguments.argTypes
- An array of types for the additional script arguments.argValues
- An array of values for the additional script arguments.public static java.lang.Object eval(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg, java.lang.String[] argNames, java.lang.Class[] argTypes, java.lang.Object[] argValues, boolean showException)
_eval
method.fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.argNames
- An array of names for the additional script arguments.argTypes
- An array of types for the additional script arguments.argValues
- An array of values for the additional script arguments.showException
- If true
, an error dialog is shown to the user on exception.public static java.lang.Object eval(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg, java.lang.String[] argNames, java.lang.Class[] argTypes, java.lang.Object[] argValues, boolean showException, boolean allowDeclare)
_eval
method.fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.argNames
- An array of names for the additional script arguments.argTypes
- An array of types for the additional script arguments.argValues
- An array of values for the additional script arguments.showException
- If true
, an error dialog is shown to the user on exception.allowDeclare
- If true
, the script is allowed to declare new variables in its context.public static java.lang.Object eval(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg, java.util.Map parameters)
This method automatically extracts argument names and values from the map and
passes them to the underlying _eval
method. It also includes the entire
map as a parameter named "_parameters" and each key as a separate parameter
prefixed with "_" (e.g. "_myParameter").
fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.parameters
- A Map
of parameters where keys are names and values are the values.public static java.lang.Object eval(FormElementI fe, FormContextI ftx, electric.xml.Element el, java.lang.Object errMsg, java.util.Map parameters, boolean showException)
This method automatically extracts argument names and values from the map and
passes them to the underlying _eval
method. It also includes the entire
map as a parameter named "_parameters" and each key as a separate parameter
prefixed with "_" (e.g. "_myParameter").
fe
- The FormElementI
instance.ftx
- The FormContextI
instance.el
- The XML Element
containing the script code.errMsg
- An error message to use if an exception occurs.parameters
- A Map
of parameters where keys are names and values are the values.showException
- If true
, an error dialog is shown to the user on exception.public static java.lang.String getLanguage(electric.xml.Element _el)
element
- The XML Element
.Copyright © 2000-2025 OAshi S.à r.l. All Rights Reserved.