org.apache.tiles.context
Class BasicAttributeContext

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

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

Basic implementation for AttributeContext.

See Also:
Serialized Form

Constructor Summary
BasicAttributeContext()
          Constructor.
BasicAttributeContext(org.apache.tiles.AttributeContext context)
          Copy constructor.
BasicAttributeContext(java.util.Map<java.lang.String,org.apache.tiles.Attribute> attributes)
          Constructor.
 
Method Summary
 void addAll(java.util.Map<java.lang.String,org.apache.tiles.Attribute> newAttributes)
          Add all attributes to this context.
 void addMissing(java.util.Map<java.lang.String,org.apache.tiles.Attribute> defaultAttributes)
          Add all missing attributes to this context.
 void clear()
          
 org.apache.tiles.Attribute getAttribute(java.lang.String name)
          Get an attribute from context.
 java.util.Iterator<java.lang.String> getAttributeNames()
          Get names of all attributes.
static org.apache.tiles.AttributeContext getContext(TilesRequestContext tilesContext)
          Get attribute context from request.
static java.util.Stack<org.apache.tiles.AttributeContext> getContextStack(TilesRequestContext tilesContext)
          Returns the context stack.
static org.apache.tiles.AttributeContext popContext(TilesRequestContext tilesContext)
          Pops a context object out of the stack.
static void pushContext(org.apache.tiles.AttributeContext context, TilesRequestContext tilesContext)
          Pushes a context object in the stack.
 void putAttribute(java.lang.String name, org.apache.tiles.Attribute value)
          Put a new attribute to context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicAttributeContext

public BasicAttributeContext()
Constructor.


BasicAttributeContext

public BasicAttributeContext(java.util.Map<java.lang.String,org.apache.tiles.Attribute> attributes)
Constructor. Create a context and set specified attributes.

Parameters:
attributes - Attributes to initialize context.

BasicAttributeContext

public BasicAttributeContext(org.apache.tiles.AttributeContext context)
Copy constructor.

Parameters:
context - The constructor to copy.
Method Detail

addAll

public void addAll(java.util.Map<java.lang.String,org.apache.tiles.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 org.apache.tiles.AttributeContext
Parameters:
newAttributes - Attributes to add.

addMissing

public void addMissing(java.util.Map<java.lang.String,org.apache.tiles.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 org.apache.tiles.AttributeContext
Parameters:
defaultAttributes - Attributes to add.

getAttribute

public org.apache.tiles.Attribute getAttribute(java.lang.String name)
Get an attribute from context.

Specified by:
getAttribute in interface org.apache.tiles.AttributeContext
Parameters:
name - Name of the attribute.
Returns:
<{Attribute}>

getAttributeNames

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

Specified by:
getAttributeNames in interface org.apache.tiles.AttributeContext
Returns:
<{Attribute}>

putAttribute

public void putAttribute(java.lang.String name,
                         org.apache.tiles.Attribute value)
Put a new attribute to context.

Specified by:
putAttribute in interface org.apache.tiles.AttributeContext
Parameters:
name - Name of the attribute.
value - Value of the attribute.

getContext

public static org.apache.tiles.AttributeContext getContext(TilesRequestContext tilesContext)
Get attribute context from request.

Parameters:
tilesContext - current Tiles application context.
Returns:
BasicAttributeContext or null if context is not found or an jspException is present in the request.

getContextStack

public static java.util.Stack<org.apache.tiles.AttributeContext> getContextStack(TilesRequestContext tilesContext)
Returns the context stack.

Parameters:
tilesContext - The Tiles context object to use.
Returns:
The needed stack of contexts.

pushContext

public static void pushContext(org.apache.tiles.AttributeContext context,
                               TilesRequestContext tilesContext)
Pushes a context object in the stack.

Parameters:
context - The context to push.
tilesContext - The Tiles context object to use.

popContext

public static org.apache.tiles.AttributeContext popContext(TilesRequestContext tilesContext)
Pops a context object out of the stack.

Parameters:
tilesContext - The Tiles context object to use.
Returns:
The popped context object.

clear

public void clear()

Specified by:
clear in interface org.apache.tiles.AttributeContext