Package org.apache.tiles
Class BasicAttributeContext
- java.lang.Object
-
- org.apache.tiles.BasicAttributeContext
-
- All Implemented Interfaces:
java.io.Serializable,AttributeContext
- Direct Known Subclasses:
Definition
public class BasicAttributeContext extends java.lang.Object implements AttributeContext, java.io.Serializable
Basic implementation forAttributeContext.- Since:
- 2.1.0
- Version:
- $Rev: 943645 $ $Date: 2010-05-13 05:33:19 +1000 (Thu, 13 May 2010) $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,Attribute>attributesTemplate attributes.protected java.util.Map<java.lang.String,Attribute>cascadedAttributesCascaded template attributes.protected java.lang.StringpreparerAssociated ViewPreparer URL or classname, if defined.protected AttributetemplateAttributeThe template attribute, to render a template.
-
Constructor Summary
Constructors Constructor Description BasicAttributeContext()Constructor.BasicAttributeContext(java.util.Map<java.lang.String,Attribute> attributes)Constructor.BasicAttributeContext(AttributeContext context)Copy constructor.BasicAttributeContext(BasicAttributeContext context)Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAll(java.util.Map<java.lang.String,Attribute> newAttributes)Add all attributes to this context.voidaddMissing(java.util.Map<java.lang.String,Attribute> defaultAttributes)Add all missing attributes to this context.voidclear()Clear the attributes.booleanequals(java.lang.Object obj)AttributegetAttribute(java.lang.String name)Retrieve the named attribute, either cascaded or not.AttributegetCascadedAttribute(java.lang.String name)Retrieve the attribute that has been cascaded at upper levels.java.util.Set<java.lang.String>getCascadedAttributeNames()Returns the names of the cascaded attributes.AttributegetLocalAttribute(java.lang.String name)Retrieve the attribute that has been defined in this context (i.e.java.util.Set<java.lang.String>getLocalAttributeNames()Returns the names of the local attributes, i.e.java.lang.StringgetPreparer()Get associated preparer instance.AttributegetTemplateAttribute()Returns the attribute that will be used to render a template.inthashCode()voidinherit(AttributeContext parent)Copies all missing attributes from theparentattribute context to this one.voidinherit(BasicAttributeContext parent)Inherits the attribute context, inheriting, i.e.voidinheritCascadedAttributes(AttributeContext context)Copies the cascaded attributes to this attribute context.voidputAttribute(java.lang.String name, Attribute value)Add the specified attribute.voidputAttribute(java.lang.String name, Attribute value, boolean cascade)Add the specified attribute.voidsetPreparer(java.lang.String url)Set associated preparer instance.voidsetTemplateAttribute(Attribute templateAttribute)Sets the template attribute, that will be used to render the template page.
-
-
-
Field Detail
-
templateAttribute
protected Attribute templateAttribute
The template attribute, to render a template.- Since:
- 2.1.2
-
preparer
protected java.lang.String preparer
Associated ViewPreparer URL or classname, if defined.- Since:
- 2.1.0
-
attributes
protected java.util.Map<java.lang.String,Attribute> attributes
Template attributes.- Since:
- 2.1.0
-
cascadedAttributes
protected java.util.Map<java.lang.String,Attribute> cascadedAttributes
Cascaded template attributes.- Since:
- 2.1.0
-
-
Constructor Detail
-
BasicAttributeContext
public BasicAttributeContext()
Constructor.- Since:
- 2.1.0
-
BasicAttributeContext
public BasicAttributeContext(java.util.Map<java.lang.String,Attribute> attributes)
Constructor. Create a context and set specified attributes.- Parameters:
attributes- Attributes to initialize context.- Since:
- 2.1.0
-
BasicAttributeContext
public BasicAttributeContext(AttributeContext context)
Copy constructor.- Parameters:
context- The constructor to copy.- Since:
- 2.1.0
-
BasicAttributeContext
public BasicAttributeContext(BasicAttributeContext context)
Copy constructor.- Parameters:
context- The constructor to copy.- Since:
- 2.1.0
-
-
Method Detail
-
getTemplateAttribute
public Attribute getTemplateAttribute()
Returns the attribute that will be used to render a template.- Specified by:
getTemplateAttributein interfaceAttributeContext- Returns:
- The template attribute.
-
setTemplateAttribute
public void setTemplateAttribute(Attribute templateAttribute)
Sets the template attribute, that will be used to render the template page.- Specified by:
setTemplateAttributein interfaceAttributeContext- Parameters:
templateAttribute- The template attribute.
-
getPreparer
public java.lang.String getPreparer()
Get associated preparer instance.- Specified by:
getPreparerin interfaceAttributeContext- Returns:
- The preparer name.
-
setPreparer
public void setPreparer(java.lang.String url)
Set associated preparer instance.- Specified by:
setPreparerin interfaceAttributeContext- Parameters:
url- The preparer name.
-
inheritCascadedAttributes
public void inheritCascadedAttributes(AttributeContext context)
Copies the cascaded attributes to this attribute context.- Specified by:
inheritCascadedAttributesin interfaceAttributeContext- Parameters:
context- The parent context to be used.
-
inherit
public void inherit(AttributeContext parent)
Copies all missing attributes from theparentattribute context to this one.- Specified by:
inheritin interfaceAttributeContext- Parameters:
parent- The attribute context to copy attributes from.
-
inherit
public void inherit(BasicAttributeContext parent)
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
public void addAll(java.util.Map<java.lang.String,Attribute> newAttributes)
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:
addAllin interfaceAttributeContext- Parameters:
newAttributes- Attributes to add.- Since:
- 2.1.0
-
addMissing
public void addMissing(java.util.Map<java.lang.String,Attribute> defaultAttributes)
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:
addMissingin interfaceAttributeContext- Parameters:
defaultAttributes- Attributes to add.- Since:
- 2.1.0
-
getAttribute
public Attribute getAttribute(java.lang.String name)
Retrieve the named attribute, either cascaded or not.- Specified by:
getAttributein interfaceAttributeContext- Parameters:
name- key name for the attribute.- Returns:
- Attribute associated with the given name.
-
getLocalAttribute
public Attribute getLocalAttribute(java.lang.String name)
Retrieve the attribute that has been defined in this context (i.e. not cascaded).- Specified by:
getLocalAttributein interfaceAttributeContext- Parameters:
name- key name for the attribute.- Returns:
- Attribute The local attribute associated with the given name, if
present, or
nullotherwise.
-
getCascadedAttribute
public Attribute getCascadedAttribute(java.lang.String name)
Retrieve the attribute that has been cascaded at upper levels.- Specified by:
getCascadedAttributein interfaceAttributeContext- Parameters:
name- key name for the attribute.- Returns:
- Attribute The cascaded attribute associated with the given name,
if present, or
nullotherwise.
-
getLocalAttributeNames
public java.util.Set<java.lang.String> getLocalAttributeNames()
Returns the names of the local attributes, i.e. the one that have not been cascaded.- Specified by:
getLocalAttributeNamesin interfaceAttributeContext- Returns:
- The local attribute names.
-
getCascadedAttributeNames
public java.util.Set<java.lang.String> getCascadedAttributeNames()
Returns the names of the cascaded attributes.- Specified by:
getCascadedAttributeNamesin interfaceAttributeContext- Returns:
- The cascaded attribute names.
-
putAttribute
public void putAttribute(java.lang.String name, Attribute value)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:
putAttributein interfaceAttributeContext- Parameters:
name- name of the attributevalue- value of the attribute
-
putAttribute
public void putAttribute(java.lang.String name, Attribute value, boolean cascade)Add the specified attribute.- Specified by:
putAttributein 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:
clearin interfaceAttributeContext
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-