org.thymeleaf.dom
Class DOMSelector

Object
  extended by org.thymeleaf.dom.DOMSelector
All Implemented Interfaces:
Serializable

public final class DOMSelector
extends Object
implements Serializable

DOM Selectors model selections of subtrees from Thymeleaf DOM trees.

A common use of these selectors is for including fragments of other templates without the need of these other templates having any Thymeleaf code.

Note this class exists since 2.0.0, but its syntax has been greatly enhanced in 2.1.0.

Selection features

DOM Selector selection operations are based on:

Syntax

DOM Selector syntax is similar to that of XPath or jQuery selectors:

Objects of this class are thread-safe.

Since:
2.0.0
Author:
Daniel Fernández
See Also:
Serialized Form

Nested Class Summary
static class DOMSelector.AbstractNodeReferenceChecker
           Common abstract implementation of DOMSelector.INodeReferenceChecker.
static class DOMSelector.AggregatingNodeReferenceChecker
           Implementation of DOMSelector.INodeReferenceChecker that aggregates two other reference checker objects.
static interface DOMSelector.INodeReferenceChecker
           Common interface for objects in charge of resolving references in DOM Selector expressions.
 
Constructor Summary
DOMSelector(String selectorExpression)
           Creates a new DOM selector specified by the argument selector expression.
 
Method Summary
 String getSelectorExpression()
           Returns the expression that specifies this DOM selector.
 List<Node> select(List<Node> nodes)
           Executes the DOM selector against the specified list of nodes, returning the result of applying the selector expression.
 List<Node> select(List<Node> nodes, DOMSelector.INodeReferenceChecker referenceChecker)
           Executes the DOM selector against the specified list of nodes and using the specified reference checker (if references are used in the DOM selector expression).
 List<Node> select(Node node)
           Executes the DOM selector against the specified node, returning the result of applying the selector expression.
 List<Node> select(Node node, DOMSelector.INodeReferenceChecker referenceChecker)
           Executes the DOM selector against the specified node and using the specified reference checker (if references are used in the DOM selector expression).
 String toString()
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DOMSelector

public DOMSelector(String selectorExpression)

Creates a new DOM selector specified by the argument selector expression.

Parameters:
selectorExpression - the expression specifying the selector to be used.
Method Detail

getSelectorExpression

public String getSelectorExpression()

Returns the expression that specifies this DOM selector.

Returns:
the selector expression.
Since:
2.0.12

select

public List<Node> select(Node node)

Executes the DOM selector against the specified node, returning the result of applying the selector expression.

Parameters:
node - the node on which the selector will be executed.
Returns:
the result of executing the selector.

select

public List<Node> select(Node node,
                         DOMSelector.INodeReferenceChecker referenceChecker)

Executes the DOM selector against the specified node and using the specified reference checker (if references are used in the DOM selector expression).

Parameters:
node - the node on which the selector will be executed.
referenceChecker - the checker that will be used to compute whether a Node matches or not a specified reference. Can be null.
Returns:
the result of executing the selector.
Since:
2.1.0

select

public List<Node> select(List<Node> nodes)

Executes the DOM selector against the specified list of nodes, returning the result of applying the selector expression.

Parameters:
nodes - the nodes on which the selector will be executed.
Returns:
the result of executing the selector.

select

public List<Node> select(List<Node> nodes,
                         DOMSelector.INodeReferenceChecker referenceChecker)

Executes the DOM selector against the specified list of nodes and using the specified reference checker (if references are used in the DOM selector expression).

Parameters:
nodes - the nodes on which the selector will be executed.
referenceChecker - the checker that will be used to compute whether a Node matches or not a specified reference. Can be null.
Returns:
the result of executing the selector.
Since:
2.1.0

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013 The THYMELEAF team. All Rights Reserved.