org.vizzini.game
Class TokenCollection

java.lang.Object
  extended by org.vizzini.util.AbstractCollection
      extended by org.vizzini.util.AbstractMap
          extended by org.vizzini.game.TokenCollection
All Implemented Interfaces:
PropertyChangeListener, Serializable, Cloneable, Iterable, Collection, EventListener, ITokenCollection, ICollection
Direct Known Subclasses:
CardCollection, TokenPositionCollection

public class TokenCollection
extends AbstractMap
implements ITokenCollection, PropertyChangeListener

Provides a collection to hold IToken s.

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Constructor Summary
TokenCollection()
          Construct this object.
TokenCollection(int initialCapacity)
          Construct this object with the given parameters.
 
Method Summary
 boolean add(Object object)
          Add the given object.
 Object clone()
          Return a deep clone of this instance.
 void configure(Properties properties)
          Configure this collection.
 void configure(Properties properties, int index)
          Configure this collection.
 IToken findByName(String name)
          Return the team with the given name.
 IToken get(Class tokenType, IAgent agent)
          Return the first token found of the given type belonging to the given agent.
 IToken get(IPosition position)
          Return the token at the given position.
protected  Map getData()
          Return the data collection.
protected  Object getKey(Object object)
          Return the token key.
protected  Object getKey(String name, String teamName, String agentName)
          Return the token key.
 String[] getTokenPropertyNames()
          Return the property names of interest to this.
protected  Class getType()
          Return the type this collection holds.
 Iterator iterator(Class aClass)
          Return an iterator over the collection of tokens of the given class.
 void propertyChange(PropertyChangeEvent event)
          Implement a property change listener for relevant token properties.
 boolean remove(Object object)
          Add the given object.
 
Methods inherited from class org.vizzini.util.AbstractMap
clear, contains, equals, hashCode, isEmpty, iterator, size, toString
 
Methods inherited from class org.vizzini.util.AbstractCollection
addAll, containsAll, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.vizzini.util.ICollection
toString
 
Methods inherited from interface java.util.Collection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

TokenCollection

public TokenCollection()
Construct this object.

Since:
v0.1

TokenCollection

public TokenCollection(int initialCapacity)
Construct this object with the given parameters.

Since:
v0.1
Method Detail

add

public boolean add(Object object)
Add the given object. Extend the super method to add property listeners to the token.

Specified by:
add in interface Collection
Overrides:
add in class AbstractMap
Since:
v0.2

clone

public Object clone()
Return a deep clone of this instance.

Specified by:
clone in interface ITokenCollection
Overrides:
clone in class Object
Since:
v0.1

configure

public void configure(Properties properties)
               throws InstantiationException,
                      IllegalAccessException
Configure this collection.

Specified by:
configure in interface ITokenCollection
Parameters:
properties - Source of configuration information. This is typically the game.properties.
Throws:
InstantiationException
IllegalAccessException
Since:
v0.2

configure

public void configure(Properties properties,
                      int index)
               throws InstantiationException,
                      IllegalAccessException
Configure this collection.

Parameters:
properties - Source of configuration information. This is typically the gameUI.properties.
index - Agent index.
Throws:
InstantiationException
IllegalAccessException
Since:
v0.2

findByName

public IToken findByName(String name)
Return the team with the given name.

Specified by:
findByName in interface ITokenCollection
Since:
v0.1

get

public IToken get(IPosition position)
Return the token at the given position.

Specified by:
get in interface ITokenCollection
Since:
v0.1

get

public IToken get(Class tokenType,
                  IAgent agent)
Return the first token found of the given type belonging to the given agent.

Specified by:
get in interface ITokenCollection
Since:
v0.1

getTokenPropertyNames

public String[] getTokenPropertyNames()
Return the property names of interest to this.

Since:
v0.2

iterator

public Iterator iterator(Class aClass)
Return an iterator over the collection of tokens of the given class.

Specified by:
iterator in interface ITokenCollection
Since:
v0.1

propertyChange

public void propertyChange(PropertyChangeEvent event)
Implement a property change listener for relevant token properties.

Specified by:
propertyChange in interface PropertyChangeListener
Since:
v0.2

remove

public boolean remove(Object object)
Add the given object. Extend the super method to remove property listeners from the token.

Specified by:
remove in interface Collection
Overrides:
remove in class AbstractMap
Since:
v0.2

getData

protected Map getData()
Return the data collection.

Specified by:
getData in class AbstractMap
Since:
v0.1

getKey

protected Object getKey(Object object)
Return the token key.

Specified by:
getKey in class AbstractMap
Since:
v0.1

getKey

protected Object getKey(String name,
                        String teamName,
                        String agentName)
Return the token key.

Since:
v0.1

getType

protected Class getType()
Return the type this collection holds.

Specified by:
getType in class AbstractCollection
Since:
v0.1


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02