Class RemovePathsJsonAction

java.lang.Object
net.minidev.json.actions.traverse.RemovePathsJsonAction
All Implemented Interfaces:
JSONTraverseAction, TreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>

public class RemovePathsJsonAction extends Object implements JSONTraverseAction
Removes branches from a JSONObject.

A path is not removed from the user-specified list once its processing is over, because identical objects in the same array are supported by this action.

See package-info for more details

See unit tests for examples

Author:
adoneitan@gmail.com
  • Field Details

    • result

      protected net.minidev.json.JSONObject result
    • pathsToRemove

      protected List<String> pathsToRemove
  • Constructor Details

    • RemovePathsJsonAction

      public RemovePathsJsonAction(List<String> pathsToRemove)
  • Method Details

    • start

      public boolean start(net.minidev.json.JSONObject object)
      Description copied from interface: TreeTraverseAction
      called before any traversal of the TreeTraverseAction tree starts
      Specified by:
      start in interface TreeTraverseAction<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: TreeTraverseAction
      the last callback for each entry in an TreeTraverseAction map. if this method returns true the TreeTraverser removes the entry from the map. there is no further handling of the entry.
      Specified by:
      removeEntry in interface TreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
      Parameters:
      fullPathToEntry - TODO
      entry - 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: TreeTraverseAction
      called when a new entry is encountered and before any processing is performed on it
      Specified by:
      traverseEntry in interface TreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
      Parameters:
      fullPathToEntry - TODO
      entry - TODO
      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 M object
      Specified by:
      recurInto in interface TreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
      Parameters:
      pathToEntry - TODO
      entryValue - 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: TreeTraverseAction
      called when a non-leaf item is encountered inside an L object
      Specified by:
      recurInto in interface TreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
      Parameters:
      pathToEntry - TODO
      entryValue - 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: TreeTraverseAction
      called for each leaf of an M map is encountered
      Specified by:
      handleLeaf in interface TreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
      Parameters:
      pathToEntry - TODO
      entry - TODO
    • handleLeaf

      public void handleLeaf(String fullPathToContainingList, int listIndex, Object listItem)
      Description copied from interface: TreeTraverseAction
      called for each leaf of an L list is encountered
      Specified by:
      handleLeaf in interface TreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
      Parameters:
      fullPathToContainingList - - the item
      listIndex - - the ordered location of the item in the list
      listItem - -
    • end

      public void end()
      Description copied from interface: TreeTraverseAction
      called after the traversal ends, and just before the TreeTraverseAction.start(M) method exits
      Specified by:
      end in interface TreeTraverseAction<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 interface TreeTraverseAction<net.minidev.json.JSONObject,net.minidev.json.JSONArray>
      Returns:
      result