Class JexlFeatures
- java.lang.Object
-
- org.apache.commons.jexl3.JexlFeatures
-
public final class JexlFeatures extends java.lang.ObjectA set of language feature options.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()andcreateAll()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 Summary
Fields Modifier and Type Field Description private static longALL_FEATURESAll features.static intAMBIGUOUS_STATEMENTAmbiguous or strict statement allowed.static intANNOTATIONAnnotation feature ordinal.static intARRAY_REF_EXPRExpressions allowed in array reference ordinal.static intCOMPARATOR_NAMESComparator names (legacy) syntax.static intCONST_CAPTURECaptured variables are const.private static longDEFAULT_FEATURESThe default features flag mask.private static java.lang.String[]F_NAMESTe feature names (for toString()).static intFAT_ARROWFat-arrow lambda syntax.private longflagsThe feature flags.static intIMPORT_PRAGMAImport pragma feature ordinal.static intLAMBDALambda feature ordinal.static intLEXICALLexical feature ordinal.static intLEXICAL_SHADELexical shade feature ordinal.static intLOCAL_VARLocals feature ordinal.static intLOOPLoops feature ordinal.static intMETHOD_CALLLambda feature ordinal.private java.util.function.Predicate<java.lang.String>nameSpacesThe namespace names.static intNEW_INSTANCENew-instance feature ordinal.static intNS_IDENTIFIERNamespace syntax as an identifier (no space).static intNS_PRAGMANamespace pragma feature ordinal.static intPRAGMAPragma feature ordinal.static intPRAGMA_ANYWHEREThe pragma anywhere feature ordinal.static intREF_CAPTURECaptured variables are reference.private static intREGISTERRegisters feature ordinal.static intRESERVEDReserved future feature ordinal (unused as of 3.3.1).private static java.util.Set<java.lang.String>RESERVED_WORDSProtected future syntactic elements.private java.util.Set<java.lang.String>reservedNamesThe set of reserved names, aka global variables that cannot be masked by local variables or parameters.static intSCRIPTScript feature ordinal.private static longSCRIPT_FEATURESThe canonical scripting (since 3.3.1) features flag mask based on the original default.static intSIDE_EFFECTSide effects feature ordinal.static intSIDE_EFFECT_GLOBALGlobal side effects feature ordinal.static intSTRICT_STATEMENTDeprecated.3.6static intSTRUCTURED_LITERALStructured literal feature ordinal.static java.util.function.Predicate<java.lang.String>TEST_STR_FALSEThe false predicate.static intTHIN_ARROWThin-arrow lambda syntax.
-
Constructor Summary
Constructors Modifier Constructor Description JexlFeatures()Creates default instance, equivalent to the result of calling the preferred alternativecreateDefault()protectedJexlFeatures(long f, java.util.Set<java.lang.String> r, java.util.function.Predicate<java.lang.String> n)An all member constructor for derivation.JexlFeatures(JexlFeatures features)Copy constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JexlFeaturesambiguousStatement(boolean flag)Sets whether statements can be ambiguous.JexlFeaturesannotation(boolean flag)Sets whether annotation constructs are enabled.JexlFeaturesarrayReferenceExpr(boolean flag)Sets whether array references expressions are enabled.JexlFeaturescomparatorNames(boolean flag)Sets whether the legacy comparison operator names syntax is enabled.JexlFeaturesconstCapture(boolean flag)Sets whether lambda captured-variables are constant or mutable.static JexlFeaturescreateAll()Creates an all features enabled set.static JexlFeaturescreateDefault()Creates a default features set suitable for basic but complete scripting needs.static JexlFeaturescreateNone()Creates an empty feature set.static JexlFeaturescreateScript()The modern scripting features set.booleanequals(java.lang.Object obj)JexlFeaturesfatArrow(boolean flag)Sets whether fat-arrow lambda syntax is enabled.private booleangetFeature(int feature)Gets a feature flag value.longgetFlags()Gets the feature flagsjava.util.Set<java.lang.String>getReservedNames()Gets the immutable set of reserved names.inthashCode()JexlFeaturesimportPragma(boolean flag)Sets whether import pragma constructs are enabled.booleanisLexical()Is the lexical scope feature enabled?booleanisLexicalShade()Is the lexical shade feature enabled?booleanisReservedName(java.lang.String name)Checks whether a name is reserved.JexlFeatureslambda(boolean flag)Sets whether lambda/function constructs are enabled.JexlFeatureslexical(boolean flag)Sets whether syntactic lexical mode is enabled.JexlFeatureslexicalShade(boolean flag)Sets whether syntactic lexical shade is enabled.JexlFeatureslocalVar(boolean flag)Sets whether local variables are enabled.JexlFeaturesloops(boolean flag)Sets whether looping constructs are enabled.JexlFeaturesmethodCall(boolean flag)Sets whether method calls expressions are enabled.JexlFeaturesnamespaceIdentifier(boolean flag)Sets whether namespace as identifier syntax is enabled.JexlFeaturesnamespacePragma(boolean flag)Sets whether namespace pragma constructs are enabled.java.util.function.Predicate<java.lang.String>namespaceTest()Gets the declared namespaces test.JexlFeaturesnamespaceTest(java.util.function.Predicate<java.lang.String> names)Sets a test to determine namespace declaration.JexlFeaturesnewInstance(boolean flag)Sets whether creating new instances is enabled.JexlFeaturespragma(boolean flag)Sets whether pragma constructs are enabled.JexlFeaturespragmaAnywhere(boolean flag)Sets whether pragma constructs can appear anywhere in the code.JexlFeaturesreferenceCapture(boolean flag)Sets whether lambda captured-variables are references or values.JexlFeaturesregister(boolean flag)Sets whether register are enabled.JexlFeaturesreservedNames(java.util.Collection<java.lang.String> names)Sets a collection of reserved r precluding those to be used as local variables or parameter r.JexlFeaturesscript(boolean flag)Sets whether scripts constructs are enabled.private voidsetFeature(int feature, boolean flag)Sets a feature flag.JexlFeaturessideEffect(boolean flag)Sets whether side effect expressions are enabled.JexlFeaturessideEffectGlobal(boolean flag)Sets whether side effect expressions on global variables (aka non-local) are enabled.static java.lang.Stringstringify(int feature)The text corresponding to a feature code.JexlFeaturesstructuredLiteral(boolean flag)Sets whether array/map/set literal expressions are enabled.booleansupportsAmbiguousStatement()Checks whether statements can be ambiguous.booleansupportsAnnotation()Does the engine support annotations?booleansupportsArrayReferenceExpr()Does the engine support array references which contain method call expressions?booleansupportsComparatorNames()Does the engine support legacy comparison operator names syntax?booleansupportsConstCapture()Does the engine support lambda captured-variables as const?booleansupportsExpression()Does the engine support expressions (aka not scripts)booleansupportsFatArrow()Does the engine support fat-arrow lambda syntax?booleansupportsImportPragma()Does the engine support import pragma?booleansupportsLambda()Does the engine support lambdas?booleansupportsLocalVar()Is local variables syntax enabled?booleansupportsLoops()Are loops enabled?booleansupportsMethodCall()Can array references contain expressions?booleansupportsNamespaceIdentifier()Is namespace identifier syntax enabled?booleansupportsNamespacePragma()Is namespace pragma enabled?booleansupportsNewInstance()Is creating new instances enabled?booleansupportsPragma()Is the namespace pragma enabled?booleansupportsPragmaAnywhere()Can pragma constructs appear anywhere in the code?booleansupportsReferenceCapture()Does the engine support lambda captured-variables as references?booleansupportsRegister()Is register syntax enabled?booleansupportsScript()Are scripts enabled?booleansupportsSideEffect()Are side effects enabled?booleansupportsSideEffectGlobal()Can global variables be assigned?booleansupportsStructuredLiteral()Are array/map/set literal expressions supported?booleansupportsThinArrow()Is thin-arrow lambda syntax enabled?JexlFeaturesthinArrow(boolean flag)Sets whether thin-arrow lambda syntax is enabled.
-
-
-
Field Detail
-
TEST_STR_FALSE
public static final java.util.function.Predicate<java.lang.String> TEST_STR_FALSE
The false predicate.
-
F_NAMES
private static final java.lang.String[] F_NAMES
Te feature names (for toString()).
-
REGISTER
private static final int REGISTER
Registers feature ordinal.- See Also:
- Constant Field Values
-
RESERVED
public static final int RESERVED
Reserved future feature ordinal (unused as of 3.3.1).- See Also:
- Constant Field Values
-
LOCAL_VAR
public static final int LOCAL_VAR
Locals feature ordinal.- See Also:
- Constant Field Values
-
SIDE_EFFECT
public static final int SIDE_EFFECT
Side effects feature ordinal.- See Also:
- Constant Field Values
-
SIDE_EFFECT_GLOBAL
public static final int SIDE_EFFECT_GLOBAL
Global side effects feature ordinal.- See Also:
- Constant Field Values
-
ARRAY_REF_EXPR
public static final int ARRAY_REF_EXPR
Expressions allowed in array reference ordinal.- See Also:
- Constant Field Values
-
NEW_INSTANCE
public static final int NEW_INSTANCE
New-instance feature ordinal.- See Also:
- Constant Field Values
-
LOOP
public static final int LOOP
Loops feature ordinal.- See Also:
- Constant Field Values
-
LAMBDA
public static final int LAMBDA
Lambda feature ordinal.- See Also:
- Constant Field Values
-
METHOD_CALL
public static final int METHOD_CALL
Lambda feature ordinal.- See Also:
- Constant Field Values
-
STRUCTURED_LITERAL
public static final int STRUCTURED_LITERAL
Structured literal feature ordinal.- See Also:
- Constant Field Values
-
PRAGMA
public static final int PRAGMA
Pragma feature ordinal.- See Also:
- Constant Field Values
-
ANNOTATION
public static final int ANNOTATION
Annotation feature ordinal.- See Also:
- Constant Field Values
-
SCRIPT
public static final int SCRIPT
Script feature ordinal.- See Also:
- Constant Field Values
-
LEXICAL
public static final int LEXICAL
Lexical feature ordinal.- See Also:
- Constant Field Values
-
LEXICAL_SHADE
public static final int LEXICAL_SHADE
Lexical shade feature ordinal.- See Also:
- Constant Field Values
-
THIN_ARROW
public static final int THIN_ARROW
Thin-arrow lambda syntax.- See Also:
- Constant Field Values
-
FAT_ARROW
public static final int FAT_ARROW
Fat-arrow lambda syntax.- See Also:
- Constant Field Values
-
NS_PRAGMA
public static final int NS_PRAGMA
Namespace pragma feature ordinal.- See Also:
- Constant Field Values
-
NS_IDENTIFIER
public static final int NS_IDENTIFIER
Namespace syntax as an identifier (no space).- See Also:
- Constant Field Values
-
IMPORT_PRAGMA
public static final int IMPORT_PRAGMA
Import pragma feature ordinal.- See Also:
- Constant Field Values
-
COMPARATOR_NAMES
public static final int COMPARATOR_NAMES
Comparator names (legacy) syntax.- See Also:
- Constant Field Values
-
PRAGMA_ANYWHERE
public static final int PRAGMA_ANYWHERE
The pragma anywhere feature ordinal.- See Also:
- Constant Field Values
-
CONST_CAPTURE
public static final int CONST_CAPTURE
Captured variables are const.- See Also:
- Constant Field Values
-
REF_CAPTURE
public static final int REF_CAPTURE
Captured variables are reference.- See Also:
- Constant Field Values
-
AMBIGUOUS_STATEMENT
public static final int AMBIGUOUS_STATEMENT
Ambiguous or strict statement allowed.- See Also:
- Constant Field Values
-
STRICT_STATEMENT
@Deprecated public static final int STRICT_STATEMENT
Deprecated.3.6Bad naming, use AMBIGUOUS_STATEMENT.- See Also:
- Constant Field Values
-
ALL_FEATURES
private static final long ALL_FEATURES
All features. Ensure this is updated if additional features are added.- See Also:
- Constant Field Values
-
DEFAULT_FEATURES
private static final long DEFAULT_FEATURES
The default features flag mask.Meant for compatibility with scripts written before 3.3.1
- See Also:
- Constant Field Values
-
SCRIPT_FEATURES
private static final long SCRIPT_FEATURES
The canonical scripting (since 3.3.1) features flag mask based on the original default.Adds lexical, lexical-shade and const-capture but removes comparator-names and pragma-anywhere
- See Also:
- Constant Field Values
-
RESERVED_WORDS
private static final java.util.Set<java.lang.String> RESERVED_WORDS
Protected future syntactic elements.class, jexl, $jexl
- Since:
- 3.3.1
-
flags
private long flags
The feature flags.
-
reservedNames
private java.util.Set<java.lang.String> reservedNames
The set of reserved names, aka global variables that cannot be masked by local variables or parameters.
-
nameSpaces
private java.util.function.Predicate<java.lang.String> nameSpaces
The namespace names.
-
-
Constructor Detail
-
JexlFeatures
public JexlFeatures()
Creates default instance, equivalent to the result of calling the preferred alternativecreateDefault()
-
JexlFeatures
public JexlFeatures(JexlFeatures features)
Copy constructor.- Parameters:
features- the feature to copy from
-
JexlFeatures
protected JexlFeatures(long f, java.util.Set<java.lang.String> r, java.util.function.Predicate<java.lang.String> n)An 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- flagr- 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 Detail
-
createAll
public static JexlFeatures createAll()
Creates an all features enabled set.- Returns:
- a new instance of all features set
- Since:
- 3.3.1
-
createDefault
public static JexlFeatures createDefault()
Creates 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,
-
createNone
public static JexlFeatures createNone()
Creates 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
-
createScript
public static JexlFeatures createScript()
The 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,
-
stringify
public static java.lang.String stringify(int feature)
The text corresponding to a feature code.- Parameters:
feature- the feature number- Returns:
- the feature name
-
annotation
public JexlFeatures annotation(boolean flag)
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
-
arrayReferenceExpr
public JexlFeatures arrayReferenceExpr(boolean flag)
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
-
comparatorNames
public JexlFeatures comparatorNames(boolean flag)
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
-
constCapture
public JexlFeatures constCapture(boolean flag)
Sets 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
-
referenceCapture
public JexlFeatures referenceCapture(boolean flag)
Sets 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
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
fatArrow
public JexlFeatures fatArrow(boolean flag)
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
-
getFeature
private boolean getFeature(int feature)
Gets a feature flag value.- Parameters:
feature- feature ordinal- Returns:
- true if on, false if off
-
getFlags
public long getFlags()
Gets the feature flags- Returns:
- these features"s flags
-
getReservedNames
public java.util.Set<java.lang.String> getReservedNames()
Gets the immutable set of reserved names.- Returns:
- the (unmodifiable) set of reserved names.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
importPragma
public JexlFeatures importPragma(boolean flag)
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
-
isLexical
public boolean isLexical()
Is the lexical scope feature enabled?- Returns:
- whether lexical scope feature is enabled
-
isLexicalShade
public boolean isLexicalShade()
Is the lexical shade feature enabled?- Returns:
- whether lexical shade feature is enabled
-
isReservedName
public boolean isReservedName(java.lang.String name)
Checks whether a name is reserved.- Parameters:
name- the name to check- Returns:
- true if reserved, false otherwise
-
lambda
public JexlFeatures lambda(boolean flag)
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
-
lexical
public JexlFeatures lexical(boolean flag)
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
-
lexicalShade
public JexlFeatures lexicalShade(boolean flag)
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
-
localVar
public JexlFeatures localVar(boolean flag)
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
-
loops
public JexlFeatures loops(boolean flag)
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
-
methodCall
public JexlFeatures methodCall(boolean flag)
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
-
namespacePragma
public JexlFeatures namespacePragma(boolean flag)
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
-
namespaceIdentifier
public JexlFeatures namespaceIdentifier(boolean flag)
Sets 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
-
namespaceTest
public java.util.function.Predicate<java.lang.String> namespaceTest()
Gets the declared namespaces test.- Returns:
- the declared namespaces test.
-
namespaceTest
public JexlFeatures namespaceTest(java.util.function.Predicate<java.lang.String> names)
Sets a test to determine namespace declaration.- Parameters:
names- the name predicate- Returns:
- this features instance
-
newInstance
public JexlFeatures newInstance(boolean flag)
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
-
pragma
public JexlFeatures pragma(boolean flag)
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
-
pragmaAnywhere
public JexlFeatures pragmaAnywhere(boolean flag)
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
-
register
public JexlFeatures register(boolean flag)
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
-
reservedNames
public JexlFeatures reservedNames(java.util.Collection<java.lang.String> names)
Sets 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
-
script
public JexlFeatures script(boolean flag)
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
-
setFeature
private void setFeature(int feature, boolean flag)Sets a feature flag.- Parameters:
feature- the feature ordinalflag- turn-on, turn off
-
ambiguousStatement
public JexlFeatures ambiguousStatement(boolean flag)
Sets whether statements can be ambiguous.When enabled, the semicolumn is not required between expressions that otherwise are considered ambiguous. The default will report ambiguity in cases like
if (true) { x 5 }considering this may be missing an operator or that the intent is not clear.- Parameters:
flag- true to enable, false to disable- Returns:
- this features instance
-
supportsAmbiguousStatement
public boolean supportsAmbiguousStatement()
Checks whether statements can be ambiguous.When enabled, the semicolumn is not required between expressions that otherwise are considered ambiguous. The default will report ambiguity in cases like
if (true) { x 5 }considering this may be missing an operator or that the intent is not clear.- Returns:
- true if statements can be ambiguous, false otherwise
-
sideEffect
public JexlFeatures sideEffect(boolean flag)
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
-
sideEffectGlobal
public JexlFeatures sideEffectGlobal(boolean flag)
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
-
structuredLiteral
public JexlFeatures structuredLiteral(boolean flag)
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
-
supportsAnnotation
public boolean supportsAnnotation()
Does the engine support annotations?- Returns:
- true if annotation are enabled, false otherwise
-
supportsArrayReferenceExpr
public boolean supportsArrayReferenceExpr()
Does the engine support array references which contain method call expressions?- Returns:
- true if array references can contain method call expressions, false otherwise
-
supportsComparatorNames
public boolean supportsComparatorNames()
Does the engine support legacy comparison operator names syntax?- Returns:
- true if legacy comparison operator names syntax is enabled, false otherwise
- Since:
- 3.3
-
supportsConstCapture
public boolean supportsConstCapture()
Does the engine support lambda captured-variables as const?- Returns:
- true if lambda captured-variables are const, false otherwise
-
supportsReferenceCapture
public boolean supportsReferenceCapture()
Does the engine support lambda captured-variables as references?- Returns:
- true if lambda captured-variables are references, false otherwise
-
supportsExpression
public boolean supportsExpression()
Does the engine support expressions (aka not scripts)- Returns:
- true if expressions (aka not scripts) are enabled, false otherwise
-
supportsFatArrow
public boolean supportsFatArrow()
Does the engine support fat-arrow lambda syntax?- Returns:
- true if fat-arrow lambda syntax is enabled, false otherwise
- Since:
- 3.3
-
supportsImportPragma
public boolean supportsImportPragma()
Does the engine support import pragma?- Returns:
- true if import pragma are enabled, false otherwise
- Since:
- 3.3
-
supportsLambda
public boolean supportsLambda()
Does the engine support lambdas?- Returns:
- true if lambda are enabled, false otherwise
-
supportsLocalVar
public boolean supportsLocalVar()
Is local variables syntax enabled?- Returns:
- true if local variables syntax is enabled
-
supportsLoops
public boolean supportsLoops()
Are loops enabled?- Returns:
- true if loops are enabled, false otherwise
-
supportsMethodCall
public boolean supportsMethodCall()
Can array references contain expressions?- Returns:
- true if array references can contain expressions, false otherwise
-
supportsNamespacePragma
public boolean supportsNamespacePragma()
Is namespace pragma enabled?- Returns:
- true if namespace pragma are enabled, false otherwise
- Since:
- 3.3
-
supportsNamespaceIdentifier
public boolean supportsNamespaceIdentifier()
Is namespace identifier syntax enabled?- Returns:
- true if namespace identifier syntax is enabled, false otherwise
- Since:
- 3.5.0
-
supportsNewInstance
public boolean supportsNewInstance()
Is creating new instances enabled?- Returns:
- true if creating new instances is enabled, false otherwise
-
supportsPragma
public boolean supportsPragma()
Is the namespace pragma enabled?- Returns:
- true if namespace pragma are enabled, false otherwise
-
supportsPragmaAnywhere
public boolean supportsPragmaAnywhere()
Can pragma constructs appear anywhere in the code?- Returns:
- true if pragma constructs can appear anywhere in the code, false otherwise
- Since:
- 3.3
-
supportsRegister
public boolean supportsRegister()
Is register syntax enabled?- Returns:
- true if register syntax is enabled
-
supportsScript
public boolean supportsScript()
Are scripts enabled?- Returns:
- true if scripts are enabled, false otherwise
-
supportsSideEffect
public boolean supportsSideEffect()
Are side effects enabled?- Returns:
- true if side effects are enabled, false otherwise
-
supportsSideEffectGlobal
public boolean supportsSideEffectGlobal()
Can global variables be assigned?- Returns:
- true if global variables can be assigned
-
supportsStructuredLiteral
public boolean supportsStructuredLiteral()
Are array/map/set literal expressions supported?- Returns:
- true if array/map/set literal expressions are supported, false otherwise
-
supportsThinArrow
public boolean supportsThinArrow()
Is thin-arrow lambda syntax enabled?- Returns:
- true if thin-arrow lambda syntax is enabled, false otherwise
- Since:
- 3.3
-
thinArrow
public JexlFeatures thinArrow(boolean flag)
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
-
-