org.mentawai.core
Class MapOutput

java.lang.Object
  extended by org.mentawai.core.MapOutput
All Implemented Interfaces:
Output

public class MapOutput
extends Object
implements Output

A simple Output implementation backed up by a java.util.HashMap. You may use this class as a mock for testing.

Author:
Sergio Oliveira

Constructor Summary
MapOutput()
           
 
Method Summary
 String add(Object value)
          Add an object with a auto generated key.
 Object getValue(String name)
          Gets an output value by name.
 boolean has(String key)
          Check if the output has this key.
 boolean isEmpty()
          Returns true is this output has no values.
 Iterator<String> keys()
          Gets an iterator with the names of each output value.
 void removeValue(String name)
          Removes an output value by name.
 void setObject(Object bean)
          Sets the properties of the given bean in the action output, in other words, extract all attributes from the given object and place them in the action output.
 void setObject(Object bean, String prefix)
          Sets the properties of the given bean in the action output, in other words, extract all attributes from the given object and place them in the action output.
 void setValue(String name, Object value)
          Sets an output value by name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapOutput

public MapOutput()
Method Detail

setValue

public void setValue(String name,
                     Object value)
Description copied from interface: Output
Sets an output value by name.

Specified by:
setValue in interface Output
Parameters:
name - The name of the value
value - The value

add

public String add(Object value)
Description copied from interface: Output
Add an object with a auto generated key. This can be used when you don't care about the key, for example for streams.

Specified by:
add in interface Output
Returns:
The key used to add this object to the output.

getValue

public Object getValue(String name)
Description copied from interface: Output
Gets an output value by name.

Specified by:
getValue in interface Output
Parameters:
name - The name of the value
Returns:
The value or null if it does not exist

removeValue

public void removeValue(String name)
Description copied from interface: Output
Removes an output value by name.

Specified by:
removeValue in interface Output
Parameters:
name - The name of the value

isEmpty

public boolean isEmpty()
Description copied from interface: Output
Returns true is this output has no values.

Specified by:
isEmpty in interface Output
Returns:
true if this output has no values

setObject

public void setObject(Object bean)
Description copied from interface: Output
Sets the properties of the given bean in the action output, in other words, extract all attributes from the given object and place them in the action output.

Specified by:
setObject in interface Output
Parameters:
bean - The bean (object) from where to get the properties.

setObject

public void setObject(Object bean,
                      String prefix)
Description copied from interface: Output
Sets the properties of the given bean in the action output, in other words, extract all attributes from the given object and place them in the action output. Use the given prefix when placing in the output.

Specified by:
setObject in interface Output
Parameters:
bean - The bean (object) from where to get the properties.
prefix - The prefix to use when placing the properties in the output.

keys

public Iterator<String> keys()
Description copied from interface: Output
Gets an iterator with the names of each output value.

Specified by:
keys in interface Output
Returns:
An iterator with all the names

has

public boolean has(String key)
Description copied from interface: Output
Check if the output has this key.

Specified by:
has in interface Output
Returns:
boolean


Copyright © 2013. All Rights Reserved.