Class ElementTagStructureHandler
- Object
-
- org.thymeleaf.engine.ElementTagStructureHandler
-
- All Implemented Interfaces:
IElementTagStructureHandler
public final class ElementTagStructureHandler extends Object implements IElementTagStructureHandler
Structure handler implementation, internally used by the engine.
This class should not be directly used from outside the engine.
- Since:
- 3.0.0
- Author:
- Daniel Fernández
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
insertBefore(IModel model)
Instructs the engine to insert the specified model just before the element being processed.void
insertImmediatelyAfter(IModel model, boolean processable)
Instructs the engine to insert the specified model just after the element being processed.void
iterateElement(String iterVariableName, String iterStatusVariableName, Object iteratedObject)
Instructs the engine to iterate the current element, applying a specific iteration configuration.void
removeAllButFirstChild()
Instructs the engine to remove all the children of the element being processed, except the first one (the first element, not text or others).void
removeAttribute(String attributeName)
Instructs the engine to remove an attribute from the tag being processed.void
removeAttribute(String prefix, String name)
Instructs the engine to remove an attribute from the tag being processed.void
removeAttribute(AttributeName attributeName)
Instructs the engine to remove an attribute from the tag being processed.void
removeBody()
Instructs the engine to remove the body of the element being processed, but keep the open and close tags.void
removeElement()
Instructs the engine to remove the entire element that is being processed (open tag, body, close tag).void
removeLocalVariable(String name)
Instructs the engine to remove a local variable.void
removeTags()
Instructs the engine to remove the tags delimiting the element being processed (open and close tag), but keep the body.void
replaceAttribute(AttributeName oldAttributeName, String attributeName, String attributeValue)
Instructs the engine to replace an existing attribute for a new one (which can also exist) in the current tag being processed.void
replaceAttribute(AttributeName oldAttributeName, String attributeName, String attributeValue, AttributeValueQuotes attributeValueQuotes)
Instructs the engine to replace an existing attribute for a new one (which can also exist) in the current tag being processed.void
replaceAttribute(AttributeName oldAttributeName, AttributeDefinition attributeDefinition, String attributeName, String attributeValue, AttributeValueQuotes attributeValueQuotes)
void
replaceWith(CharSequence text, boolean processable)
Instructs the engine to replace the current element with the specified text (aCharSequence
).void
replaceWith(IModel model, boolean processable)
Instructs the engine to replace the current element with the specified model (aIModel
).void
reset()
Resets all actions specified so far for the current processor execution.void
setAttribute(String attributeName, String attributeValue)
Instructs the engine to set an attribute (existing or not) in the current tag being processed.void
setAttribute(String attributeName, String attributeValue, AttributeValueQuotes attributeValueQuotes)
Instructs the engine to set an attribute (existing or not) in the current tag being processed.void
setAttribute(AttributeDefinition attributeDefinition, String attributeName, String attributeValue, AttributeValueQuotes attributeValueQuotes)
void
setBody(CharSequence text, boolean processable)
Instructs the engine to set a new body for the current element, in the form of aCharSequence
.void
setBody(IModel model, boolean processable)
Instructs the engine to set a new body for the current element, in the form of anIModel
.void
setInliner(IInliner inliner)
Instructs the engine to set a new inliner.void
setLocalVariable(String name, Object value)
Instructs the engine to set a new local variable.void
setSelectionTarget(Object selectionTarget)
Instructs the engine to set a new selection target.void
setTemplateData(TemplateData templateData)
Instructs the engine to set a new template data.
-
-
-
Method Detail
-
setBody
public void setBody(CharSequence text, boolean processable)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to set a new body for the current element, in the form of a
CharSequence
.This is the way a processor can change what is shown inside an element during processing. For example, it is this way how
th:text
changes the contents of its containing element.- Specified by:
setBody
in interfaceIElementTagStructureHandler
- Parameters:
text
- the text to be used as the new body.processable
- whether the text being set should be considered processable, and therefore anyITextProcessor
processors might be applied on it, or not.
-
setBody
public void setBody(IModel model, boolean processable)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to set a new body for the current element, in the form of an
IModel
.This is the way a processor can change what is shown inside an element during processing. For example, it is this way how
th:utext
changes the contents of its containing element.- Specified by:
setBody
in interfaceIElementTagStructureHandler
- Parameters:
model
- the model to be used as the new body.processable
- whether the model being set should be considered processable, and therefore any processors might be applied on its events, or not.
-
insertBefore
public void insertBefore(IModel model)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to insert the specified model just before the element being processed.
Processors can use this method to insert content before the tag they are processing, but with the limitation that such content (in the form of an
IModel
) cannot be processable, i.e. no processors will be executed on their elements or texts.- Specified by:
insertBefore
in interfaceIElementTagStructureHandler
- Parameters:
model
- the model to be inserted
-
insertImmediatelyAfter
public void insertImmediatelyAfter(IModel model, boolean processable)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to insert the specified model just after the element being processed.
Processors can use this method to insert content just after the tag they are processing. Note that such content will be inserted after the tag, not the element, which in practice means that if the tag is an open tag, the new content will be inserted as the first part of the element's body.
- Specified by:
insertImmediatelyAfter
in interfaceIElementTagStructureHandler
- Parameters:
model
- the model to be inserted.processable
- whether the inserted model should be considered processable or not (i.e. whether processors should be executed on it).
-
replaceWith
public void replaceWith(CharSequence text, boolean processable)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to replace the current element with the specified text (a
CharSequence
).Note it is the complete element that will be replaced with the specified text, i.e. the open tag, the body and the close tag.
- Specified by:
replaceWith
in interfaceIElementTagStructureHandler
- Parameters:
text
- the text to be used as a replacement.processable
- whether the text should be considered processable or not.
-
replaceWith
public void replaceWith(IModel model, boolean processable)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to replace the current element with the specified model (a
IModel
).Note it is the complete element that will be replaced with the specified model, i.e. the open tag, the body and the close tag.
- Specified by:
replaceWith
in interfaceIElementTagStructureHandler
- Parameters:
model
- the model to be used as a replacement.processable
- whether the model should be considered processable or not.
-
removeElement
public void removeElement()
Description copied from interface:IElementTagStructureHandler
Instructs the engine to remove the entire element that is being processed (open tag, body, close tag).
- Specified by:
removeElement
in interfaceIElementTagStructureHandler
-
removeTags
public void removeTags()
Description copied from interface:IElementTagStructureHandler
Instructs the engine to remove the tags delimiting the element being processed (open and close tag), but keep the body.
- Specified by:
removeTags
in interfaceIElementTagStructureHandler
-
removeBody
public void removeBody()
Description copied from interface:IElementTagStructureHandler
Instructs the engine to remove the body of the element being processed, but keep the open and close tags.
- Specified by:
removeBody
in interfaceIElementTagStructureHandler
-
removeAllButFirstChild
public void removeAllButFirstChild()
Description copied from interface:IElementTagStructureHandler
Instructs the engine to remove all the children of the element being processed, except the first one (the first element, not text or others).
- Specified by:
removeAllButFirstChild
in interfaceIElementTagStructureHandler
-
removeLocalVariable
public void removeLocalVariable(String name)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to remove a local variable.
- Specified by:
removeLocalVariable
in interfaceIElementTagStructureHandler
- Parameters:
name
- the name of the variable.
-
setLocalVariable
public void setLocalVariable(String name, Object value)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to set a new local variable.
- Specified by:
setLocalVariable
in interfaceIElementTagStructureHandler
- Parameters:
name
- the name of the variable.value
- the value of the variable.
-
setAttribute
public void setAttribute(String attributeName, String attributeValue)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to set an attribute (existing or not) in the current tag being processed.
- Specified by:
setAttribute
in interfaceIElementTagStructureHandler
- Parameters:
attributeName
- the name of the attribute.attributeValue
- the value of the attribute.
-
setAttribute
public void setAttribute(String attributeName, String attributeValue, AttributeValueQuotes attributeValueQuotes)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to set an attribute (existing or not) in the current tag being processed.
- Specified by:
setAttribute
in interfaceIElementTagStructureHandler
- Parameters:
attributeName
- the name of the attribute.attributeValue
- the value of the attribute.attributeValueQuotes
- the type of quotes to be set for the attribute.
-
setAttribute
public void setAttribute(AttributeDefinition attributeDefinition, String attributeName, String attributeValue, AttributeValueQuotes attributeValueQuotes)
-
replaceAttribute
public void replaceAttribute(AttributeName oldAttributeName, String attributeName, String attributeValue)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to replace an existing attribute for a new one (which can also exist) in the current tag being processed.
- Specified by:
replaceAttribute
in interfaceIElementTagStructureHandler
- Parameters:
oldAttributeName
- the name of the attribute to be replaced.attributeName
- the name of the new attribute.attributeValue
- the value of the new attribute.
-
replaceAttribute
public void replaceAttribute(AttributeName oldAttributeName, String attributeName, String attributeValue, AttributeValueQuotes attributeValueQuotes)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to replace an existing attribute for a new one (which can also exist) in the current tag being processed.
- Specified by:
replaceAttribute
in interfaceIElementTagStructureHandler
- Parameters:
oldAttributeName
- the name of the attribute to be replaced.attributeName
- the name of the new attribute.attributeValue
- the value of the new attribute.attributeValueQuotes
- the type of quotes to be set for the attribute.
-
replaceAttribute
public void replaceAttribute(AttributeName oldAttributeName, AttributeDefinition attributeDefinition, String attributeName, String attributeValue, AttributeValueQuotes attributeValueQuotes)
-
removeAttribute
public void removeAttribute(String attributeName)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to remove an attribute from the tag being processed.
- Specified by:
removeAttribute
in interfaceIElementTagStructureHandler
- Parameters:
attributeName
- the complete name of the attribute to be removed.
-
removeAttribute
public void removeAttribute(String prefix, String name)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to remove an attribute from the tag being processed.
- Specified by:
removeAttribute
in interfaceIElementTagStructureHandler
- Parameters:
prefix
- the prefix of the attribute to be removed.name
- the name of the attribute to be removed.
-
removeAttribute
public void removeAttribute(AttributeName attributeName)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to remove an attribute from the tag being processed.
- Specified by:
removeAttribute
in interfaceIElementTagStructureHandler
- Parameters:
attributeName
- the name of the attribute to be removed.
-
setSelectionTarget
public void setSelectionTarget(Object selectionTarget)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to set a new selection target.
The selection target is the object on which selection expressions
(*{...})
are executed. In the Standard Dialect, this selection target is usually modified by means of theth:object
attribute, but custom processors can do it too. Note the selection target has the same scope as a local variable, and will therefore be accessible only inside the body of the element being processed.- Specified by:
setSelectionTarget
in interfaceIElementTagStructureHandler
- Parameters:
selectionTarget
- the selection target to be set.
-
setInliner
public void setInliner(IInliner inliner)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to set a new inliner.
Inliners are used for processing all text nodes (
IText
events) appearing in the body of the element being processed. This is the mechanism used by the th:inline attribute to enable inlining in any of the specified modes (text, javascript, etc).- Specified by:
setInliner
in interfaceIElementTagStructureHandler
- Parameters:
inliner
- the inliner.
-
setTemplateData
public void setTemplateData(TemplateData templateData)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to set a new template data.
This method modifies the metadata about the template that is actually being processed. When inserting fragments, this allows the engine to know data about the specific fragment being processed, and also the complete stack of fragments being nested.
- Specified by:
setTemplateData
in interfaceIElementTagStructureHandler
- Parameters:
templateData
- the template data.
-
iterateElement
public void iterateElement(String iterVariableName, String iterStatusVariableName, Object iteratedObject)
Description copied from interface:IElementTagStructureHandler
Instructs the engine to iterate the current element, applying a specific iteration configuration.
This method specifies the name of both the iteration variable name and the iterStatus variable name, and also the object that should be iterated (usually a
Collection
,Iterable
or similar).- Specified by:
iterateElement
in interfaceIElementTagStructureHandler
- Parameters:
iterVariableName
- the name of the iteration variable.iterStatusVariableName
- the name of the iterations status variable.iteratedObject
- the object to be iterated.
-
reset
public void reset()
Description copied from interface:IElementTagStructureHandler
Resets all actions specified so far for the current processor execution.
- Specified by:
reset
in interfaceIElementTagStructureHandler
-
-