org.graffiti.plugin.view.interactive
Class SlotMap

java.lang.Object
  extended by org.graffiti.plugin.view.interactive.SlotMap
All Implemented Interfaces:
InSlotMap, OutSlotMap

public class SlotMap
extends Object
implements InSlotMap, OutSlotMap

A container, which manages the association of Slots with values. See Overview of the trigger/action paradigm.

Version:
$Revision$ $Date$
Author:
Andreas Gleißner

Constructor Summary
SlotMap()
          Constructs a new, empty SlotMap.
 
Method Summary
<T> void
addObserver(Slot<T> slot, Observer<T> observer)
          Adds an observer, which is notified when the specified slot is assigned a new value.
 void clear()
          Removes all associations of slots with values.
 void clearObservers(Slot<?> slot)
          Removes all observers for the specified slot.
 boolean containsSlot(String id)
          Returns if there is a slot with the specified id.
static SlotMap emptyMap()
          Returns an empty, immutable SlotMap.
<T> T
get(Slot<T> slot)
          Returns the value associated with the specified slot.
 Object get(String id)
          Returns the value associated with the slot specified by id.
 Set<Map.Entry<Slot<?>,Observable<?>>> getEntrySet()
          Returns the entry set of the Map backing this SlotMap.
<T> void
put(Slot<T> slot, T value)
          Assigns the specified value to the specified slot.
 void put(String id, Object value)
          Assigns the specified value to the slot with the specified id.
 void putAll(SlotMap slotMap)
          Copies all slot assignments from slotMap to this map.
<T> void
putDefaultValue(Slot<T> slot)
          Associates the specified slot by its default value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SlotMap

public SlotMap()
Constructs a new, empty SlotMap.

Method Detail

emptyMap

public static SlotMap emptyMap()
Returns an empty, immutable SlotMap.

Returns:
an empty, immutable SlotMap.

get

public Object get(String id)
Returns the value associated with the slot specified by id. The preferred way to query the value of a slot is to call the type safe get(Slot) method.

Parameters:
id - the id of the slot whose associated value is to be returned.
Returns:
the value associated with the slot specified by id or null if there is no such slot.

containsSlot

public boolean containsSlot(String id)
Returns if there is a slot with the specified id.

Specified by:
containsSlot in interface InSlotMap
Parameters:
id - the id of the slot in question.
Returns:
true if there is a slot with the specified id.

get

public <T> T get(Slot<T> slot)
Returns the value associated with the specified slot.

Specified by:
get in interface InSlotMap
Type Parameters:
T - the type of the slot.
Parameters:
slot - the slot whose associated value is to be returned. It must be contained by this map.
Returns:
the value associated with the specified slot.

put

public <T> void put(Slot<T> slot,
                    T value)
Assigns the specified value to the specified slot.

Specified by:
put in interface OutSlotMap
Type Parameters:
T - the type of the slot.
Parameters:
slot - the slot the value is to be assigned to. It must be contained by this map.
value - the value to be assigned to the specified slot. May be null.

putAll

public void putAll(SlotMap slotMap)
Copies all slot assignments from slotMap to this map.

Specified by:
putAll in interface OutSlotMap
Parameters:
slotMap - the SlotMap that the assignments are taken from. Must not be null.

putDefaultValue

public <T> void putDefaultValue(Slot<T> slot)
Associates the specified slot by its default value.

Type Parameters:
T - the type of the specified slot.
Parameters:
slot - the slot that its default value is assigned to. It must be contained by this map.

put

public void put(String id,
                Object value)
Assigns the specified value to the slot with the specified id. The preferred way to assign a value to a slot is to call the type safe put(Slot, Object) method.

Parameters:
id - the id of the slot that the value is to be assigned to. This map must contain a slot with that id.
value - the value to be assigned to the specified slot. May be null.

addObserver

public <T> void addObserver(Slot<T> slot,
                            Observer<T> observer)
Adds an observer, which is notified when the specified slot is assigned a new value.

Type Parameters:
T - the type of the specified slot.
Parameters:
slot - the slot to be observed by observer.
observer - the observer that is to be notified when slot is assigned a new value.
Throws:
SlotAssignmentException - if this map does not contain slot.

clearObservers

public void clearObservers(Slot<?> slot)
Removes all observers for the specified slot.

Parameters:
slot - the slot the observers are removed from.
Throws:
SlotAssignmentException - if this map does not contain slot.

getEntrySet

public Set<Map.Entry<Slot<?>,Observable<?>>> getEntrySet()
Returns the entry set of the Map backing this SlotMap.

Returns:
the entry set of the Map backing this SlotMap.
See Also:
Map.entrySet()

clear

public void clear()
Removes all associations of slots with values.



Generated at 2012-05-30 11:00:36 PM CEST