Class RemoveElementsJsonAction

  • All Implemented Interfaces:
    JSONTraverseAction, TreeTraverseAction<JSONObject,​JSONArray>

    public class RemoveElementsJsonAction
    extends java.lang.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

    • Constructor Summary

      Constructors 
      Constructor Description
      RemoveElementsJsonAction​(java.util.Map<java.lang.String,​java.lang.Object> elementsToRemove)  
      RemoveElementsJsonAction​(java.util.Map<java.lang.String,​java.lang.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 TreeTraverseAction.start(M) method exits
      void handleLeaf​(java.lang.String fullPathToContainingList, int listIndex, java.lang.Object listItem)
      called for each leaf of an L list is encountered
      void handleLeaf​(java.lang.String pathToEntry, java.util.Map.Entry<java.lang.String,​java.lang.Object> entry)
      called for each leaf of an M map is encountered
      boolean recurInto​(java.lang.String pathToEntry, JSONArray entryValue)
      called when a non-leaf item is encountered inside an L object
      boolean recurInto​(java.lang.String pathToEntry, JSONObject entryValue)
      called when a non-leaf entry is encountered inside an M object
      boolean removeEntry​(java.lang.String fullPathToEntry, java.util.Map.Entry<java.lang.String,​java.lang.Object> entry)
      the last callback for each entry in an TreeTraverseAction map.
      java.lang.Object result()
      holds the result of the traversal, as assigned by the action implementing this interface
      boolean start​(JSONObject object)
      called before any traversal of the TreeTraverseAction tree starts
      boolean traverseEntry​(java.lang.String fullPathToEntry, java.util.Map.Entry<java.lang.String,​java.lang.Object> entry)
      called when a new entry is encountered and before any processing is performed on it
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • elementsToRemove

        protected final java.util.Map<java.lang.String,​java.lang.Object> elementsToRemove
      • allowDotChar

        protected final boolean allowDotChar
    • Constructor Detail

      • RemoveElementsJsonAction

        public RemoveElementsJsonAction​(java.util.Map<java.lang.String,​java.lang.Object> elementsToRemove,
                                        boolean allowDotChar)
      • RemoveElementsJsonAction

        public RemoveElementsJsonAction​(java.util.Map<java.lang.String,​java.lang.Object> elementsToRemove)
    • Method Detail

      • removeEntry

        public boolean removeEntry​(java.lang.String fullPathToEntry,
                                   java.util.Map.Entry<java.lang.String,​java.lang.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<JSONObject,​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​(java.lang.String fullPathToEntry,
                                     java.util.Map.Entry<java.lang.String,​java.lang.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<JSONObject,​JSONArray>
        Parameters:
        fullPathToEntry - TODO
        entry - TODO
        Returns:
        true if the entry should be processed
      • recurInto

        public boolean recurInto​(java.lang.String pathToEntry,
                                 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<JSONObject,​JSONArray>
        Parameters:
        pathToEntry - TODO
        entryValue - TODO
        Returns:
        true if the non-leaf entry should be recursively traversed
      • recurInto

        public boolean recurInto​(java.lang.String pathToEntry,
                                 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<JSONObject,​JSONArray>
        Parameters:
        pathToEntry - TODO
        entryValue - TODO
        Returns:
        true if the non-leaf item should be recursively traversed
      • handleLeaf

        public void handleLeaf​(java.lang.String pathToEntry,
                               java.util.Map.Entry<java.lang.String,​java.lang.Object> entry)
        Description copied from interface: TreeTraverseAction
        called for each leaf of an M map is encountered
        Specified by:
        handleLeaf in interface TreeTraverseAction<JSONObject,​JSONArray>
        Parameters:
        pathToEntry - TODO
        entry - TODO
      • handleLeaf

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