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:
- adoneitan@gmail.com
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanallowDotCharprotected Map<String,Object>elementsToRemoveprotected net.minidev.json.JSONObjectresult
-
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 voidend()called after the traversal ends, and just before theTreeTraverseAction.start(M)method exitsvoidhandleLeaf(String fullPathToContainingList, int listIndex, Object listItem)called for each leaf of an L list is encounteredvoidhandleLeaf(String pathToEntry, Map.Entry<String,Object> entry)called for each leaf of an M map is encounteredbooleanrecurInto(String pathToEntry, net.minidev.json.JSONArray entryValue)called when a non-leaf item is encountered inside an L objectbooleanrecurInto(String pathToEntry, net.minidev.json.JSONObject 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(net.minidev.json.JSONObject 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
public boolean start(net.minidev.json.JSONObject object)
Description copied from interface:TreeTraverseActioncalled before any traversal of theTreeTraverseActiontree starts- Specified by:
startin interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>- Parameters:
object- TODO- Returns:
- true if traversal should start at all
-
removeEntry
public boolean removeEntry(String fullPathToEntry, Map.Entry<String,Object> entry)
Description copied from interface:TreeTraverseActionthe 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.- Specified by:
removeEntryin interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>- Parameters:
fullPathToEntry- TODOentry- TODO- Returns:
- true if the entry and its subtree should be removed from the M tree
-
traverseEntry
public boolean traverseEntry(String fullPathToEntry, Map.Entry<String,Object> entry)
Description copied from interface:TreeTraverseActioncalled when a new entry is encountered and before any processing is performed on it- Specified by:
traverseEntryin interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>- Parameters:
fullPathToEntry- TODOentry- TODO- Returns:
- true if the entry should be processed
-
recurInto
public boolean recurInto(String pathToEntry, net.minidev.json.JSONObject entryValue)
Description copied from interface:TreeTraverseActioncalled when a non-leaf entry is encountered inside an M object- Specified by:
recurIntoin interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>- Parameters:
pathToEntry- TODOentryValue- TODO- 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:TreeTraverseActioncalled when a non-leaf item is encountered inside an L object- Specified by:
recurIntoin interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>- Parameters:
pathToEntry- TODOentryValue- TODO- 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:TreeTraverseActioncalled for each leaf of an M map is encountered- Specified by:
handleLeafin interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>- Parameters:
pathToEntry- TODOentry- TODO
-
handleLeaf
public void handleLeaf(String fullPathToContainingList, int listIndex, Object listItem)
Description copied from interface:TreeTraverseActioncalled for each leaf of an L list is encountered- Specified by:
handleLeafin interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>- Parameters:
fullPathToContainingList- - the itemlistIndex- - the ordered location of the item in the listlistItem- -
-
end
public void end()
Description copied from interface:TreeTraverseActioncalled after the traversal ends, and just before theTreeTraverseAction.start(M)method exits- Specified by:
endin interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
-
result
public Object result()
Description copied from interface:TreeTraverseActionholds the result of the traversal, as assigned by the action implementing this interface- Specified by:
resultin interfaceTreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>- Returns:
- result
-
-