Class RemoveElementsJsonAction
- java.lang.Object
-
- net.minidev.json.actions.traverse.RemoveElementsJsonAction
-
- All Implemented Interfaces:
JSONTraverseAction
,TreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
public class RemoveElementsJsonAction extends Object implements JSONTraverseAction
Removes key:value elements from aJSONObject
.An element is not removed from the user-specified list once its processing is over, because it may appear in more than one node.
See package-info for more details
See unit tests for examples
- Author:
- [email protected]
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
allowDotChar
protected Map<String,Object>
elementsToRemove
protected net.minidev.json.JSONObject
result
-
Constructor Summary
Constructors Constructor Description RemoveElementsJsonAction(Map<String,Object> elementsToRemove)
RemoveElementsJsonAction(Map<String,Object> elementsToRemove, boolean allowDotChar)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
end()
called after the traversal ends, and just before the#start(M)
method exitsvoid
handleLeaf(String fullPathToContainingList, int listIndex, Object listItem)
called for each leaf of anTreeTraverseAction
list is encounteredvoid
handleLeaf(String pathToEntry, Map.Entry<String,Object> entry)
called for each leaf of anTreeTraverseAction
map is encounteredboolean
recurInto(String pathToEntry, net.minidev.json.JSONArray entryValue)
called when a non-leaf item is encountered inside an objectboolean
recurInto(String pathToEntry, net.minidev.json.JSONObject entryValue)
called when a non-leaf entry is encountered inside an objectboolean
removeEntry(String fullPathToEntry, Map.Entry<String,Object> entry)
the last callback for each entry in anTreeTraverseAction
map.Object
result()
holds the result of the traversal, as assigned by the action implementing this interfaceboolean
start(net.minidev.json.JSONObject object)
called before any traversal of theTreeTraverseAction
tree startsboolean
traverseEntry(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
public boolean start(net.minidev.json.JSONObject object)
Description copied from interface:TreeTraverseAction
called before any traversal of theTreeTraverseAction
tree starts- Specified by:
start
in interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
- Returns:
- true if traversal should start at all
-
removeEntry
public boolean removeEntry(String fullPathToEntry, Map.Entry<String,Object> entry)
Description copied from interface:TreeTraverseAction
the last callback for each entry in anTreeTraverseAction
map. if this method returns true theTreeTraverser
removes the entry from the map. there is no further handling of the entry.- Specified by:
removeEntry
in interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
- Returns:
- true if the entry and its subtree should be removed from the
TreeTraverseAction
tree
-
traverseEntry
public boolean traverseEntry(String fullPathToEntry, Map.Entry<String,Object> entry)
Description copied from interface:TreeTraverseAction
called when a new entry is encountered and before any processing is performed on it- Specified by:
traverseEntry
in interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
- Returns:
- true if the entry should be processed
-
recurInto
public boolean recurInto(String pathToEntry, net.minidev.json.JSONObject entryValue)
Description copied from interface:TreeTraverseAction
called when a non-leaf entry is encountered inside an object- Specified by:
recurInto
in interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
- Returns:
- true if the non-leaf entry should be recursively traversed
-
recurInto
public boolean recurInto(String pathToEntry, net.minidev.json.JSONArray entryValue)
Description copied from interface:TreeTraverseAction
called when a non-leaf item is encountered inside an object- Specified by:
recurInto
in interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
- Returns:
- true if the non-leaf item should be recursively traversed
-
handleLeaf
public void handleLeaf(String pathToEntry, Map.Entry<String,Object> entry)
Description copied from interface:TreeTraverseAction
called for each leaf of anTreeTraverseAction
map is encountered- Specified by:
handleLeaf
in interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
-
handleLeaf
public void handleLeaf(String fullPathToContainingList, int listIndex, Object listItem)
Description copied from interface:TreeTraverseAction
called for each leaf of anTreeTraverseAction
list is encountered- Specified by:
handleLeaf
in interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
listIndex
- - the ordered location of the item in the listlistItem
- - the item
-
end
public void end()
Description copied from interface:TreeTraverseAction
called after the traversal ends, and just before the#start(M)
method exits- Specified by:
end
in interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
-
result
public Object result()
Description copied from interface:TreeTraverseAction
holds the result of the traversal, as assigned by the action implementing this interface- Specified by:
result
in interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
-
-