Package com.adobe.xfa

Class NodeListFilter

  • Direct Known Subclasses:
    TagnameFilter

    public class NodeListFilter
    extends java.lang.Object
    NodeListFilter filters a node and its children to produce a list of nodes that satisfy some filter test.

    A derived class will typically override the accept(Node) method, and can further refine the behaviour by overriding init(), checkChildren(Node) or checkFinished().

    • Constructor Summary

      Constructors 
      Constructor Description
      NodeListFilter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean accept​(Node node)
      Determines whether node is to be included in the filtered list of nodes.
      boolean checkChildren​(Node node)
      Determines whether the filter should search the children of this node.
      boolean checkFinished()
      Determines whether a search should continue or not.
      java.util.List<Node> filterNodes​(Node startNode)
      Searches the startNode all descendants of startNode.
      java.util.List<Node> filterNodes​(Node startNode, int level)
      Searches the startNode all descendants of startNode down to the level specified.
      java.util.List<Node> filterNodes​(Node startNode, int level, java.util.List<Node> nodeList)
      Searches the startNode all descendants of startNode down to the level specified.
      void init()
      This method is called when a search is started.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NodeListFilter

        public NodeListFilter()
    • Method Detail

      • accept

        public boolean accept​(Node node)
        Determines whether node is to be included in the filtered list of nodes. Derived classes will want to override this behaviour.
        Parameters:
        node - the node to test for inclusion
        Returns:
        true if the node is to be included. The default implementation always returns true.
      • checkChildren

        public boolean checkChildren​(Node node)
        Determines whether the filter should search the children of this node.
        Parameters:
        node - the node to check
        Returns:
        true if the filter should search children of node.
      • checkFinished

        public boolean checkFinished()
        Determines whether a search should continue or not. We may want to abort the search in cases such as where we're searching for a specific node or the first occurrence of a node and wish to stop searching when we've found it.
        Returns:
        true if we're done, false if we're to keep searching.
      • init

        public void init()
        This method is called when a search is started.
      • filterNodes

        public java.util.List<Node> filterNodes​(Node startNode)
        Searches the startNode all descendants of startNode.
        Only nodes that are accepted by the filter will be added to the list.
        Parameters:
        startNode - the node to start searching from.
        Returns:
        a list of nodes
      • filterNodes

        public java.util.List<Node> filterNodes​(Node startNode,
                                                int level,
                                                java.util.List<Node> nodeList)
        Searches the startNode all descendants of startNode down to the level specified.
        Only nodes that are accepted by the filter will be added to nodeList.
        Parameters:
        startNode - the node to start searching from.
        level -

        0 = Exhaustively search all descendants of startNode
        1 = Search immediate children.
        2 = Search immediate children and grandchildren
        n = Search descendants down to the nth level.
        Returns:
        a list of nodes
      • filterNodes

        public java.util.List<Node> filterNodes​(Node startNode,
                                                int level)
        Searches the startNode all descendants of startNode down to the level specified.
        Only nodes that are accepted by the filter will be added to the result list.
        Parameters:
        startNode - the node to start searching from.
        level -

        0 = Exhaustively search all descendants of startNode
        1 = Search immediate children.
        2 = Search immediate children and grandchildren
        n = Search descendants down to the nth level.
        Returns:
        a list of nodes