com.realtime.crossfire.jxclient.skin.skin
Class JXCSkinCache<T>

java.lang.Object
  extended by com.realtime.crossfire.jxclient.skin.skin.JXCSkinCache<T>
All Implemented Interfaces:
java.lang.Iterable<T>

public class JXCSkinCache<T>
extends java.lang.Object
implements java.lang.Iterable<T>

Implements a cache for elements identified by name.


Field Summary
private  java.util.Map<java.lang.String,T> cache
          The cached elements.
private  java.lang.String ident
          The description of this cache used for creating error messages.
 
Constructor Summary
JXCSkinCache(java.lang.String ident)
          Create a new instance.
 
Method Summary
 void clear()
          Forget all cached elements.
 void insert(java.lang.String name, T t)
          Add a new element to the cache.
 java.util.Iterator<T> iterator()
          Return all stored values.
 T lookup(java.lang.String name)
          Lookup an element by name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

@NotNull
private final java.util.Map<java.lang.String,T> cache
The cached elements. Maps element name to element. Mapped elements are never null.


ident

@NotNull
private final java.lang.String ident
The description of this cache used for creating error messages.

Constructor Detail

JXCSkinCache

public JXCSkinCache(@NotNull
                    java.lang.String ident)
Create a new instance.

Parameters:
ident - The description of this cache used for creating error messages.
Method Detail

clear

public void clear()
Forget all cached elements.


insert

public void insert(@NotNull
                   java.lang.String name,
                   @NotNull
                   T t)
            throws JXCSkinException
Add a new element to the cache.

Parameters:
name - The element name to add.
t - The element to add.
Throws:
JXCSkinException - if the element name is not unique

iterator

@NotNull
public java.util.Iterator<T> iterator()
Return all stored values.

Specified by:
iterator in interface java.lang.Iterable<T>
Returns:
An iterator returning all stored values.

lookup

@NotNull
public T lookup(@NotNull
                        java.lang.String name)
         throws JXCSkinException
Lookup an element by name.

Parameters:
name - The name of the element.
Returns:
The element.
Throws:
JXCSkinException - if no such element exists