org.thymeleaf
Class Arguments

Object
  extended by org.thymeleaf.Arguments

public final class Arguments
extends Object

Objects of this class contain all the required arguments for template processing.

These objects are created internally by the Template Engine in order to provide processors with all the information they might need for performing their tasks.

Arguments include many attributes, among which some should be used internally only, and never by developers of attribute/element processors. Public attributes are:

Since:
1.0
Author:
Daniel Fernández

Method Summary
 Arguments addLocalVariables(java.util.Map<String,Object> newVariables)
           Creates a new Arguments object by adding some new local variables to the existing map (the rest of the attributes are copied verbatim).
 Arguments addLocalVariablesAndProcessOnlyElementNodes(java.util.Map<String,Object> newVariables, boolean shouldProcessOnlyElementNodes)
           Creates a new Arguments object by setting new local variables and a new value for the processOnlyElementNodes flag.
 Arguments addLocalVariablesAndProcessOnlyElementNodesAndSetSelectionTarget(java.util.Map<String,Object> newVariables, boolean shouldProcessOnlyElementNodes, Object target)
           Creates a new Arguments object by adding new local variables, a new value for the processOnlyElementNodes flag and a selection target.
 Arguments addLocalVariablesAndSetSelectionTarget(java.util.Map<String,Object> newVariables, Object target)
           Creates a new Arguments object by setting new local variables and a selection target.
 Integer getAndIncrementIDSeq(String id)
           Returns a new index (ID count) for a specific value of the id attribute, and increments the count.
 java.util.Map<String,Object> getBaseContextVariables()
           Returns the map of base variables that should be made available to every expression evaluation operation (whenever variable evaluation is available).
 Configuration getConfiguration()
           Returns the Template Engine configuration being used for processing templates.
 IContext getContext()
           Returns the current context specified for template processing.
 Document getDocument()
           Returns the parsed Document DOM object.
 Object getExecutionAttribute(String attributeName)
           Returns the execution attribute with the specified name.
 java.util.Map<String,Object> getExecutionAttributes()
           Returns the execution attributes.
 Object getExpressionEvaluationRoot()
           Returns the current evaluation root.
 Object getExpressionSelectionEvaluationRoot()
           Returns the current selection evaluation root.
 java.util.Map<String,Integer> getIdCounts()
           Returns the map of ID counts.
 Object getLocalVariable(String variableName)
           Returns the value of a local variable.
 java.util.Map<String,Object> getLocalVariables()
           Returns a safe copy of the map of local variables.
 Integer getNextIDSeq(String id)
           Returns the index (ID count) for a specific value of the id attribute without incrementing the count.
 Integer getPreviousIDSeq(String id)
           Returns the last index (ID count) returned for a specific value of the id attribute (without incrementing the count).
 boolean getProcessOnlyElementNodes()
           Returns whether only element nodes should be processed (as opposed to texts, CDATAs, comments, etc.).
 org.thymeleaf.Arguments.SelectionTarget getSelectionTarget()
           Returns the current selection target (e.g. object selected by a th:object attribute in standard dialect).
 Object getSelectionTargetObject()
           Returns the selection target object, object contained by the result of getSelectionTarget(), and raises an exception if there isn't any.
 String getTemplateName()
           Returns the name of the template currently being processed.
 TemplateProcessingParameters getTemplateProcessingParameters()
           Returns the Template Processing Parameters used for resolving and parsing the template being processed.
 TemplateRepository getTemplateRepository()
           Returns the template repository in use.
 TemplateResolution getTemplateResolution()
           Returns the template resolution object corresponding to the template currently being processed.
 boolean hasLocalVariable(String variableName)
           Returns whether a specific local variable is defined or not.
 boolean hasLocalVariables()
           Returns whether local variables have currently been specified or not.
 boolean hasSelectionTarget()
           Returns whether there currently is a selection going on (e.g.
 Arguments setProcessOnlyElementNodes(boolean shouldProcessOnlyElementNodes)
           Creates a new Arguments object by setting a new value for the processOnlyElementNodes flag.
 Arguments setProcessOnlyElementNodesAndSetSelectionTarget(boolean shouldProcessOnlyElementNodes, Object target)
           Creates a new Arguments object by setting a new value for the processOnlyElementNodes flag and a selection target.
 Arguments setSelectionTarget(Object target)
           Creates a new Arguments object by setting a selection target.
 java.util.HashMap<String,Object> unsafeGetLocalVariables()
           Returns the real inner map of local variables.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTemplateProcessingParameters

public TemplateProcessingParameters getTemplateProcessingParameters()

Returns the Template Processing Parameters used for resolving and parsing the template being processed.

Returns:
the template processing parameters

getConfiguration

public Configuration getConfiguration()

Returns the Template Engine configuration being used for processing templates.

Returns:
the configuration

getTemplateResolution

public TemplateResolution getTemplateResolution()

Returns the template resolution object corresponding to the template currently being processed.

Returns:
the Template Resolution object

getTemplateRepository

public TemplateRepository getTemplateRepository()

Returns the template repository in use.

Returns:
the Template Repository object

getDocument

public Document getDocument()

Returns the parsed Document DOM object.

Returns:
the Document object

getTemplateName

public String getTemplateName()

Returns the name of the template currently being processed.

Returns:
the template name

getContext

public IContext getContext()

Returns the current context specified for template processing.

Returns:
the current context

hasLocalVariables

public boolean hasLocalVariables()

Returns whether local variables have currently been specified or not. (e.g. th:with in standard dialect).

Returns:
true if there are local variables, false if not

getLocalVariable

public Object getLocalVariable(String variableName)

Returns the value of a local variable.

Parameters:
variableName - the name of the local variable to be returned
Returns:
the value of the variable, or null if the variable does not exist (or has null value)

hasLocalVariable

public boolean hasLocalVariable(String variableName)

Returns whether a specific local variable is defined or not.

Returns:
true if the variable is currently defined, false if not.

unsafeGetLocalVariables

public java.util.HashMap<String,Object> unsafeGetLocalVariables()

Returns the real inner map of local variables. This method should not be called directly.

Returns:
the local variables map, which could be null if no variables are defined

getLocalVariables

public java.util.Map<String,Object> getLocalVariables()

Returns a safe copy of the map of local variables.

Returns:
the local variables

getProcessOnlyElementNodes

public boolean getProcessOnlyElementNodes()

Returns whether only element nodes should be processed (as opposed to texts, CDATAs, comments, etc.). Default is true.

Returns:
whether only element nodes will be processed

hasSelectionTarget

public boolean hasSelectionTarget()

Returns whether there currently is a selection going on (e.g. th:object in standard dialect).

Returns:
true if there is a selection currently established, false if not

getSelectionTarget

public org.thymeleaf.Arguments.SelectionTarget getSelectionTarget()

Returns the current selection target (e.g. object selected by a th:object attribute in standard dialect).

Returns:
the current selection target, if there is any

getSelectionTargetObject

public Object getSelectionTargetObject()

Returns the selection target object, object contained by the result of getSelectionTarget(), and raises an exception if there isn't any.

Meant for internal use.

Returns:
the selection target object

getIdCounts

public java.util.Map<String,Integer> getIdCounts()

Returns the map of ID counts.

These numbers are used to avoid conflicts among elements with the same id attribute; for example elements being repeated as a part of a th:each iteration.

Returns:
the current map of ID counts

getExecutionAttributes

public java.util.Map<String,Object> getExecutionAttributes()

Returns the execution attributes.

Returns:
the current map of execution attributes

getExecutionAttribute

public Object getExecutionAttribute(String attributeName)

Returns the execution attribute with the specified name.

Parameters:
attributeName - the name of the attribute to be retrieved
Returns:
the value of the attribute

getExpressionEvaluationRoot

public Object getExpressionEvaluationRoot()

Returns the current evaluation root. This is the object on which expressions (normal expressions, like those specified in the standard dialect with ${...}) are executed.

Returns:
the expression evaluation root

getExpressionSelectionEvaluationRoot

public Object getExpressionSelectionEvaluationRoot()

Returns the current selection evaluation root. This is the object on which selection expressions (like those specified in the standard dialect with *{...}) are executed.

Returns:
the selection evaluation root

getBaseContextVariables

public java.util.Map<String,Object> getBaseContextVariables()

Returns the map of base variables that should be made available to every expression evaluation operation (whenever variable evaluation is available).

Returns:
the map of variables (a new object, mutable, safe to use as a context variables base)
Since:
2.0.0

getAndIncrementIDSeq

public Integer getAndIncrementIDSeq(String id)

Returns a new index (ID count) for a specific value of the id attribute, and increments the count.

Parameters:
id - the ID for which the count will be computed
Returns:
the new count, ready to be used

getNextIDSeq

public Integer getNextIDSeq(String id)

Returns the index (ID count) for a specific value of the id attribute without incrementing the count.

Parameters:
id - the ID for which the count will be retrieved
Returns:
the current count

getPreviousIDSeq

public Integer getPreviousIDSeq(String id)

Returns the last index (ID count) returned for a specific value of the id attribute (without incrementing the count).

Parameters:
id - the ID for which the last count will be retrieved
Returns:
the count

addLocalVariables

public Arguments addLocalVariables(java.util.Map<String,Object> newVariables)

Creates a new Arguments object by adding some new local variables to the existing map (the rest of the attributes are copied verbatim).

Parameters:
newVariables - the new variables
Returns:
the new Arguments object

setSelectionTarget

public Arguments setSelectionTarget(Object target)

Creates a new Arguments object by setting a selection target.

Parameters:
target - the new selection target object
Returns:
the new Arguments object

addLocalVariablesAndSetSelectionTarget

public Arguments addLocalVariablesAndSetSelectionTarget(java.util.Map<String,Object> newVariables,
                                                        Object target)

Creates a new Arguments object by setting new local variables and a selection target.

Parameters:
newVariables - the new local variables
target - the new selection target object
Returns:
the new Arguments object

setProcessOnlyElementNodes

public Arguments setProcessOnlyElementNodes(boolean shouldProcessOnlyElementNodes)

Creates a new Arguments object by setting a new value for the processOnlyElementNodes flag.

Parameters:
shouldProcessOnlyElementNodes - whether only element nodes should be processed from this moment in template execution
Returns:
the new Arguments object

addLocalVariablesAndProcessOnlyElementNodes

public Arguments addLocalVariablesAndProcessOnlyElementNodes(java.util.Map<String,Object> newVariables,
                                                             boolean shouldProcessOnlyElementNodes)

Creates a new Arguments object by setting new local variables and a new value for the processOnlyElementNodes flag.

Parameters:
newVariables - the new local variables
shouldProcessOnlyElementNodes - whether only element nodes should be processed from this moment in template execution
Returns:
the new Arguments object

setProcessOnlyElementNodesAndSetSelectionTarget

public Arguments setProcessOnlyElementNodesAndSetSelectionTarget(boolean shouldProcessOnlyElementNodes,
                                                                 Object target)

Creates a new Arguments object by setting a new value for the processOnlyElementNodes flag and a selection target.

Parameters:
shouldProcessOnlyElementNodes - whether only element nodes should be processed from this moment in template execution
target - the new selection target object
Returns:
the new Arguments object

addLocalVariablesAndProcessOnlyElementNodesAndSetSelectionTarget

public Arguments addLocalVariablesAndProcessOnlyElementNodesAndSetSelectionTarget(java.util.Map<String,Object> newVariables,
                                                                                  boolean shouldProcessOnlyElementNodes,
                                                                                  Object target)

Creates a new Arguments object by adding new local variables, a new value for the processOnlyElementNodes flag and a selection target.

Parameters:
newVariables - the new local variables
shouldProcessOnlyElementNodes - whether only element nodes should be processed from this moment in template execution
target - the new selection target object
Returns:
the new Arguments object


Copyright © 2012 The THYMELEAF team. All Rights Reserved.