Package org.apache.tiles
Class BasicAttributeContext
java.lang.Object
org.apache.tiles.BasicAttributeContext
- All Implemented Interfaces:
Serializable
,AttributeContext
- Direct Known Subclasses:
Definition
Basic implementation for
AttributeContext
.- Since:
- 2.1.0
- Version:
- $Rev: 943645 $ $Date: 2010-05-13 05:33:19 +1000 (Thu, 13 May 2010) $
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.BasicAttributeContext
(Map<String, Attribute> attributes) Constructor.BasicAttributeContext
(AttributeContext context) Copy constructor.Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add all attributes to this context.void
addMissing
(Map<String, Attribute> defaultAttributes) Add all missing attributes to this context.void
clear()
Clear the attributes.boolean
getAttribute
(String name) Retrieve the named attribute, either cascaded or not.getCascadedAttribute
(String name) Retrieve the attribute that has been cascaded at upper levels.Returns the names of the cascaded attributes.getLocalAttribute
(String name) Retrieve the attribute that has been defined in this context (i.e.Returns the names of the local attributes, i.e.Get associated preparer instance.Returns the attribute that will be used to render a template.int
hashCode()
void
inherit
(AttributeContext parent) Copies all missing attributes from theparent
attribute context to this one.void
inherit
(BasicAttributeContext parent) Inherits the attribute context, inheriting, i.e.void
Copies the cascaded attributes to this attribute context.void
putAttribute
(String name, Attribute value) Add the specified attribute.void
putAttribute
(String name, Attribute value, boolean cascade) Add the specified attribute.void
setPreparer
(String url) Set associated preparer instance.void
setTemplateAttribute
(Attribute templateAttribute) Sets the template attribute, that will be used to render the template page.
-
Field Details
-
templateAttribute
The template attribute, to render a template.- Since:
- 2.1.2
-
preparer
Associated ViewPreparer URL or classname, if defined.- Since:
- 2.1.0
-
attributes
Template attributes.- Since:
- 2.1.0
-
cascadedAttributes
Cascaded template attributes.- Since:
- 2.1.0
-
-
Constructor Details
-
BasicAttributeContext
public BasicAttributeContext()Constructor.- Since:
- 2.1.0
-
BasicAttributeContext
Constructor. Create a context and set specified attributes.- Parameters:
attributes
- Attributes to initialize context.- Since:
- 2.1.0
-
BasicAttributeContext
Copy constructor.- Parameters:
context
- The constructor to copy.- Since:
- 2.1.0
-
BasicAttributeContext
Copy constructor.- Parameters:
context
- The constructor to copy.- Since:
- 2.1.0
-
-
Method Details
-
getTemplateAttribute
Returns the attribute that will be used to render a template.- Specified by:
getTemplateAttribute
in interfaceAttributeContext
- Returns:
- The template attribute.
-
setTemplateAttribute
Sets the template attribute, that will be used to render the template page.- Specified by:
setTemplateAttribute
in interfaceAttributeContext
- Parameters:
templateAttribute
- The template attribute.
-
getPreparer
Get associated preparer instance.- Specified by:
getPreparer
in interfaceAttributeContext
- Returns:
- The preparer name.
-
setPreparer
Set associated preparer instance.- Specified by:
setPreparer
in interfaceAttributeContext
- Parameters:
url
- The preparer name.
-
inheritCascadedAttributes
Copies the cascaded attributes to this attribute context.- Specified by:
inheritCascadedAttributes
in interfaceAttributeContext
- Parameters:
context
- The parent context to be used.
-
inherit
Copies all missing attributes from theparent
attribute context to this one.- Specified by:
inherit
in interfaceAttributeContext
- Parameters:
parent
- The attribute context to copy attributes from.
-
inherit
Inherits the attribute context, inheriting, i.e. copying if not present, the attributes.- Parameters:
parent
- The attribute context to inherit.- Since:
- 2.1.0
-
addAll
Add all attributes to this context. Copies all of the mappings from the specified attribute map to this context. New attribute mappings will replace any mappings that this context had for any of the keys currently in the specified attribute map.- Specified by:
addAll
in interfaceAttributeContext
- Parameters:
newAttributes
- Attributes to add.- Since:
- 2.1.0
-
addMissing
Add all missing attributes to this context. Copies all of the mappings from the specified attributes map to this context. New attribute mappings will be added only if they don't already exist in this context.- Specified by:
addMissing
in interfaceAttributeContext
- Parameters:
defaultAttributes
- Attributes to add.- Since:
- 2.1.0
-
getAttribute
Retrieve the named attribute, either cascaded or not.- Specified by:
getAttribute
in interfaceAttributeContext
- Parameters:
name
- key name for the attribute.- Returns:
- Attribute associated with the given name.
-
getLocalAttribute
Retrieve the attribute that has been defined in this context (i.e. not cascaded).- Specified by:
getLocalAttribute
in interfaceAttributeContext
- Parameters:
name
- key name for the attribute.- Returns:
- Attribute The local attribute associated with the given name, if
present, or
null
otherwise.
-
getCascadedAttribute
Retrieve the attribute that has been cascaded at upper levels.- Specified by:
getCascadedAttribute
in interfaceAttributeContext
- Parameters:
name
- key name for the attribute.- Returns:
- Attribute The cascaded attribute associated with the given name,
if present, or
null
otherwise.
-
getLocalAttributeNames
Returns the names of the local attributes, i.e. the one that have not been cascaded.- Specified by:
getLocalAttributeNames
in interfaceAttributeContext
- Returns:
- The local attribute names.
-
getCascadedAttributeNames
Returns the names of the cascaded attributes.- Specified by:
getCascadedAttributeNames
in interfaceAttributeContext
- Returns:
- The cascaded attribute names.
-
putAttribute
Add the specified attribute. The attribute value will be available only in the current context, i.e. it is like callingAttributeContext.putAttribute(String, Attribute, boolean)
withcascade = false
.- Specified by:
putAttribute
in interfaceAttributeContext
- Parameters:
name
- name of the attributevalue
- value of the attribute
-
putAttribute
Add the specified attribute.- Specified by:
putAttribute
in interfaceAttributeContext
- Parameters:
name
- name of the attributevalue
- value of the attributecascade
- Iftrue
, the attribute value will be available in all nested contexts. Iffalse
, it will be available only in the current context.
-
clear
public void clear()Clear the attributes.- Specified by:
clear
in interfaceAttributeContext
-
equals
-
hashCode
public int hashCode()
-