Class 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 a JSONObject.

    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 Detail

      • result

        protected net.minidev.json.JSONObject result
      • allowDotChar

        protected final boolean allowDotChar
    • Constructor Detail

      • RemoveElementsJsonAction

        public RemoveElementsJsonAction​(Map<String,​Object> elementsToRemove,
                                        boolean allowDotChar)
      • RemoveElementsJsonAction

        public RemoveElementsJsonAction​(Map<String,​Object> elementsToRemove)
    • Method Detail

      • 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>
        Returns:
        true if traversal should start at all
      • 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>
        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 interface TreeTraverseAction<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 interface TreeTraverseAction<net.minidev.json.JSONObject,​net.minidev.json.JSONArray>
        Returns:
        true if the non-leaf item should be recursively traversed
      • handleLeaf

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