Package com.openhtmltopdf.css.extend.lib
Class DOMTreeResolver
java.lang.Object
com.openhtmltopdf.css.extend.lib.DOMTreeResolver
- All Implemented Interfaces:
TreeResolver
-
Field Summary
FieldsModifier and TypeFieldDescriptionWe cache element positions for nth-child, odd and even condition matchers.Fields inherited from interface com.openhtmltopdf.css.extend.TreeResolver
NO_NAMESPACE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetElementName
(Object element) returns the name of the element so that it may match against the selectorsgetParentElement
(Object element) returns the parent element of an element, or null if this was the root elementint
getPositionOfElement
(Object element) Returns the index of the position of the submitted element among its element node siblings.getPreviousSiblingElement
(Object element) The previous sibling element, or null if none existsboolean
isFirstChildElement
(Object element) returns true if this element is the first child element of its parentboolean
isLastChildElement
(Object element) returns true if this element is the last child element of its parentboolean
matchesElement
(Object element, String namespaceURI, String name) Returnstrue
ifelement
has the local namename
and namespace URInamespaceURI
.
-
Field Details
-
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
Description copied from interface:TreeResolver
returns the parent element of an element, or null if this was the root element- Specified by:
getParentElement
in interfaceTreeResolver
-
getPreviousSiblingElement
Description copied from interface:TreeResolver
The previous sibling element, or null if none exists- Specified by:
getPreviousSiblingElement
in interfaceTreeResolver
-
getElementName
Description copied from interface:TreeResolver
returns the name of the element so that it may match against the selectors- Specified by:
getElementName
in interfaceTreeResolver
-
isFirstChildElement
Description copied from interface:TreeResolver
returns true if this element is the first child element of its parent- Specified by:
isFirstChildElement
in interfaceTreeResolver
-
isLastChildElement
Description copied from interface:TreeResolver
returns true if this element is the last child element of its parent- Specified by:
isLastChildElement
in interfaceTreeResolver
-
matchesElement
Description copied from interface:TreeResolver
Returnstrue
ifelement
has the local namename
and namespace URInamespaceURI
.- Specified by:
matchesElement
in interfaceTreeResolver
- Parameters:
element
-namespaceURI
- The namespace to match, may be null to signify any namespace. UseTreeResolver.NO_NAMESPACE
to signify thatname
should only match when there is no namespace defined onelement
.name
- The name to match, may not be null
-
getPositionOfElement
Description copied from interface:TreeResolver
Returns the index of the position of the submitted element among its element node siblings.- Specified by:
getPositionOfElement
in interfaceTreeResolver
- Parameters:
element
-- Returns:
- -1 in case of error, 0 indexed position otherwise
-