Class JexlFeatures
These control syntactical constructs that will throw JexlException.Feature exceptions (a subclass of JexlException.Parsing) when disabled.
It is recommended to be explicit in choosing the features you need rather than rely on the default
 constructor: the 2 convenience methods createNone() and createAll()
 are the recommended starting points to selectively enable or disable chosen features.
- Registers: register syntax (#number), used internally for {g,s}etProperty
- Reserved Names: a set of reserved variable names that cannot 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 namespacesyntax is allowed
- Namespace identifier: whether the ns:fun(...)parser treats the ns:fun as one identifier, no spaces allowed
- Import pragma: whether the #pragma jexl.import fully.qualified.class.namesyntax is allowed
- Comparator names: whether the comparator operator names can be used (as in gtfor >,ltfor <, ...)
- 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.
- Const Capture: whether variables captured by lambdas are read-only (aka const, same as Java) or read-write.
- Reference Capture: whether variables captured by lambdas are pass-by-reference or pass-by-value.
- Since:
- 3.2
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intAnnotation feature ordinal.static final intExpressions allowed in array reference ordinal.static final intComparator names (legacy) syntax.static final intCaptured variables are const.static final intFat-arrow lambda syntax.static final intImport pragma feature ordinal.static final intLambda feature ordinal.static final intLexical feature ordinal.static final intLexical shade feature ordinal.static final intLocals feature ordinal.static final intLoops feature ordinal.static final intLambda feature ordinal.static final intNew-instance feature ordinal.static final intNamespace syntax as an identifier (no space).static final intNamespace pragma feature ordinal.static final intPragma feature ordinal.static final intThe pragma anywhere feature ordinal.static final intCaptured variables are reference.static final intReserved future feature ordinal (unused as of 3.3.1).static final intScript feature ordinal.static final intSide effects feature ordinal.static final intGlobal side effects feature ordinal.static final intCaptured variables are reference.static final intStructured literal feature ordinal.The false predicate.static final intThin-arrow lambda syntax.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionCreates default instance, equivalent to the result of calling the preferred alternativecreateDefault()protectedJexlFeatures(long f, Set<String> r, Predicate<String> n) An all member constructor for derivation.JexlFeatures(JexlFeatures features) Copy constructor.
- 
Method SummaryModifier 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.constCapture(boolean flag) Sets whether lambda captured-variables are constant or mutable.static JexlFeaturesCreates an all features enabled set.static JexlFeaturesCreates a default features set suitable for basic but complete scripting needs.static JexlFeaturesCreates an empty feature set.static JexlFeaturesThe modern scripting features set.booleanfatArrow(boolean flag) Sets whether fat-arrow lambda syntax is enabled.longgetFlags()Gets the feature flagsGets the immutable set of reserved names.inthashCode()importPragma(boolean flag) Sets whether import pragma constructs are enabled.booleanIs the lexical scope feature enabled?booleanIs the lexical shade feature enabled?booleanisReservedName(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.namespaceIdentifier(boolean flag) Sets whether namespace as identifier syntax is enabled.namespacePragma(boolean flag) Sets whether namespace pragma constructs are enabled.Gets the declared namespaces test.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.referenceCapture(boolean flag) Sets whether lambda captured-variables are references or values.register(boolean flag) Sets whether register are enabled.reservedNames(Collection<String> names) Sets a collection of reserved r precluding those to be used as local variables or parameter r.script(boolean flag) Sets whether scripts constructs are enabled.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 Stringstringify(int feature) The text corresponding to a feature code.structuredLiteral(boolean flag) Sets whether array/map/set literal expressions are enabled.booleanDoes the engine support annotations?booleanDoes the engine support array references which contain method call expressions?booleanDoes the engine support legacy comparison operator names syntax?booleanDoes the engine support lambda captured-variables as const?booleanDoes the engine support expressions (aka not scripts)booleanDoes the engine support fat-arrow lambda syntax?booleanDoes the engine support import pragma?booleanDoes the engine support lambdas?booleanIs local variables syntax enabled?booleanAre loops enabled?booleanCan array references contain expressions?booleanIs namespace identifier syntax enabled?booleanIs namespace pragma enabled?booleanIs creating new instances enabled?booleanIs the namespace pragma enabled?booleanCan pragma constructs appear anywhere in the code?booleanDoes the engine support lambda captured-variables as references?booleanIs register syntax enabled?booleanAre scripts enabled?booleanAre side effects enabled?booleanCan global variables be assigned?booleanAre array/map/set literal expressions supported?booleanIs thin-arrow lambda syntax enabled?thinArrow(boolean flag) Sets whether thin-arrow lambda syntax is enabled.
- 
Field Details- 
TEST_STR_FALSEThe false predicate.
- 
RESERVEDReserved future feature ordinal (unused as of 3.3.1).- See Also:
 
- 
LOCAL_VARLocals feature ordinal.- See Also:
 
- 
SIDE_EFFECTSide effects feature ordinal.- See Also:
 
- 
SIDE_EFFECT_GLOBALGlobal side effects feature ordinal.- See Also:
 
- 
ARRAY_REF_EXPRExpressions allowed in array reference ordinal.- See Also:
 
- 
NEW_INSTANCENew-instance feature ordinal.- See Also:
 
- 
LOOPLoops feature ordinal.- See Also:
 
- 
LAMBDALambda feature ordinal.- See Also:
 
- 
METHOD_CALLLambda feature ordinal.- See Also:
 
- 
STRUCTURED_LITERALStructured literal feature ordinal.- See Also:
 
- 
PRAGMAPragma feature ordinal.- See Also:
 
- 
ANNOTATIONAnnotation feature ordinal.- See Also:
 
- 
SCRIPTScript feature ordinal.- See Also:
 
- 
LEXICALLexical feature ordinal.- See Also:
 
- 
LEXICAL_SHADELexical shade feature ordinal.- See Also:
 
- 
THIN_ARROWThin-arrow lambda syntax.- See Also:
 
- 
FAT_ARROWFat-arrow lambda syntax.- See Also:
 
- 
NS_PRAGMANamespace pragma feature ordinal.- See Also:
 
- 
NS_IDENTIFIERNamespace syntax as an identifier (no space).- See Also:
 
- 
IMPORT_PRAGMAImport pragma feature ordinal.- See Also:
 
- 
COMPARATOR_NAMESComparator names (legacy) syntax.- See Also:
 
- 
PRAGMA_ANYWHEREThe pragma anywhere feature ordinal.- See Also:
 
- 
CONST_CAPTURECaptured variables are const.- See Also:
 
- 
REF_CAPTURECaptured variables are reference.- See Also:
 
- 
STRICT_STATEMENTCaptured variables are reference.- See Also:
 
 
- 
- 
Constructor Details- 
JexlFeaturespublic JexlFeatures()Creates default instance, equivalent to the result of calling the preferred alternativecreateDefault()
- 
JexlFeaturesCopy constructor.- Parameters:
- features- the feature to copy from
 
- 
JexlFeaturesAn all member constructor for derivation.Not respecting immutability or thread-safety constraints for this class constructor arguments will likely result in unexpected behavior. - Parameters:
- f- flag
- r- reserved variable names; must be an immutable Set or thread-safe (concurrent or synchronized set)
- n- namespace predicate; must be stateless or thread-safe
 
 
- 
- 
Method Details- 
createAllCreates an all features enabled set.- Returns:
- a new instance of all features set
- Since:
- 3.3.1
 
- 
createDefaultCreates a default features set suitable for basic but complete scripting needs.Maximizes compatibility with older version scripts (before 3.3), new projects should use createScript()or equivalent features as a base.The following scripting features are enabled: - local variable, supportsLocalVar()
- side effect, supportsSideEffect()
- global side effect, supportsSideEffectGlobal()
- array reference expression, supportsStructuredLiteral()
- new instance, supportsNewInstance()
- loop, supportsLoops()
- lambda, supportsLambda()
- method call, supportsMethodCall()
- structured literal, supportsStructuredLiteral()
- pragma, supportsPragma()
- annotation, supportsAnnotation()
- script, supportsScript()
- comparator names,  supportsComparatorNames()
- namespace pragma,  supportsNamespacePragma()
- import pragma, supportsImportPragma()
- pragma anywhere, supportsPragmaAnywhere()
 - Returns:
- a new instance of a default scripting features set
- Since:
- 3.3.1
 
- local variable, 
- 
createNoneCreates an empty feature set.This is the strictest base-set since no feature is allowed, suitable as-is only for the simplest expressions. - Returns:
- a new instance of an empty features set
- Since:
- 3.3.1
 
- 
createScriptThe modern scripting features set.This is the recommended set for new projects. All default features with the following differences: - disable pragma-anywhere, supportsPragmaAnywhere()
- disable comparator-names, supportsComparatorNames()
- enable lexical, isLexical()
- enable lexical-shade, isLexicalShade()
- enable const-capture, supportsConstCapture()
 It also adds a set of reserved words to enable future unencumbered syntax evolution: try, catch, throw, finally, switch, case, default, class, instanceof - Returns:
- a new instance of a modern scripting features set
- Since:
- 3.3.1
 
- disable pragma-anywhere, 
- 
stringifyThe text corresponding to a feature code.- Parameters:
- feature- the feature number
- Returns:
- the feature name
 
- 
annotationSets 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
 
- 
arrayReferenceExprSets 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
 
- 
comparatorNamesSets 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
 
- 
constCaptureSets whether lambda captured-variables are constant or mutable.When disabled, lambda-captured variables are implicitly converted to read-write local variable (let), when enabled, those are implicitly converted to read-only local variables (const). - Parameters:
- flag- true to enable, false to disable
- Returns:
- this features instance
 
- 
referenceCaptureSets whether lambda captured-variables are references or values.When variables are pass-by-reference, side-effects are visible from inner lexical scopes to outer-scope. When disabled, lambda-captured variables use pass-by-value semantic, when enabled, those use pass-by-reference semantic. - Parameters:
- flag- true to enable, false to disable
- Returns:
- this features instance
 
- 
equals
- 
fatArrowSets 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
 
- 
getFlagsGets the feature flags- Returns:
- these features"s flags
 
- 
getReservedNamesGets the immutable set of reserved names.- Returns:
- the (unmodifiable) set of reserved names.
 
- 
hashCode
- 
importPragmaSets 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
 
- 
isLexicalIs the lexical scope feature enabled?- Returns:
- whether lexical scope feature is enabled
 
- 
isLexicalShadeIs the lexical shade feature enabled?- Returns:
- whether lexical shade feature is enabled
 
- 
isReservedNameChecks whether a name is reserved.- Parameters:
- name- the name to check
- Returns:
- true if reserved, false otherwise
 
- 
lambdaSets 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
 
- 
lexicalSets 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
 
- 
lexicalShadeSets whether syntactic lexical shade is enabled.- Parameters:
- flag- true means syntactic lexical shade is in effect and implies lexical scope
- Returns:
- this features instance
 
- 
localVarSets 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
 
- 
loopsSets 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
 
- 
methodCallSets 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
 
- 
namespacePragmaSets 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
 
- 
namespaceIdentifierSets whether namespace as identifier syntax is enabled.When enabled, a namespace call must be of the form ns:fun(...)with no spaces between the namespace name and the function.- Parameters:
- flag- true to enable, false to disable
- Returns:
- this features instance
- Since:
- 3.5.0
 
- 
namespaceTestGets the declared namespaces test.- Returns:
- the declared namespaces test.
 
- 
namespaceTestSets a test to determine namespace declaration.- Parameters:
- names- the name predicate
- Returns:
- this features instance
 
- 
newInstanceSets 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
 
- 
pragmaSets 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
 
- 
pragmaAnywhereSets whether pragma constructs can appear anywhere in the code.- Parameters:
- flag- true to enable, false to disable
- Returns:
- this features instance
- Since:
- 3.3
 
- 
registerSets 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
 
- 
reservedNamesSets a collection of reserved r precluding those to be used as local variables or parameter r.- Parameters:
- names- the r to reserve
- Returns:
- this features instance
 
- 
scriptSets 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
 
- 
sideEffectSets 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
 
- 
sideEffectGlobalSets 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
 
- 
structuredLiteralSets 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
 
- 
supportsAnnotationDoes the engine support annotations?- Returns:
- true if annotation are enabled, false otherwise
 
- 
supportsArrayReferenceExprDoes the engine support array references which contain method call expressions?- Returns:
- true if array references can contain method call expressions, false otherwise
 
- 
supportsComparatorNamesDoes the engine support legacy comparison operator names syntax?- Returns:
- true if legacy comparison operator names syntax is enabled, false otherwise
- Since:
- 3.3
 
- 
supportsConstCaptureDoes the engine support lambda captured-variables as const?- Returns:
- true if lambda captured-variables are const, false otherwise
 
- 
supportsReferenceCaptureDoes the engine support lambda captured-variables as references?- Returns:
- true if lambda captured-variables are references, false otherwise
 
- 
supportsExpressionDoes the engine support expressions (aka not scripts)- Returns:
- true if expressions (aka not scripts) are enabled, false otherwise
 
- 
supportsFatArrowDoes the engine support fat-arrow lambda syntax?- Returns:
- true if fat-arrow lambda syntax is enabled, false otherwise
- Since:
- 3.3
 
- 
supportsImportPragmaDoes the engine support import pragma?- Returns:
- true if import pragma are enabled, false otherwise
- Since:
- 3.3
 
- 
supportsLambdaDoes the engine support lambdas?- Returns:
- true if lambda are enabled, false otherwise
 
- 
supportsLocalVarIs local variables syntax enabled?- Returns:
- true if local variables syntax is enabled
 
- 
supportsLoopsAre loops enabled?- Returns:
- true if loops are enabled, false otherwise
 
- 
supportsMethodCallCan array references contain expressions?- Returns:
- true if array references can contain expressions, false otherwise
 
- 
supportsNamespacePragmaIs namespace pragma enabled?- Returns:
- true if namespace pragma are enabled, false otherwise
- Since:
- 3.3
 
- 
supportsNamespaceIdentifierIs namespace identifier syntax enabled?- Returns:
- true if namespace identifier syntax is enabled, false otherwise
- Since:
- 3.5.0
 
- 
supportsNewInstanceIs creating new instances enabled?- Returns:
- true if creating new instances is enabled, false otherwise
 
- 
supportsPragmaIs the namespace pragma enabled?- Returns:
- true if namespace pragma are enabled, false otherwise
 
- 
supportsPragmaAnywhereCan pragma constructs appear anywhere in the code?- Returns:
- true if pragma constructs can appear anywhere in the code, false otherwise
- Since:
- 3.3
 
- 
supportsRegisterIs register syntax enabled?- Returns:
- true if register syntax is enabled
 
- 
supportsScriptAre scripts enabled?- Returns:
- true if scripts are enabled, false otherwise
 
- 
supportsSideEffectAre side effects enabled?- Returns:
- true if side effects are enabled, false otherwise
 
- 
supportsSideEffectGlobalCan global variables be assigned?- Returns:
- true if global variables can be assigned
 
- 
supportsStructuredLiteralAre array/map/set literal expressions supported?- Returns:
- true if array/map/set literal expressions are supported, false otherwise
 
- 
supportsThinArrowIs thin-arrow lambda syntax enabled?- Returns:
- true if thin-arrow lambda syntax is enabled, false otherwise
- Since:
- 3.3
 
- 
thinArrowSets 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
 
 
-