|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object org.thymeleaf.fragment.ElementAndAttributeNameFragmentSpec
public final class ElementAndAttributeNameFragmentSpec
Fragment specification that extracts a specific element from a Node tree by its name, or by the value of one of its attributes.
Objects of this class are thread-safe.
Constructor Summary | |
---|---|
ElementAndAttributeNameFragmentSpec(String elementName,
String attributeName,
String attributeValue)
Create a fragment spec specifying element name and/or attribute name+value. |
|
ElementAndAttributeNameFragmentSpec(String elementName,
String attributeName,
String attributeValue,
boolean returnOnlyChildren)
Create a fragment spec specifying element name and/or attribute name+value, and specifying whether the selected element itself (or selected elements if more than one) must be returned or only its/their children. |
Method Summary | |
---|---|
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. |
String |
getAttributeName()
Returns the (optional) attribute name. |
String |
getAttributeValue()
Returns the attribute value, if attributeName has been set. |
String |
getElementName()
Returns the (optional) element name. |
boolean |
isReturnOnlyChildren()
Returns whether this spec should only return the children of the selected nodes (true) or the selected nodes themselves (false, default). |
String |
toString()
|
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ElementAndAttributeNameFragmentSpec(String elementName, String attributeName, String attributeValue)
Create a fragment spec specifying element name and/or attribute name+value.
elementName
- the element name to look for, optional.attributeName
- the attribute name to look for, optional.attributeValue
- the value of the attribute (if attribute name has been specified).public ElementAndAttributeNameFragmentSpec(String elementName, String attributeName, String attributeValue, boolean returnOnlyChildren)
Create a fragment spec specifying element name and/or attribute name+value, and specifying whether the selected element itself (or selected elements if more than one) must be returned or only its/their children.
If returnOnlyChildren is true, the element with the specified name and/or containing the specified attribute will be discarded, and only its/their children will be returned.
elementName
- the element name to look for, optional.attributeName
- the attribute name to look for, optional.attributeValue
- the value of the attribute (if attribute name has been specified).returnOnlyChildren
- whether the selected elements should be returned (false),
or only their children (true).Method Detail |
---|
public String getElementName()
Returns the (optional) element name.
If this property is not null, this fragment specification will look for element(s) with the name specified here (note the element name is the tag name when processing markup).
Both elementName and attributeName can be set (non-null), and at least one of them must be set.
public String getAttributeName()
Returns the (optional) attribute name.
If this property is not null, this fragment specification will look for element(s) containing an attribute with the name specified here.
If this property is specified (not null), attributeValue must be specified too.
Both elementName and attributeName can be set (non-null), and at least one of them must be set.
public String getAttributeValue()
Returns the attribute value, if attributeName has been set. If attributeName is not null, this property should be set a value too.
This is the value that the attribute specified in attributeName should have in order for an element to be considered extractable by this fragment specification.
Both elementName and attributeName can be set (non-null), and at least one of them must be set.
public boolean isReturnOnlyChildren()
Returns whether this spec should only return the children of the selected nodes (true) or the selected nodes themselves (false, default).
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.
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |