Class PyDictionaryElementExtractor

java.lang.Object
com.inductiveautomation.ignition.gateway.expressions.PyDictionaryElementExtractor
All Implemented Interfaces:
ElementExtractor<org.python.core.PyObject>

public class PyDictionaryElementExtractor extends Object implements ElementExtractor<org.python.core.PyObject>
An ElementExtractor over Jython object graphs: PyDictionarys are the map elements and PySequences are the array elements. Every element is a primitive at the end of a path — toJava(org.python.core.PyObject) converts any PyObject, containers included, to its plain Java equivalent.
  • Field Details

  • Method Details

    • isMap

      public boolean isMap(@Nullable org.python.core.PyObject element)
      Specified by:
      isMap in interface ElementExtractor<org.python.core.PyObject>
      Returns:
      true if element is a map: a container ElementExtractor.extractKey(T, java.lang.String) can step into; false for null.
    • extractKey

      public org.python.core.PyObject extractKey(org.python.core.PyObject element, String key)
      Specified by:
      extractKey in interface ElementExtractor<org.python.core.PyObject>
      Returns:
      the value at key; null if the key is present with a null value.
    • mapName

      public String mapName()
      Specified by:
      mapName in interface ElementExtractor<org.python.core.PyObject>
      Returns:
      the representation's name for its map type (e.g. "JsonObject"), used in type-mismatch error messages.
    • isArray

      public boolean isArray(@Nullable org.python.core.PyObject element)
      Specified by:
      isArray in interface ElementExtractor<org.python.core.PyObject>
      Returns:
      true if element is an array: a container ElementExtractor.extractIndex(T, int) can step into; false for null.
    • extractIndex

      public org.python.core.PyObject extractIndex(org.python.core.PyObject element, int index)
      Specified by:
      extractIndex in interface ElementExtractor<org.python.core.PyObject>
      Returns:
      the value at index; null if the slot holds a null value.
    • arraySize

      public int arraySize(org.python.core.PyObject element)
      Specified by:
      arraySize in interface ElementExtractor<org.python.core.PyObject>
      Returns:
      the number of elements in element, for which ElementExtractor.isArray(T) is true.
    • arrayName

      public String arrayName()
      Specified by:
      arrayName in interface ElementExtractor<org.python.core.PyObject>
      Returns:
      the representation's name for its array type (e.g. "JsonArray"), used in type-mismatch and out-of-bounds error messages.
    • isNull

      public boolean isNull(@Nullable org.python.core.PyObject element)
      Specified by:
      isNull in interface ElementExtractor<org.python.core.PyObject>
      Returns:
      true if element is a Java null or the representation's own null element (e.g. JsonNull).
    • isPrimitive

      public boolean isPrimitive(@Nullable org.python.core.PyObject element)
      Specified by:
      isPrimitive in interface ElementExtractor<org.python.core.PyObject>
      Returns:
      true if element is a leaf value — null or a primitive — that ElementExtractor.toJava(T) converts to a plain Java value; false if it is a map or array, which the evaluator returns in its native representation.
    • toJava

      public Object toJava(org.python.core.PyObject element)
      Specified by:
      toJava in interface ElementExtractor<org.python.core.PyObject>
      Returns:
      the plain Java equivalent (e.g. String, Long, Double, Boolean) of an element for which ElementExtractor.isPrimitive(T) is true; null for the representation's null element.