Interface ElementExtractor<T>
- Type Parameters:
T- the representation's element type: the common supertype of its map, array, and primitive elements.
- All Known Implementing Classes:
DocumentElementExtractor,JsonObjectElementExtractor,MapElementExtractor,PyDictionaryElementExtractor
public interface ElementExtractor<T>
Navigates one concrete document-like representation (JSON, Document, Python dictionary, plain
Java maps, etc.) on behalf of
ElementPathEvaluator, which walks a parsed path one element
at a time: extractKey(T, java.lang.String) steps into map elements, extractIndex(T, int) steps into array
elements, and isPrimitive(T)/toJava(T) convert the final element to a plain Java
value.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classSignals that a map element has no value at a requested key, or an array element has no value at a requested index. -
Method Summary
Modifier and TypeMethodDescriptionint@Nullable TextractIndex(T element, int index) @Nullable TextractKey(T element, String key) booleanbooleanbooleanbooleanisPrimitive(@Nullable T element) mapName()
-
Method Details
-
isMap
- Returns:
- true if
elementis a map: a containerextractKey(T, java.lang.String)can step into; false for null.
-
extractKey
- Returns:
- the value at
key; null if the key is present with a null value. - Throws:
ElementExtractor.ElementNotFoundException- ifelementhas no value atkey.
-
mapName
String mapName()- Returns:
- the representation's name for its map type (e.g.
"JsonObject"), used in type-mismatch error messages.
-
isArray
- Returns:
- true if
elementis an array: a containerextractIndex(T, int)can step into; false for null.
-
extractIndex
- Returns:
- the value at
index; null if the slot holds a null value. - Throws:
ElementExtractor.ElementNotFoundException- ifindexis out of range forelement.
-
arraySize
- Returns:
- the number of elements in
element, for whichisArray(T)is true.
-
arrayName
String arrayName()- Returns:
- the representation's name for its array type (e.g.
"JsonArray"), used in type-mismatch and out-of-bounds error messages.
-
isNull
- Returns:
- true if
elementis a Java null or the representation's own null element (e.g.JsonNull).
-
isPrimitive
-
toJava
- Returns:
- the plain Java equivalent (e.g. String, Long, Double, Boolean) of an element for which
isPrimitive(T)is true; null for the representation's null element.
-