org.apache.commons.jexl3

## Class JexlFeatures

- java.lang.Object
- - org.apache.commons.jexl3.JexlFeatures

-     public final class JexlFeatures
      extends Object

  A set of language feature options. These control syntactical constructs that will throw JexlException.Feature exceptions (a subclass of JexlException.Parsing) when disabled.
  - 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
  - Pragmas: #pragma x y
  - Annotation: @annotation statement;
  Since:
    3.2

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `ANNOTATION` Annotation feature ordinal.
    `static int` | `ARRAY_REF_EXPR` Array get is allowed on expr.
    `static int` | `LAMBDA` Lambda feature ordinal.
    `static int` | `LEXICAL` Lexical feature ordinal.
    `static int` | `LEXICAL_SHADE` Lexical shade feature ordinal.
    `static int` | `LOCAL_VAR` Locals feature ordinal.
    `static int` | `LOOP` Loops feature ordinal.
    `static int` | `METHOD_CALL` Lambda feature ordinal.
    `static int` | `NEW_INSTANCE` New-instance feature ordinal.
    `static int` | `PRAGMA` Pragma feature ordinal.
    `static int` | `RESERVED` Reserved name feature ordinal.
    `static int` | `SCRIPT` Script feature ordinal.
    `static int` | `SIDE_EFFECT` Side-effects feature ordinal.
    `static int` | `SIDE_EFFECT_GLOBAL` Global side-effects feature ordinal.
    `static int` | `STRUCTURED_LITERAL` Structured literal feature ordinal.
    `static Predicate<String>` | `TEST_STR_FALSE` The false predicate.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JexlFeatures()` Creates an all-features-enabled instance.
    `JexlFeatures(JexlFeatures features)` Copy constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `JexlFeatures` | `annotation(boolean flag)` Sets whether annotation constructs are enabled.
    `JexlFeatures` | `arrayReferenceExpr(boolean flag)` Sets whether array references expressions are enabled.
    `boolean` | `equals(Object obj)`
    `Set<String>` | `getReservedNames()`
    `int` | `hashCode()`
    `boolean` | `isLexical()`
    `boolean` | `isLexicalShade()`
    `boolean` | `isReservedName(String name)` Checks whether a name is reserved.
    `JexlFeatures` | `lambda(boolean flag)` Sets whether lambda/function constructs are enabled.
    `JexlFeatures` | `lexical(boolean flag)` Sets whether syntactic lexical mode is enabled.
    `JexlFeatures` | `lexicalShade(boolean flag)` Sets whether syntactic lexical shade is enabled.
    `JexlFeatures` | `localVar(boolean flag)` Sets whether local variables are enabled.
    `JexlFeatures` | `loops(boolean flag)` Sets whether looping constructs are enabled.
    `JexlFeatures` | `methodCall(boolean flag)` Sets whether method calls expressions are enabled.
    `Predicate<String>` | `namespaceTest()`
    `JexlFeatures` | `namespaceTest(Predicate<String> names)` Sets a test to determine namespace declaration.
    `JexlFeatures` | `newInstance(boolean flag)` Sets whether creating new instances is enabled.
    `JexlFeatures` | `pragma(boolean flag)` Sets whether pragma constructs are enabled.
    `JexlFeatures` | `register(boolean flag)` Sets whether register are enabled.
    `JexlFeatures` | `reservedNames(Collection<String> names)` Sets a collection of reserved names precluding those to be used as local variables or parameter names.
    `JexlFeatures` | `script(boolean flag)` Sets whether scripts constructs are enabled.
    `JexlFeatures` | `sideEffect(boolean flag)` Sets whether side effect expressions are enabled.
    `JexlFeatures` | `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.
    `JexlFeatures` | `structuredLiteral(boolean flag)` Sets whether array/map/set literal expressions are enabled.
    `boolean` | `supportsAnnotation()`
    `boolean` | `supportsArrayReferenceExpr()`
    `boolean` | `supportsExpression()`
    `boolean` | `supportsLambda()`
    `boolean` | `supportsLocalVar()`
    `boolean` | `supportsLoops()`
    `boolean` | `supportsMethodCall()`
    `boolean` | `supportsNewInstance()`
    `boolean` | `supportsPragma()`
    `boolean` | `supportsRegister()`
    `boolean` | `supportsScript()`
    `boolean` | `supportsSideEffect()`
    `boolean` | `supportsSideEffectGlobal()`
    `boolean` | `supportsStructuredLiteral()`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TEST_STR_FALSE

          public static final Predicate<String> TEST_STR_FALSE

      The false predicate.

    - #### RESERVED

          public static final int RESERVED

      Reserved name feature ordinal.
      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

      Array get is allowed on expr.
      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

  - ### Constructor Detail

    - #### JexlFeatures

          public JexlFeatures()

      Creates an all-features-enabled instance.

    - #### JexlFeatures

          public JexlFeatures(JexlFeatures features)

      Copy constructor.
      Parameters:
        `features` - the feature to copy from

  - ### Method Detail

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### stringify

          public static String stringify(int feature)

      The text corresponding to a feature code.
      Parameters:
        `feature` - the feature number
      Returns:
        the feature name

    - #### reservedNames

          public JexlFeatures reservedNames(Collection<String> names)

      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

          public Set<String> getReservedNames()

      Returns:
        the (unmodifiable) set of reserved names.

    - #### isReservedName

          public boolean isReservedName(String name)

      Checks whether a name is reserved.
      Parameters:
        `name` - the name to check
      Returns:
        true if reserved, false otherwise

    - #### namespaceTest

          public JexlFeatures namespaceTest(Predicate<String> names)

      Sets a test to determine namespace declaration.
      Parameters:
        `names` - the name predicate
      Returns:
        this features instance

    - #### namespaceTest

          public Predicate<String> namespaceTest()

      Returns:
        the declared namespaces test.

    - #### 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

    - #### supportsRegister

          public boolean supportsRegister()

      Returns:
        true if register syntax is enabled

    - #### 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

    - #### supportsLocalVar

          public boolean supportsLocalVar()

      Returns:
        true if local variables syntax is enabled

    - #### 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

    - #### supportsSideEffectGlobal

          public boolean supportsSideEffectGlobal()

      Returns:
        true if global variables can be assigned

    - #### 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

    - #### supportsSideEffect

          public boolean supportsSideEffect()

      Returns:
        true if side effects are enabled, false otherwise

    - #### 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

    - #### supportsArrayReferenceExpr

          public boolean supportsArrayReferenceExpr()

      Returns:
        true if array references can contain method call expressions, false otherwise

    - #### 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

    - #### supportsMethodCall

          public boolean supportsMethodCall()

      Returns:
        true if array references can contain expressions, false otherwise

    - #### 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

    - #### supportsStructuredLiteral

          public boolean supportsStructuredLiteral()

      Returns:
        true if array/map/set literal expressions are supported, false otherwise

    - #### 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

    - #### supportsNewInstance

          public boolean supportsNewInstance()

      Returns:
        true if creating new instances is enabled, false otherwise

    - #### 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

    - #### supportsLoops

          public boolean supportsLoops()

      Returns:
        true if loops are enabled, 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

    - #### supportsLambda

          public boolean supportsLambda()

      Returns:
        true if lambda are enabled, false otherwise

    - #### 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

    - #### supportsPragma

          public boolean supportsPragma()

      Returns:
        true if pragma are enabled, false otherwise

    - #### 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

    - #### supportsAnnotation

          public boolean supportsAnnotation()

      Returns:
        true if annotation are enabled, false otherwise

    - #### 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

    - #### 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

          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

    - #### isLexical

          public boolean isLexical()

      Returns:
        whether lexical scope feature is enabled

    - #### 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

    - #### isLexicalShade

          public boolean isLexicalShade()

      Returns:
        whether lexical shade feature is enabled

Copyright © 2001–2021 The Apache Software Foundation. All rights reserved.