org.vizzini.game
Class TokenArrayCollection

java.lang.Object
  extended by org.vizzini.util.AbstractCollection
      extended by org.vizzini.game.TokenArrayCollection
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, ITokenCollection, ICollection
Direct Known Subclasses:
ChessTokenCollection

public class TokenArrayCollection
extends AbstractCollection
implements ITokenCollection

Provides a collection to hold IToken s, where the tokens are stored by their position in a three dimensional array. This class assumes the use of IntegerPosition for all IPosition s.

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

Constructor Summary
TokenArrayCollection()
           
 
Method Summary
 boolean add(Object object)
          Add the given object.
 void clear()
          Removes all of the objects from this collection.
 Object clone()
          Return a clone of this instance.
 void configure(Properties properties)
          Configure this collection.
 boolean contains(Object object)
          Returns true if this collection contains the given object.
 boolean equals(Object object)
          Return true if the given object is equal to this.
 IToken findByName(String name)
          Return the token 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(int file, int rank, int level)
          Return the token at the given position.
 IToken get(IPosition position)
          Return the token at the given position.
protected  Class getType()
          Return the type this collection holds.
 int hashCode()
          Returns a hash code value for the object.
 boolean isEmpty()
          Return true if this is empty.
 Iterator iterator()
          Return an iterator over the object collection.
 Iterator iterator(Class aClass)
          Return an iterator over the collection of tokens of the given class.
 void move(IntegerPosition fromPosition, IntegerPosition toPosition)
          Move a token from the given position to the new position.
 void move(int file0, int rank0, int level0, int file1, int rank1, int level1)
          Move a token from the given position to the new position.
 boolean remove(Object object)
          Remove the given object.
 int size()
          Return the size of this collection.
 
Methods inherited from class org.vizzini.util.AbstractCollection
addAll, containsAll, removeAll, retainAll, toArray, toArray, toString
 
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, containsAll, removeAll, retainAll, toArray, toArray
 

Constructor Detail

TokenArrayCollection

public TokenArrayCollection()
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
Since:
v0.2

clear

public void clear()
Removes all of the objects from this collection.

Specified by:
clear in interface Collection
Since:
v0.2

clone

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

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

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

contains

public boolean contains(Object object)
Returns true if this collection contains the given object.

Specified by:
contains in interface Collection
Since:
v0.2

equals

public boolean equals(Object object)
Return true if the given object is equal to this.

Specified by:
equals in interface Collection
Overrides:
equals in class Object
Parameters:
object - The object to compare.
Since:
v0.2

findByName

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

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

get

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

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

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.2

get

public IToken get(int file,
                  int rank,
                  int level)
Return the token at the given position.

Since:
v0.2

hashCode

public int hashCode()
Returns a hash code value for the object.

Specified by:
hashCode in interface Collection
Overrides:
hashCode in class Object
Since:
v0.2

isEmpty

public boolean isEmpty()
Return true if this is empty.

Specified by:
isEmpty in interface Collection
Since:
v0.2

iterator

public Iterator iterator()
Return an iterator over the object collection.

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
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.2

move

public void move(IntegerPosition fromPosition,
                 IntegerPosition toPosition)
Move a token from the given position to the new position.

Since:
v0.3

move

public void move(int file0,
                 int rank0,
                 int level0,
                 int file1,
                 int rank1,
                 int level1)
Move a token from the given position to the new position.

Since:
v0.3

remove

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

Specified by:
remove in interface Collection
Since:
v0.2

size

public int size()
Return the size of this collection.

Specified by:
size in interface Collection
Since:
v0.2

getType

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

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


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02