Class AbstractHTMLFilter

  • All Implemented Interfaces:
    HTMLFilter, HTMLConstants

    public abstract class AbstractHTMLFilter
    extends Object
    implements HTMLFilter, HTMLConstants
    Abstract implementation of HTMLFilter providing utility methods for various common w3c dom operations.
    Since:
    1.8M2
    Version:
    $Id: 85b4f1fe10154404ed00f11bfc8b78ef2aaf8dd7 $
    • Constructor Detail

      • AbstractHTMLFilter

        public AbstractHTMLFilter()
    • Method Detail

      • filterChildren

        protected List<Element> filterChildren​(Element parent,
                                               String tagName)
        Utility method for filtering an element's children with a tagName.
        Parameters:
        parent - the parent Element.
        tagName - expected tagName of the children elements.
        Returns:
        list of children elements with the provided tagName.
      • filterDescendants

        protected List<Element> filterDescendants​(Element parent,
                                                  String[] tagNames)
        Utility method for filtering an element's descendants by their tag names.
        Parameters:
        parent - the parent Element.
        tagNames - an array of tagNames.
        Returns:
        list of descendants of the parent element having one of given tag names.
      • filterDescendants

        protected List<Element> filterDescendants​(Element parent,
                                                  String[] tagNames,
                                                  ElementSelector elementSelector)
        Utility method for filtering an element's descendants by their tag names and an ElementSelector.
        Parameters:
        parent - the parent Element.
        tagNames - an array of tagNames.
        elementSelector - an ElementSelector that allows further filtering of elements.
        Returns:
        list of descendants of the parent element having one of given tag names.
      • hasAttribute

        protected boolean hasAttribute​(List<Element> elements,
                                       String attributeName,
                                       boolean checkValue)
        Utility method for checking if a list of elements have the same attribute set. If the checkValue is true, the values of the given attribute will be checked for equivalency.
        Parameters:
        elements - the list of elements.
        attributeName - Name of the attribute.
        checkValue - flag indicating if the value of the attribute should be equal among all the elements.
        Returns:
        true if the given attribute is present and the value check is passing.
      • replaceWithChildren

        protected void replaceWithChildren​(Element element)
        Replaces the given Element with it's children.
        Parameters:
        element - the Element to be replaced.
      • moveChildren

        protected void moveChildren​(Element parent,
                                    Element destination)
        Moves all child elements of the parent into destination element.
        Parameters:
        parent - the parent Element.
        destination - the destination Element.