Class ArraySuffix

  • Direct Known Subclasses:
    PropertySuffix

    public class ArraySuffix
    extends ValueSuffix

    Represents an operator that obtains a Map entry, an indexed value, a property value, or an indexed property value of an object. The following are the rules for evaluating this operator:

     Evaluating a[b] (assuming a.b == a["b"])
       a is null
         return null
       b is null
         return null
       a is Map
         !a.containsKey (b)
           return null
         a.get(b) == null
           return null
         otherwise
           return a.get(b)
       a is List or array
         coerce b to int (using coercion rules)
         coercion couldn't be performed
           error
         a.get(b) or Array.get(a, b) throws ArrayIndexOutOfBoundsException or IndexOutOfBoundsException
           return null
         a.get(b) or Array.get(a, b) throws other exception
           error
         return a.get(b) or Array.get(a, b)
    
       coerce b to String
       b is a readable property of a
         getter throws an exception
           error
         otherwise
           return result of getter call
    
       otherwise
         error
     
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) Expression mIndex  
      (package private) static java.lang.Object[] sNoArgs  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object evaluate​(java.lang.Object pValue, java.lang.Object pContext, VariableResolver pResolver, java.util.Map functions, java.lang.String defaultPrefix, Logger pLogger)
      Evaluates the expression in the given context, operating on the given value.
      (package private) java.lang.Object evaluateIndex​(java.lang.Object pContext, VariableResolver pResolver, java.util.Map functions, java.lang.String defaultPrefix, Logger pLogger)
      Gets the value of the index
      java.lang.String getExpressionString()
      Returns the expression in the expression language syntax
      Expression getIndex()  
      (package private) java.lang.String getOperatorSymbol()
      Returns the operator symbol
      void setIndex​(Expression pIndex)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • sNoArgs

        static java.lang.Object[] sNoArgs
    • Constructor Detail

      • ArraySuffix

        public ArraySuffix​(Expression pIndex)
        Constructor
    • Method Detail

      • setIndex

        public void setIndex​(Expression pIndex)
      • evaluateIndex

        java.lang.Object evaluateIndex​(java.lang.Object pContext,
                                       VariableResolver pResolver,
                                       java.util.Map functions,
                                       java.lang.String defaultPrefix,
                                       Logger pLogger)
                                throws ELException
        Gets the value of the index
        Throws:
        ELException
      • getOperatorSymbol

        java.lang.String getOperatorSymbol()
        Returns the operator symbol
      • getExpressionString

        public java.lang.String getExpressionString()
        Returns the expression in the expression language syntax
        Specified by:
        getExpressionString in class ValueSuffix
      • evaluate

        public java.lang.Object evaluate​(java.lang.Object pValue,
                                         java.lang.Object pContext,
                                         VariableResolver pResolver,
                                         java.util.Map functions,
                                         java.lang.String defaultPrefix,
                                         Logger pLogger)
                                  throws ELException
        Evaluates the expression in the given context, operating on the given value.
        Specified by:
        evaluate in class ValueSuffix
        Throws:
        ELException