Class DOMTreeResolver

java.lang.Object
com.openhtmltopdf.css.extend.lib.DOMTreeResolver
All Implemented Interfaces:
TreeResolver

public class DOMTreeResolver extends Object implements TreeResolver
  • Field Details

    • cachedPositions

      private final Map<Node,Map<Node,Integer>> cachedPositions
      We cache element positions for nth-child, odd and even condition matchers. To avoid scaling with the square of the number of children elements.
  • Constructor Details

    • DOMTreeResolver

      public DOMTreeResolver()
  • Method Details

    • getParentElement

      public Object getParentElement(Object element)
      Description copied from interface: TreeResolver
      returns the parent element of an element, or null if this was the root element
      Specified by:
      getParentElement in interface TreeResolver
    • getPreviousSiblingElement

      public Object getPreviousSiblingElement(Object element)
      Description copied from interface: TreeResolver
      The previous sibling element, or null if none exists
      Specified by:
      getPreviousSiblingElement in interface TreeResolver
    • getElementName

      public String getElementName(Object element)
      Description copied from interface: TreeResolver
      returns the name of the element so that it may match against the selectors
      Specified by:
      getElementName in interface TreeResolver
    • isFirstChildElement

      public boolean isFirstChildElement(Object element)
      Description copied from interface: TreeResolver
      returns true if this element is the first child element of its parent
      Specified by:
      isFirstChildElement in interface TreeResolver
    • isLastChildElement

      public boolean isLastChildElement(Object element)
      Description copied from interface: TreeResolver
      returns true if this element is the last child element of its parent
      Specified by:
      isLastChildElement in interface TreeResolver
    • matchesElement

      public boolean matchesElement(Object element, String namespaceURI, String name)
      Description copied from interface: TreeResolver
      Returns true if element has the local name name and namespace URI namespaceURI.
      Specified by:
      matchesElement in interface TreeResolver
      Parameters:
      element -
      namespaceURI - The namespace to match, may be null to signify any namespace. Use TreeResolver.NO_NAMESPACE to signify that name should only match when there is no namespace defined on element.
      name - The name to match, may not be null
    • getPositionOfElement

      public int getPositionOfElement(Object element)
      Description copied from interface: TreeResolver
      Returns the index of the position of the submitted element among its element node siblings.
      Specified by:
      getPositionOfElement in interface TreeResolver
      Parameters:
      element -
      Returns:
      -1 in case of error, 0 indexed position otherwise