Package com.singularsys.jep.misc.dictionary

# Class Get

java.lang.Object
com.singularsys.jep.functions.PostfixMathCommand
com.singularsys.jep.functions.BinaryFunction
com.singularsys.jep.misc.dictionary.Get

All Implemented Interfaces:
  `ZeroLengthBehaviourI`, `ZeroLengthBehaviourI.DefaultZeroLengthBehaviourI`, `PostfixMathCommandI`, `Serializable`

public class Get extends BinaryFunction implements ZeroLengthBehaviourI.DefaultZeroLengthBehaviourI
Gets the value associated with a key.

    map = {'x':2, 'y':3};
    get(map, 'x');

The function returns the value associated with the key. If no key is found then the behaviour is controlled according to `ZeroLengthBehaviourI`. If no value is associate with the key then `nullValue` is returned. is returned.

Since:
  Jep 4.1
See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class com.singularsys.jep.functions.BinaryFunction

  `BinaryFunction.BiFunctionWithException<T>`

  ## Nested classes/interfaces inherited from interface com.singularsys.jep.functions.ZeroLengthBehaviourI

  `ZeroLengthBehaviourI.DefaultZeroLengthBehaviourI, ZeroLengthBehaviourI.ZeroLengthErrorBehaviour, ZeroLengthBehaviourI.ZeroLengthHelper`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `final Object`
  `nullValue`
  `protected ZeroLengthBehaviourI.ZeroLengthHelper`
  `zeroLengthHelper`

  ### Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand

  `curNumberOfParameters, description, name, NaN, numberOfParameters`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Get(Object nullValue)`
  Constructor

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected boolean`
  `equals(Object key, Object k)`
  Test if key equals k.
  `Object`
  `eval(Object l, Object key)`
  Evaluate the function
  `protected Object`
  `eval(List<?> list, Object key)`
  `protected Object`
  `eval(Map<Object,Object> map, Object key)`
  `String`
  `getErrorMessage(String name)`
  Gets the zero length error message.
  `ZeroLengthBehaviourI`
  `getZeroLengthHelper()`
  Gets the helper class which implements the zero length behaviour.

  ### Methods inherited from class com.singularsys.jep.functions.BinaryFunction

  `instanceOf, instanceOf, instanceOf, instanceOf, run`

  ### Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand

  `asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, asType, checkNumberOfParameters, getDescription, getDescription, getDescriptionWithType, getName, getNumberOfParameters, setCurNumberOfParameters, setDescription, setName, toString, toString`

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

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface com.singularsys.jep.functions.ZeroLengthBehaviourI

  `getValueOrException, zeroLengthResultOrException`

  ### Methods inherited from interface com.singularsys.jep.functions.ZeroLengthBehaviourI.DefaultZeroLengthBehaviourI

  `getZeroLengthErrorBehaviour, getZeroLengthValue, setZeroLengthErrorBehaviour, setZeroLengthValue`

- ## Field Details

  - ### nullValue

    public final Object nullValue

  - ### zeroLengthHelper

    protected ZeroLengthBehaviourI.ZeroLengthHelper zeroLengthHelper

- ## Constructor Details

  - ### Get

    public Get(Object nullValue)
    Constructor
    Parameters:
      `nullValue` - , value returned when a key has no value.

- ## Method Details

  - ### eval

    public Object eval(Object l, Object key) throws EvaluationException
    Description copied from class: `BinaryFunction`
    Evaluate the function
    Specified by:
      `eval` in class `BinaryFunction`
    Parameters:
      `l` - lhs argument
      `key` - rhs argument
    Returns:
      the results
    Throws:
      `EvaluationException` - if the function cannot be evaluated.

  - ### eval

    protected Object eval(Map<Object,Object> map, Object key) throws EvaluationException
    Throws:
      `EvaluationException`

  - ### eval

    protected Object eval(List<?> list, Object key) throws EvaluationException
    Throws:
      `EvaluationException`

  - ### equals

    protected boolean equals(Object key, Object k) throws EvaluationException
    Test if key equals k. Default implementation uses `key.equals(k)`
    Parameters:
      `key` - key to test
      `k` - key to test
    Returns:
      true if parameters are equal
    Throws:
      `EvaluationException`

  - ### getZeroLengthHelper

    public ZeroLengthBehaviourI getZeroLengthHelper()
    Description copied from interface: `ZeroLengthBehaviourI.DefaultZeroLengthBehaviourI`
    Gets the helper class which implements the zero length behaviour. The standard implementation is:

        ZeroLengthHelper zeroLengthHelper = new ZeroLengthHelper();
        @Override
        public ZeroLengthBehaviourI getZeroLengthHelper() {
            return zeroLengthHelper;
        }

    Specified by:
      `getZeroLengthHelper` in interface `ZeroLengthBehaviourI.DefaultZeroLengthBehaviourI`
    Returns:
      the helper class

  - ### getErrorMessage

    public String getErrorMessage(String name)
    Description copied from interface: `ZeroLengthBehaviourI`
    Gets the zero length error message. The default implementation format a string using the `functions.AtLestOneArgumentIsRequired` property.
    Specified by:
      `getErrorMessage` in interface `ZeroLengthBehaviourI`
    Parameters:
      `name` - name of the function passed into `ZeroLengthBehaviourI.zeroLengthResultOrException(String)`
    Returns:
      the error message.