org.jrabbit.base.data.structures.base
Interface KeyedContainer<T extends Referenced>

All Superinterfaces:
Accepter<T>, Container<T>, Factory<T>, java.lang.Iterable<T>, Remover<T>
All Known Subinterfaces:
LayeredRenderList
All Known Implementing Classes:
BaseKeyedContainer, Cache, DefaultLayeredRenderList, FontCache, GroupedCache, ImageCache, OrderedKeyedContainer, SoundBoard

public interface KeyedContainer<T extends Referenced>
extends Container<T>, Factory<T>

KeyedContainer adds functionality to Container to support "keying" Referenced objects with their references - i.e., it's possible to access, add, or remove objects in the list by their associated String. A side effect of this is that no two objects in the KeyedContainer may have identical Strings - no reference collisions are supported or allowed. Additionally, a KeyedContainer is expected to be able to create an object from a String; this allows objects to be added simply by supplying the String they will associate with. The desired object is then produced and added.

Author:
Chris Molini

Method Summary
 void add(java.lang.String... references)
          Attempts to create and add objects corresponding to every supplied reference.
 boolean add(java.lang.String reference)
          Creates an object from the indicated expression and attempts to add it.
 boolean contains(java.lang.String reference)
          Checks to see if the Container contains an object with an identical reference to the one given.
 T get(java.lang.String reference)
          Attempts to access the object in the list with the given reference.
 java.util.Collection<T> remove(java.lang.String... references)
          Attempts to remove and return all objects in the Container that correspond to the supplied references.
 T remove(java.lang.String reference)
          Attempts to remove the object with the indicated Reference from the list.
 
Methods inherited from interface org.jrabbit.base.data.structures.base.Container
clear, contains, size
 
Methods inherited from interface org.jrabbit.base.data.structures.base.Accepter
add, add
 
Methods inherited from interface org.jrabbit.base.data.structures.base.Remover
remove, remove
 
Methods inherited from interface java.lang.Iterable
iterator
 
Methods inherited from interface org.jrabbit.base.data.Factory
create
 

Method Detail

add

boolean add(java.lang.String reference)
Creates an object from the indicated expression and attempts to add it.

Parameters:
reference - The String to identify the new object in the list.
Returns:
True if the addition operation succeeded, false if not.

add

void add(java.lang.String... references)
Attempts to create and add objects corresponding to every supplied reference.

Parameters:
references - The Strings to identify the new objects in the list.

remove

T remove(java.lang.String reference)
Attempts to remove the object with the indicated Reference from the list.

Parameters:
reference - The String that identifies the object in the list.
Returns:
If the object was removed, returns a reference to it, if the removal failed, returns null.

remove

java.util.Collection<T> remove(java.lang.String... references)
Attempts to remove and return all objects in the Container that correspond to the supplied references.

Parameters:
references - The Strings indicating which objects to remove.
Returns:
A Collection containing all objects removed. If no objects are removed successfully, an empty Collection is returned.

get

T get(java.lang.String reference)
Attempts to access the object in the list with the given reference.

Parameters:
reference - The String that identifies the object in the list.
Returns:
If the object is in the list, returns a reference to it. Otherwise, returns null.

contains

boolean contains(java.lang.String reference)
Checks to see if the Container contains an object with an identical reference to the one given.

Parameters:
reference - The String that identifies the object in the list.
Returns:
If the object is in the list, returns a true, otherwise, false.