public final class DOMSelectorFragmentSpec extends Object implements IFragmentSpec
Implementation of the IFragmentSpec
interface that extracts fragments
of DOM trees using a DOMSelector
object.
The DOM selector instances used by these fragment specs are stored at the
expression cache (see ICacheManager.getExpressionCache()
) using
as key DOM_SELECTOR_EXPRESSION_PREFIX
+ selectorExpression.
Objects of this class are thread-safe.
Modifier and Type | Field and Description |
---|---|
static String |
DOM_SELECTOR_EXPRESSION_PREFIX
Prefix to be used for keys when storing selector expressions at the
expression cache.
|
Constructor and Description |
---|
DOMSelectorFragmentSpec(String selectorExpression)
Creates a new instance, specifying the expression to be used for a
DOMSelector object to be created internally. |
DOMSelectorFragmentSpec(String selectorExpression,
DOMSelector.INodeReferenceChecker referenceChecker)
Creates a new instance, specifying the expression to be used for a
DOMSelector object to be created internally, and also the reference checker to be used. |
Modifier and Type | Method and Description |
---|---|
List<Node> |
extractFragment(Configuration configuration,
List<Node> nodes)
Executes the fragment specification against a list of nodes representing a DOM tree
(or a set of trees), returning the extracted nodes.
|
DOMSelector.INodeReferenceChecker |
getReferenceChecker()
Returns the reference checker (implementation of
DOMSelector.INodeReferenceChecker
being used for executing the contained DOM Selector. |
String |
getSelectorExpression() |
String |
toString() |
public static final String DOM_SELECTOR_EXPRESSION_PREFIX
Prefix to be used for keys when storing selector expressions at the expression cache.
public DOMSelectorFragmentSpec(String selectorExpression)
Creates a new instance, specifying the expression to be used for a
DOMSelector
object to be created internally.
selectorExpression
- the expression to be used for the DOM selector.public DOMSelectorFragmentSpec(String selectorExpression, DOMSelector.INodeReferenceChecker referenceChecker)
Creates a new instance, specifying the expression to be used for a
DOMSelector
object to be created internally, and also the reference checker to be used.
This constructor allows the specification of an DOMSelector.INodeReferenceChecker
that will be applied during the executing of the contained DOMSelector
object.
selectorExpression
- the expression to be used for the DOM selector.referenceChecker
- the reference checker to be used. Might be null.public String getSelectorExpression()
public DOMSelector.INodeReferenceChecker getReferenceChecker()
Returns the reference checker (implementation of DOMSelector.INodeReferenceChecker
being used for executing the contained DOM Selector. Might be null if no reference checker is to be used.
public final List<Node> extractFragment(Configuration configuration, List<Node> nodes)
IFragmentSpec
Executes the fragment specification against a list of nodes representing a DOM tree (or a set of trees), returning the extracted nodes.
extractFragment
in interface IFragmentSpec
configuration
- the configuration object.nodes
- the list of nodes on which to apply extraction.Copyright © 2017 The THYMELEAF team. All rights reserved.