Class ElementPathEvaluator
java.lang.Object
com.inductiveautomation.ignition.common.expressions.ElementPathEvaluator
Evaluates a JSON-style path (e.g.
event.data.foo[0].bar) against a document-like object,
using an ElementExtractor to navigate whatever concrete representation the object has
(JSON, Document, Python dictionary, etc.).
The caller resolves the object for some number of leading elements (possibly zero) and passes that count; traversal skips that many elements and walks the rest. The path is parsed and its per-element path strings precomputed once at construction, so a single instance can cheaply evaluate many objects (e.g. one per event).
-
Method Summary
Modifier and TypeMethodDescription<T> QualifiedValueextractData(int skipCount, @Nullable T dict, ElementExtractor<T> extractor) Traverses this evaluator's path into the given object, skipping the leading elements the caller already resolved.static ElementPathEvaluatorfromString(String jsonPath) Creates an evaluator for the given path.jsonPath()Object[]keys()
-
Method Details
-
fromString
Creates an evaluator for the given path.- Parameters:
jsonPath- the path to evaluate, e.g.event.data.foo[0].bar.- Returns:
- a new evaluator for the path.
- Throws:
IllegalArgumentException- if the path cannot be parsed.
-
jsonPath
- Returns:
- the parsed path
-
keys
- Returns:
- the key of each path element in order: a String for map keys, an Integer for array indices. Empty if the path could not be parsed.
-
extractData
public <T> QualifiedValue extractData(int skipCount, @Nullable T dict, ElementExtractor<T> extractor) Traverses this evaluator's path into the given object, skipping the leading elements the caller already resolved.- Parameters:
skipCount- the number of leading path elements already resolved todict(e.g.2whendictis the object atevent.dataof pathevent.data.foo), or0ifdictis the root of the whole path.dict- the object the remaining path elements are traversed into, possibly null.extractor- the extractor that knows how to navigatedict's representation.- Returns:
- the value at the path, converted to a plain Java object if primitive; or an
QualifiedValue.EXPRESSION_EVAL_ERROR-derived value ifdictis null, the skip count is out of the path's range, or an element along the path is missing, null, or not the expected map/array type.
-