-
- All Known Subinterfaces:
JSONTraverseAction
- All Known Implementing Classes:
KeysPrintAction,LocatePathsJsonAction,RemoveElementsJsonAction,RemovePathsJsonAction,RetainPathsJsonAction
public interface TreeTraverseAction<M extends Map<String,Object>,L extends List<Object>>An interface for a processing action on the nodes of aTreeTraverseActiontree while traversing it. The order in which the callbacks are listed below is the order in which they are called by theTreeTraverserSee package-info for more details
- Author:
- adoneitan@gmail.com
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidend()called after the traversal ends, and just before thestart(M)method exitsvoidhandleLeaf(String fullPathToContainingList, int listIndex, Object listItem)called for each leaf of an L list is encounteredvoidhandleLeaf(String fullPathToEntry, Map.Entry<String,Object> entry)called for each leaf of an M map is encounteredbooleanrecurInto(String fullPathToContainingList, L entryValue)called when a non-leaf item is encountered inside an L objectbooleanrecurInto(String fullPathToSubtree, M entryValue)called when a non-leaf entry is encountered inside an M objectbooleanremoveEntry(String fullPathToEntry, Map.Entry<String,Object> entry)the last callback for each entry in anTreeTraverseActionmap.Objectresult()holds the result of the traversal, as assigned by the action implementing this interfacebooleanstart(M object)called before any traversal of theTreeTraverseActiontree startsbooleantraverseEntry(String fullPathToEntry, Map.Entry<String,Object> entry)called when a new entry is encountered and before any processing is performed on it
-
-
-
Method Detail
-
start
boolean start(M object)
called before any traversal of theTreeTraverseActiontree starts- Parameters:
object- TODO- Returns:
- true if traversal should start at all
-
traverseEntry
boolean traverseEntry(String fullPathToEntry, Map.Entry<String,Object> entry)
called when a new entry is encountered and before any processing is performed on it- Parameters:
fullPathToEntry- TODOentry- TODO- Returns:
- true if the entry should be processed
-
removeEntry
boolean removeEntry(String fullPathToEntry, Map.Entry<String,Object> entry)
the last callback for each entry in anTreeTraverseActionmap. if this method returns true theTreeTraverserremoves the entry from the map. there is no further handling of the entry.- Parameters:
fullPathToEntry- TODOentry- TODO- Returns:
- true if the entry and its subtree should be removed from the M tree
-
recurInto
boolean recurInto(String fullPathToSubtree, M entryValue)
called when a non-leaf entry is encountered inside an M object- Parameters:
fullPathToSubtree- TODOentryValue- TODO- Returns:
- true if the non-leaf entry should be recursively traversed
-
recurInto
boolean recurInto(String fullPathToContainingList, L entryValue)
called when a non-leaf item is encountered inside an L object- Parameters:
fullPathToContainingList- TODOentryValue- TODO- Returns:
- true if the non-leaf item should be recursively traversed
-
handleLeaf
void handleLeaf(String fullPathToEntry, Map.Entry<String,Object> entry)
called for each leaf of an M map is encountered- Parameters:
fullPathToEntry- TODOentry- TODO
-
handleLeaf
void handleLeaf(String fullPathToContainingList, int listIndex, Object listItem)
called for each leaf of an L list is encountered- Parameters:
fullPathToContainingList- - the itemlistIndex- - the ordered location of the item in the listlistItem- -
-
end
void end()
called after the traversal ends, and just before thestart(M)method exits
-
result
Object result()
holds the result of the traversal, as assigned by the action implementing this interface- Returns:
- result
-
-