Class JexlFeatures
- Registers: register syntax (#number), used internally for {g,s}etProperty
- Reserved Names: a set of reserved variable names that can not be used as local variable (or parameter) names
- Global Side Effect : assigning/modifying values on global variables (=, += , -=, ...)
- Lexical: lexical scope, prevents redefining local variables
- Lexical Shade: local variables shade globals, prevents confusing a global variable with a local one
- Side Effect : assigning/modifying values on any variables or left-value
- Constant Array Reference: ensures array references only use constants;they should be statically solvable.
- New Instance: creating an instance using new(...)
- Loops: loop constructs (while(true), for(...))
- Lambda: function definitions (()->{...}, function(...) ).
- Method calls: calling methods (obj.method(...) or obj['method'](...)); when disabled, leaves function calls - including namespace prefixes - available
- Structured literals: arrays, lists, maps, sets, ranges
- Pragma: pragma construct as in
#pragma x y
- Annotation: @annotation statement;
- Thin-arrow: use the thin-arrow, ie
->
for lambdas as inx -> x + x
- Fat-arrow: use the fat-arrow, ie
=>
for lambdas as inx => x + x
- Namespace pragma: whether the
#pragma jexl.namespace.ns namespace
syntax is allowed - Import pragma: whether the
#pragma jexl.import fully.qualified.class.name
syntax is allowed - Comparator names: whether the comparator operator names can be used (as in
gt
for >,lt
for <, ...) - Pragma anywhere: whether pragma, that are not statements and handled before execution begins, can appear anywhere in the source or before any statements - ie at the beginning of a script.
- Since:
- 3.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Annotation feature ordinal.static final int
Array get is allowed on expr.static final int
Comparator names (legacy) syntax.private static final long
The default features flag mask.private static final String[]
Te feature names (for toString()).static final int
Fat-arrow lambda syntax.private long
The feature flags.static final int
Import pragma feature ordinal.static final int
Lambda feature ordinal.static final int
Lexical feature ordinal.static final int
Lexical shade feature ordinal.static final int
Locals feature ordinal.static final int
Loops feature ordinal.static final int
Lambda feature ordinal.The namespace names.static final int
New-instance feature ordinal.static final int
Namespace pragma feature ordinal.static final int
Pragma feature ordinal.static final int
The pragma anywhere feature ordinal.private static final int
Registers feature ordinal.static final int
Reserved name feature ordinal.The set of reserved names, aka global variables that can not be masked by local variables or parameters.static final int
Script feature ordinal.static final int
Side effects feature ordinal.static final int
Global side-effects feature ordinal.static final int
Structured literal feature ordinal.The false predicate.static final int
Fat-arrow lambda syntax. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an all-features-enabled instance.JexlFeatures
(JexlFeatures features) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionannotation
(boolean flag) Sets whether annotation constructs are enabled.arrayReferenceExpr
(boolean flag) Sets whether array references expressions are enabled.comparatorNames
(boolean flag) Sets whether the legacy comparison operator names syntax is enabled.boolean
fatArrow
(boolean flag) Sets whether fat-arrow lambda syntax is enabled.private boolean
getFeature
(int feature) Gets a feature flag value.int
hashCode()
importPragma
(boolean flag) Sets whether import pragma constructs are enabled.boolean
boolean
boolean
isReservedName
(String name) Checks whether a name is reserved.lambda
(boolean flag) Sets whether lambda/function constructs are enabled.lexical
(boolean flag) Sets whether syntactic lexical mode is enabled.lexicalShade
(boolean flag) Sets whether syntactic lexical shade is enabled.localVar
(boolean flag) Sets whether local variables are enabled.loops
(boolean flag) Sets whether looping constructs are enabled.methodCall
(boolean flag) Sets whether method calls expressions are enabled.namespacePragma
(boolean flag) Sets whether namespace pragma constructs are enabled.namespaceTest
(Predicate<String> names) Sets a test to determine namespace declaration.newInstance
(boolean flag) Sets whether creating new instances is enabled.pragma
(boolean flag) Sets whether pragma constructs are enabled.pragmaAnywhere
(boolean flag) Sets whether pragma constructs can appear anywhere in the code.register
(boolean flag) Sets whether register are enabled.reservedNames
(Collection<String> names) Sets a collection of reserved names precluding those to be used as local variables or parameter names.script
(boolean flag) Sets whether scripts constructs are enabled.private void
setFeature
(int feature, boolean flag) Sets a feature flag.sideEffect
(boolean flag) Sets whether side effect expressions are enabled.sideEffectGlobal
(boolean flag) Sets whether side effect expressions on global variables (aka non-local) are enabled.static String
stringify
(int feature) The text corresponding to a feature code.structuredLiteral
(boolean flag) Sets whether array/map/set literal expressions are enabled.boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
thinArrow
(boolean flag) Sets whether thin-arrow lambda syntax is enabled.
-
Field Details
-
flags
private long flagsThe feature flags. -
reservedNames
The set of reserved names, aka global variables that can not be masked by local variables or parameters. -
nameSpaces
The namespace names. -
TEST_STR_FALSE
The false predicate. -
F_NAMES
Te feature names (for toString()). -
REGISTER
private static final int REGISTERRegisters feature ordinal.- See Also:
-
RESERVED
public static final int RESERVEDReserved name feature ordinal.- See Also:
-
LOCAL_VAR
public static final int LOCAL_VARLocals feature ordinal.- See Also:
-
SIDE_EFFECT
public static final int SIDE_EFFECTSide effects feature ordinal.- See Also:
-
SIDE_EFFECT_GLOBAL
public static final int SIDE_EFFECT_GLOBALGlobal side-effects feature ordinal.- See Also:
-
ARRAY_REF_EXPR
public static final int ARRAY_REF_EXPRArray get is allowed on expr.- See Also:
-
NEW_INSTANCE
public static final int NEW_INSTANCENew-instance feature ordinal.- See Also:
-
LOOP
public static final int LOOPLoops feature ordinal.- See Also:
-
LAMBDA
public static final int LAMBDALambda feature ordinal.- See Also:
-
METHOD_CALL
public static final int METHOD_CALLLambda feature ordinal.- See Also:
-
STRUCTURED_LITERAL
public static final int STRUCTURED_LITERALStructured literal feature ordinal.- See Also:
-
PRAGMA
public static final int PRAGMAPragma feature ordinal.- See Also:
-
ANNOTATION
public static final int ANNOTATIONAnnotation feature ordinal.- See Also:
-
SCRIPT
public static final int SCRIPTScript feature ordinal.- See Also:
-
LEXICAL
public static final int LEXICALLexical feature ordinal.- See Also:
-
LEXICAL_SHADE
public static final int LEXICAL_SHADELexical shade feature ordinal.- See Also:
-
THIN_ARROW
public static final int THIN_ARROWFat-arrow lambda syntax.- See Also:
-
FAT_ARROW
public static final int FAT_ARROWFat-arrow lambda syntax.- See Also:
-
NS_PRAGMA
public static final int NS_PRAGMANamespace pragma feature ordinal.- See Also:
-
IMPORT_PRAGMA
public static final int IMPORT_PRAGMAImport pragma feature ordinal.- See Also:
-
COMPARATOR_NAMES
public static final int COMPARATOR_NAMESComparator names (legacy) syntax.- See Also:
-
PRAGMA_ANYWHERE
public static final int PRAGMA_ANYWHEREThe pragma anywhere feature ordinal.- See Also:
-
DEFAULT_FEATURES
private static final long DEFAULT_FEATURESThe default features flag mask.- See Also:
-
-
Constructor Details
-
JexlFeatures
public JexlFeatures()Creates an all-features-enabled instance. -
JexlFeatures
Copy constructor.- Parameters:
features
- the feature to copy from
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
stringify
The text corresponding to a feature code.- Parameters:
feature
- the feature number- Returns:
- the feature name
-
reservedNames
Sets a collection of reserved names precluding those to be used as local variables or parameter names.- Parameters:
names
- the names to reserve- Returns:
- this features instance
-
getReservedNames
- Returns:
- the (unmodifiable) set of reserved names.
-
isReservedName
Checks whether a name is reserved.- Parameters:
name
- the name to check- Returns:
- true if reserved, false otherwise
-
namespaceTest
Sets a test to determine namespace declaration.- Parameters:
names
- the name predicate- Returns:
- this features instance
-
namespaceTest
- Returns:
- the declared namespaces test.
-
setFeature
private void setFeature(int feature, boolean flag) Sets a feature flag.- Parameters:
feature
- the feature ordinalflag
- turn-on, turn off
-
getFeature
private boolean getFeature(int feature) Gets a feature flag value.- Parameters:
feature
- feature ordinal- Returns:
- true if on, false if off
-
register
Sets whether register are enabled.This is mostly used internally during execution of JexlEngine.{g,s}etProperty.
When disabled, parsing a script/expression using the register syntax will throw a parsing exception.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
-
supportsRegister
public boolean supportsRegister()- Returns:
- true if register syntax is enabled
-
localVar
Sets whether local variables are enabled.When disabled, parsing a script/expression using a local variable or parameter syntax will throw a parsing exception.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
-
supportsLocalVar
public boolean supportsLocalVar()- Returns:
- true if local variables syntax is enabled
-
sideEffectGlobal
Sets whether side effect expressions on global variables (aka non-local) are enabled.When disabled, parsing a script/expression using syntactical constructs modifying variables including all potentially ant-ish variables will throw a parsing exception.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
-
supportsSideEffectGlobal
public boolean supportsSideEffectGlobal()- Returns:
- true if global variables can be assigned
-
sideEffect
Sets whether side effect expressions are enabled.When disabled, parsing a script/expression using syntactical constructs modifying variables or members will throw a parsing exception.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
-
supportsSideEffect
public boolean supportsSideEffect()- Returns:
- true if side effects are enabled, false otherwise
-
arrayReferenceExpr
Sets whether array references expressions are enabled.When disabled, parsing a script/expression using 'obj[ ref ]' where ref is not a string or integer literal will throw a parsing exception;
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
-
supportsArrayReferenceExpr
public boolean supportsArrayReferenceExpr()- Returns:
- true if array references can contain method call expressions, false otherwise
-
methodCall
Sets whether method calls expressions are enabled.When disabled, parsing a script/expression using 'obj.method()' will throw a parsing exception;
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
-
supportsMethodCall
public boolean supportsMethodCall()- Returns:
- true if array references can contain expressions, false otherwise
-
structuredLiteral
Sets whether array/map/set literal expressions are enabled.When disabled, parsing a script/expression creating one of these literals will throw a parsing exception;
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
-
supportsStructuredLiteral
public boolean supportsStructuredLiteral()- Returns:
- true if array/map/set literal expressions are supported, false otherwise
-
newInstance
Sets whether creating new instances is enabled.When disabled, parsing a script/expression using 'new(...)' will throw a parsing exception; using a class as functor will fail at runtime.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
-
supportsNewInstance
public boolean supportsNewInstance()- Returns:
- true if creating new instances is enabled, false otherwise
-
loops
Sets whether looping constructs are enabled.When disabled, parsing a script/expression using syntactic looping constructs (for,while) will throw a parsing exception.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
-
supportsLoops
public boolean supportsLoops()- Returns:
- true if loops are enabled, false otherwise
-
lambda
Sets whether lambda/function constructs are enabled.When disabled, parsing a script/expression using syntactic lambda constructs (->,function) will throw a parsing exception.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
-
supportsLambda
public boolean supportsLambda()- Returns:
- true if lambda are enabled, false otherwise
-
thinArrow
Sets whether thin-arrow lambda syntax is enabled.When disabled, parsing a script/expression using syntactic thin-arrow (-<) will throw a parsing exception.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
- Since:
- 3.3
-
supportsThinArrow
public boolean supportsThinArrow()- Returns:
- true if thin-arrow lambda syntax is enabled, false otherwise
- Since:
- 3.3
-
fatArrow
Sets whether fat-arrow lambda syntax is enabled.When disabled, parsing a script/expression using syntactic fat-arrow (=<) will throw a parsing exception.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
- Since:
- 3.3
-
supportsFatArrow
public boolean supportsFatArrow()- Returns:
- true if fat-arrow lambda syntax is enabled, false otherwise
- Since:
- 3.3
-
comparatorNames
Sets whether the legacy comparison operator names syntax is enabled.When disabled, comparison operators names (eq;ne;le;lt;ge;gt) will be treated as plain identifiers.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
- Since:
- 3.3
-
supportsComparatorNames
public boolean supportsComparatorNames()- Returns:
- true if legacy comparison operator names syntax is enabled, false otherwise
- Since:
- 3.3
-
pragma
Sets whether pragma constructs are enabled.When disabled, parsing a script/expression using syntactic pragma constructs (#pragma) will throw a parsing exception.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
-
supportsPragma
public boolean supportsPragma()- Returns:
- true if namespace pragma are enabled, false otherwise
-
pragmaAnywhere
Sets whether pragma constructs can appear anywhere in the code.- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
- Since:
- 3.3
-
supportsPragmaAnywhere
public boolean supportsPragmaAnywhere()- Returns:
- true if pragma constructs can appear anywhere in the code, false otherwise
- Since:
- 3.3
-
namespacePragma
Sets whether namespace pragma constructs are enabled.When disabled, parsing a script/expression using syntactic namespace pragma constructs (#pragma jexl.namespace....) will throw a parsing exception.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
- Since:
- 3.3
-
supportsNamespacePragma
public boolean supportsNamespacePragma()- Returns:
- true if namespace pragma are enabled, false otherwise
- Since:
- 3.3
-
importPragma
Sets whether import pragma constructs are enabled.When disabled, parsing a script/expression using syntactic import pragma constructs (#pragma jexl.import....) will throw a parsing exception.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
- Since:
- 3.3
-
supportsImportPragma
public boolean supportsImportPragma()- Returns:
- true if import pragma are enabled, false otherwise
- Since:
- 3.3
-
annotation
Sets whether annotation constructs are enabled.When disabled, parsing a script/expression using syntactic annotation constructs (@annotation) will throw a parsing exception.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
-
supportsAnnotation
public boolean supportsAnnotation()- Returns:
- true if annotation are enabled, false otherwise
-
script
Sets whether scripts constructs are enabled.When disabled, parsing a script using syntactic script constructs (statements, ...) will throw a parsing exception.
- Parameters:
flag
- true to enable, false to disable- Returns:
- this features instance
-
supportsScript
public boolean supportsScript()- Returns:
- true if scripts are enabled, false otherwise
-
supportsExpression
public boolean supportsExpression()- Returns:
- true if expressions (aka not scripts) are enabled, false otherwise
-
lexical
Sets whether syntactic lexical mode is enabled.- Parameters:
flag
- true means syntactic lexical function scope is in effect, false implies non-lexical scoping- Returns:
- this features instance
-
isLexical
public boolean isLexical()- Returns:
- whether lexical scope feature is enabled
-
lexicalShade
Sets whether syntactic lexical shade is enabled.- Parameters:
flag
- true means syntactic lexical shade is in effect and implies lexical scope- Returns:
- this features instance
-
isLexicalShade
public boolean isLexicalShade()- Returns:
- whether lexical shade feature is enabled
-