public class TreeNavigator<M extends Map<String,Object>,L extends List<Object>> extends Object
JSONObject
corresponding to the paths specified.
For each specified path to navigate, the TreeNavigator
only traverses the matching
branch.
The navigator accepts an action and provides callback hooks for it to act on the traversed
nodes at each significant step. See NavigateAction
.
See package-info for more details
Example:
To navigate the branch k1.k2 of the object {"k1":{"k2":"v1"}, "k3":{"k4":"v2"}} instantiate the navigator like so: new JSONNavigator("k1.k2")
Modifier and Type | Field and Description |
---|---|
protected NavigateAction |
action |
protected String |
pathPrefix |
protected List<String> |
pathsToNavigate |
Constructor and Description |
---|
TreeNavigator(NavigateAction action,
List<String> pathsToNavigate) |
TreeNavigator(NavigateAction action,
String... pathsToNavigate) |
Modifier and Type | Method and Description |
---|---|
void |
nav(M object) |
void |
nav(TreePath jp,
L list) |
void |
nav(TreePath jp,
M map) |
TreeNavigator |
with(String pathPrefix) |
protected NavigateAction action
protected String pathPrefix
public TreeNavigator(NavigateAction action, List<String> pathsToNavigate)
public TreeNavigator(NavigateAction action, String... pathsToNavigate)
Copyright © 2020 Chemouni Uriel. All rights reserved.