org.mentawai.core
Class MapContext

java.lang.Object
  extended by org.mentawai.core.MapContext
All Implemented Interfaces:
Context

public class MapContext
extends Object
implements Context

A simple Context that can be used for testing. A SessionContext and an ApplicationContext can be mocked with this class.

Author:
Sergio Oliveira

Constructor Summary
MapContext()
           
MapContext(Map<String,Object> values)
           
 
Method Summary
 Object getAttribute(String name)
          Gets an attribute value associated with the given name.
 boolean hasAttribute(String name)
          Returns true is an attribute exists with this name.
 Iterator<String> keys()
          Return an iterator with all the attribute names in this context.
 void removeAttribute(String name)
          Removes an attribute associated with the given name.
 void reset()
          Resets this context.
 void setAttribute(String name, Object value)
          Sets an attribute value associated with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapContext

public MapContext()

MapContext

public MapContext(Map<String,Object> values)
Method Detail

getAttribute

public Object getAttribute(String name)
Description copied from interface: Context
Gets an attribute value associated with the given name.

Specified by:
getAttribute in interface Context
Parameters:
name - The name of the attribute.
Returns:
The value of the attribute or null if it doesn't exist.

setAttribute

public void setAttribute(String name,
                         Object value)
Description copied from interface: Context
Sets an attribute value associated with the given name. If the attribute already exists, overwrite it.

Specified by:
setAttribute in interface Context
Parameters:
name - The name of the attribute.
value - The value of the attribute.

removeAttribute

public void removeAttribute(String name)
Description copied from interface: Context
Removes an attribute associated with the given name.

Specified by:
removeAttribute in interface Context
Parameters:
name - The name of the attribute.

keys

public Iterator<String> keys()
Description copied from interface: Context
Return an iterator with all the attribute names in this context.

Specified by:
keys in interface Context
Returns:
an iterator with the attribute names

reset

public void reset()
Description copied from interface: Context
Resets this context. All values are discarded and a new context is internally created.

Specified by:
reset in interface Context

hasAttribute

public boolean hasAttribute(String name)
Description copied from interface: Context
Returns true is an attribute exists with this name.

Specified by:
hasAttribute in interface Context
Parameters:
name - The name of the attribute.
Returns:
true if the attribute exists


Copyright © 2013. All Rights Reserved.