org.apache.tiles
Class BasicAttributeContext

Package class diagram package BasicAttributeContext
java.lang.Object
  extended by org.apache.tiles.BasicAttributeContext
All Implemented Interfaces:
java.io.Serializable, AttributeContext
Direct Known Subclasses:
BasicAttributeContext, Definition

public class BasicAttributeContext
extends java.lang.Object
implements AttributeContext, java.io.Serializable

Basic implementation for AttributeContext.

Since:
2.1.0
See Also:
Serialized Form

Field Summary
protected  java.util.Map<java.lang.String,Attribute> attributes
          Template attributes.
protected  java.util.Map<java.lang.String,Attribute> cascadedAttributes
          Cascaded template attributes.
protected  java.lang.String preparer
          Associated ViewPreparer URL or classname, if defined.
protected  java.util.Set<java.lang.String> roles
          The roles that can render this definition.
protected  java.lang.String template
          Template path.
 
Constructor Summary
BasicAttributeContext()
          Constructor.
BasicAttributeContext(AttributeContext context)
          Copy constructor.
BasicAttributeContext(BasicAttributeContext context)
          Copy constructor.
BasicAttributeContext(java.util.Map<java.lang.String,Attribute> attributes)
          Constructor.
 
Method Summary
 void addAll(java.util.Map<java.lang.String,Attribute> newAttributes)
          Add all attributes to this context.
 void addMissing(java.util.Map<java.lang.String,Attribute> defaultAttributes)
          Add all missing attributes to this context.
 void clear()
          Clear the attributes.
 Attribute getAttribute(java.lang.String name)
          Retrieve the named attribute, either cascaded or not.
 java.util.Iterator<java.lang.String> getAttributeNames()
          Iterator of all attribute names.
 Attribute getCascadedAttribute(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.
 Attribute getLocalAttribute(java.lang.String name)
          Retrieve the attribute that has been defined in this context (i.e. not cascaded).
 java.util.Set<java.lang.String> getLocalAttributeNames()
          Returns the names of the local attributes, i.e. the one that have not been cascaded.
 java.lang.String getPreparer()
          Get associated preparer instance.
 java.lang.String getRole()
          Access method for the role property.
 java.util.Set<java.lang.String> getRoles()
          Returns the roles that can render this attribute.
 java.lang.String getTemplate()
          Access method for the template property.
 void inherit(AttributeContext parent)
          Copies all missing attributes from the parent attribute context to this one.
 void inherit(BasicAttributeContext parent)
          Inherits the attribute context, inheriting, i.e. copying if not present, the attributes.
 void inheritCascadedAttributes(AttributeContext context)
          Copies the cascaded attributes to this attribute context.
 void putAttribute(java.lang.String name, Attribute value)
          Add the specified attribute.
 void putAttribute(java.lang.String name, Attribute value, boolean cascade)
          Add the specified attribute.
 void setPreparer(java.lang.String url)
          Set associated preparer instance.
 void setRole(java.lang.String role)
          Sets the value of the role property.
 void setRoles(java.util.Set<java.lang.String> roles)
          Sets the roles that can render this attribute.
 void setTemplate(java.lang.String template)
          Sets the value of the template property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

template

protected java.lang.String template
Template path.

Since:
2.1.0

roles

protected java.util.Set<java.lang.String> roles
The roles that can render this definition.

Since:
2.1.0

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

getTemplate

public java.lang.String getTemplate()
Access method for the template property.

Specified by:
getTemplate in interface AttributeContext
Returns:
the current value of the template property

setTemplate

public void setTemplate(java.lang.String template)
Sets the value of the template property.

Specified by:
setTemplate in interface AttributeContext
Parameters:
template - the new value of the path property

getRole

public java.lang.String getRole()
Access method for the role property.

Specified by:
getRole in interface AttributeContext
Returns:
the current value of the role property

getRoles

public java.util.Set<java.lang.String> getRoles()
Returns the roles that can render this attribute.

Specified by:
getRoles in interface AttributeContext
Returns:
The enabled roles.

setRole

public void setRole(java.lang.String role)
Sets the value of the role property.

Specified by:
setRole in interface AttributeContext
Parameters:
role - the new value of the role property

setRoles

public void setRoles(java.util.Set<java.lang.String> roles)
Sets the roles that can render this attribute.

Specified by:
setRoles in interface AttributeContext
Parameters:
roles - The enabled roles.

getPreparer

public java.lang.String getPreparer()
Get associated preparer instance.

Specified by:
getPreparer in interface AttributeContext
Returns:
The preparer name.

setPreparer

public void setPreparer(java.lang.String url)
Set associated preparer instance.

Specified by:
setPreparer in interface AttributeContext
Parameters:
url - The preparer name.

inheritCascadedAttributes

public void inheritCascadedAttributes(AttributeContext context)
Copies the cascaded attributes to this attribute context.

Specified by:
inheritCascadedAttributes in interface AttributeContext
Parameters:
context - The parent context to be used.

inherit

public void inherit(AttributeContext parent)
Copies all missing attributes from the parent attribute context to this one.

Specified by:
inherit in interface AttributeContext
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:
addAll in interface AttributeContext
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:
addMissing in interface AttributeContext
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:
getAttribute in interface AttributeContext
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:
getLocalAttribute in interface AttributeContext
Parameters:
name - key name for the attribute.
Returns:
Attribute The local attribute associated with the given name, if present, or null otherwise.

getCascadedAttribute

public Attribute getCascadedAttribute(java.lang.String name)
Retrieve the attribute that has been cascaded at upper levels.

Specified by:
getCascadedAttribute in interface AttributeContext
Parameters:
name - key name for the attribute.
Returns:
Attribute The cascaded attribute associated with the given name, if present, or null otherwise.

getAttributeNames

public java.util.Iterator<java.lang.String> getAttributeNames()
Iterator of all attribute names.

Specified by:
getAttributeNames in interface AttributeContext
Returns:
iterator of all names.

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:
getLocalAttributeNames in interface AttributeContext
Returns:
The local attribute names.

getCascadedAttributeNames

public java.util.Set<java.lang.String> getCascadedAttributeNames()
Returns the names of the cascaded attributes.

Specified by:
getCascadedAttributeNames in interface AttributeContext
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 calling AttributeContext.putAttribute(String, Attribute, boolean) with cascade = false.

Specified by:
putAttribute in interface AttributeContext
Parameters:
name - name of the attribute
value - value of the attribute

putAttribute

public void putAttribute(java.lang.String name,
                         Attribute value,
                         boolean cascade)
Add the specified attribute.

Specified by:
putAttribute in interface AttributeContext
Parameters:
name - name of the attribute
value - value of the attribute
cascade - If true, the attribute value will be available in all nested contexts. If false, it will be available only in the current context.

clear

public void clear()
Clear the attributes.

Specified by:
clear in interface AttributeContext