Top Fields Constructors Methods
com.openhtmltopdf.css.extend.lib

public Class DOMTreeResolver

extends Object
implements TreeResolver
Class Inheritance
All Implemented Interfaces
com.openhtmltopdf.css.extend.TreeResolver
Imports
java.util.HashMap, .Map, org.w3c.dom.Element, .Node, .NodeList, com.openhtmltopdf.css.extend.TreeResolver

Author
scott
works for a w3c DOM tree

Field Summary

Modifier and TypeField and Description
private final Map<Node, Map<Node, Integer>>
cachedPositions

We cache element positions for nth-child, odd and even condition matchers.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
getElementName(Object element)

Implements com.openhtmltopdf.css.extend.TreeResolver.getElementName.

returns the name of the element so that it may match against the selectors

public Object
getParentElement(Object element)

Implements com.openhtmltopdf.css.extend.TreeResolver.getParentElement.

returns the parent element of an element, or null if this was the root element

public int
getPositionOfElement(Object element)

Implements com.openhtmltopdf.css.extend.TreeResolver.getPositionOfElement.

Returns the index of the position of the submitted element among its element node siblings.

public Object
getPreviousSiblingElement(Object element)

Implements com.openhtmltopdf.css.extend.TreeResolver.getPreviousSiblingElement.

The previous sibling element, or null if none exists

public boolean
isFirstChildElement(Object element)

Implements com.openhtmltopdf.css.extend.TreeResolver.isFirstChildElement.

returns true if this element is the first child element of its parent

public boolean
isLastChildElement(Object element)

Implements com.openhtmltopdf.css.extend.TreeResolver.isLastChildElement.

returns true if this element is the last child element of its parent

public boolean
matchesElement(Object element, String
The namespace to match, may be null to signify any namespace. Use NO_NAMESPACE to signify that name should only match when there is no namespace defined on element.
namespaceURI
,
String
The name to match, may not be null
name
)

Implements com.openhtmltopdf.css.extend.TreeResolver.matchesElement.

Returns true if element has the local name name and namespace URI namespaceURI.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cachedPositionsback to summary
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 Detail

DOMTreeResolverback to summary
public DOMTreeResolver()

Method Detail

getElementNameback to summary
public String getElementName(Object element)

Implements com.openhtmltopdf.css.extend.TreeResolver.getElementName.

Doc from com.openhtmltopdf.css.extend.TreeResolver.getElementName.

returns the name of the element so that it may match against the selectors

Annotations
@Override
getParentElementback to summary
public Object getParentElement(Object element)

Implements com.openhtmltopdf.css.extend.TreeResolver.getParentElement.

Doc from com.openhtmltopdf.css.extend.TreeResolver.getParentElement.

returns the parent element of an element, or null if this was the root element

Annotations
@Override
getPositionOfElementback to summary
public int getPositionOfElement(Object element)

Implements com.openhtmltopdf.css.extend.TreeResolver.getPositionOfElement.

Doc from com.openhtmltopdf.css.extend.TreeResolver.getPositionOfElement.

Returns the index of the position of the submitted element among its element node siblings.

Returns:int

-1 in case of error, 0 indexed position otherwise

Annotations
@Override
getPreviousSiblingElementback to summary
public Object getPreviousSiblingElement(Object element)

Implements com.openhtmltopdf.css.extend.TreeResolver.getPreviousSiblingElement.

Doc from com.openhtmltopdf.css.extend.TreeResolver.getPreviousSiblingElement.

The previous sibling element, or null if none exists

Annotations
@Override
isFirstChildElementback to summary
public boolean isFirstChildElement(Object element)

Implements com.openhtmltopdf.css.extend.TreeResolver.isFirstChildElement.

Doc from com.openhtmltopdf.css.extend.TreeResolver.isFirstChildElement.

returns true if this element is the first child element of its parent

Annotations
@Override
isLastChildElementback to summary
public boolean isLastChildElement(Object element)

Implements com.openhtmltopdf.css.extend.TreeResolver.isLastChildElement.

Doc from com.openhtmltopdf.css.extend.TreeResolver.isLastChildElement.

returns true if this element is the last child element of its parent

Annotations
@Override
matchesElementback to summary
public boolean matchesElement(Object element, String namespaceURI, String name)

Implements com.openhtmltopdf.css.extend.TreeResolver.matchesElement.

Doc from com.openhtmltopdf.css.extend.TreeResolver.matchesElement.

Returns true if element has the local name name and namespace URI namespaceURI.

Parameters
namespaceURI:String

The namespace to match, may be null to signify any namespace. Use NO_NAMESPACE to signify that name should only match when there is no namespace defined on element.

name:String

The name to match, may not be null

Annotations
@Override