org.vizzini.game
Class AbstractToken

java.lang.Object
  extended by org.vizzini.game.AbstractToken
All Implemented Interfaces:
Serializable, Cloneable, IToken
Direct Known Subclasses:
AbstractCard, AbstractChessToken, AbstractPhysicalObject, Ball, DefaultToken, Paddle

public abstract class AbstractToken
extends Object
implements IToken

Provides base functionality for tokens in the game framework. A token instance encapsulates the different types and behavior of game tokens. A token has a position, a value, and an optional associated agent. Examples of tokens are chess pieces, playing cards, and the ball in pong.

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

Field Summary
protected static String UNKNOWN_NAME
          Unknown name constant.
 
Fields inherited from interface org.vizzini.game.IToken
AGENT_PROPERTY, NAME_PROPERTY, POSITION_PROPERTY, TEAM_PROPERTY
 
Constructor Summary
AbstractToken()
           
 
Method Summary
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Add a PropertyChangeListener for a specific property.
 Object clone()
          Return a clone of this instance.
 void configure(Properties properties, int index)
          Configure this token.
 void copy(IToken token)
          Copy data from the given instance.
 boolean equals(Object object)
          Return true if the given object is equal to this.
 IAgent getAgent()
          Return the associated agent.
 int getIndex()
           
 String getName()
          Return this token's name.
 IPosition getPosition()
          Return the position.
protected  PropertyChangeManager getPropertyChangeManager()
          Return the property change manager.
 ITeam getTeam()
          Return this token's team.
 int getValue()
          Return the value of this token.
 int hashCode()
          Returns a hash code value for the object.
protected static boolean isFiringPositionChanges()
           
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Remove a PropertyChangeListener for a specific property.
 void setAgent(IAgent agent)
          Set the associated agent.
protected static void setFiringPositionChanges(boolean isFiringPositionChanges)
           
protected  void setIndex(int index)
           
 void setName(String name)
          Set the name to the given name.
 void setPosition(IPosition position)
          Set the position.
 void setTeam(ITeam team)
          Set the associated team.
 void setValue(int value)
          Set the value of this token.
 String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN_NAME

protected static final String UNKNOWN_NAME
Unknown name constant.

See Also:
Constant Field Values
Constructor Detail

AbstractToken

public AbstractToken()
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Add a PropertyChangeListener for a specific property. The listener will be invoked only when a call on firePropertyChange names that specific property.

Specified by:
addPropertyChangeListener in interface IToken
Parameters:
propertyName - The name of the property to listen on.
listener - The PropertyChangeListener to be added.
Since:
v0.2

clone

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

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

configure

public void configure(Properties properties,
                      int index)
Configure this token.

Specified by:
configure in interface IToken
Parameters:
properties - Source of configuration information.
index - Index of this token's properties.
Since:
v0.1

copy

public void copy(IToken token)
Copy data from the given instance.

Since:
v0.1

equals

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

Overrides:
equals in class Object
Parameters:
object - The object to compare.
Since:
v0.1

getAgent

public IAgent getAgent()
Return the associated agent.

Specified by:
getAgent in interface IToken
Since:
v0.1

getIndex

public int getIndex()
Specified by:
getIndex in interface IToken
Returns:
Return index.
Since:
v0.3

getName

public String getName()
Return this token's name. If the name is not set and the team is set, then return the team's name.

Specified by:
getName in interface IToken
Since:
v0.1

getPosition

public IPosition getPosition()
Return the position.

Specified by:
getPosition in interface IToken
Since:
v0.1

getTeam

public ITeam getTeam()
Return this token's team. If team is set through use of setTeam(), that team is returned. If team is null and the agent is set, then the agent's team is returned. Else null is returned.

Specified by:
getTeam in interface IToken
Returns:
this token's team. May be null.
Since:
v0.1

getValue

public int getValue()
Return the value of this token.

Specified by:
getValue in interface IToken
Since:
v0.1

hashCode

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

Overrides:
hashCode in class Object
Since:
v0.1

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property.

Specified by:
removePropertyChangeListener in interface IToken
Parameters:
propertyName - The name of the property that was listened on.
listener - The PropertyChangeListener to be removed.
Since:
v0.2

setAgent

public void setAgent(IAgent agent)
Set the associated agent. If the team is set through use of setTeam() and the agent is not null, then the agent's team must match.

Specified by:
setAgent in interface IToken
Parameters:
agent - The associated agent. May be null.
Since:
v0.1

setName

public void setName(String name)
Set the name to the given name.

Specified by:
setName in interface IToken
Parameters:
name - The new name.
Since:
v0.1

setPosition

public void setPosition(IPosition position)
Set the position.

Specified by:
setPosition in interface IToken
Since:
v0.1

setTeam

public void setTeam(ITeam team)
Set the associated team.

Specified by:
setTeam in interface IToken
Parameters:
team - The associated team. Can be null.
Since:
v0.1

setValue

public void setValue(int value)
Set the value of this token.

Specified by:
setValue in interface IToken
Parameters:
value - The new value.
Since:
v0.1

toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class Object
Since:
v0.1

isFiringPositionChanges

protected static boolean isFiringPositionChanges()
Returns:
Return _isFiringPositionChanges.
Since:
v0.3

setFiringPositionChanges

protected static void setFiringPositionChanges(boolean isFiringPositionChanges)
Parameters:
isFiringPositionChanges - The _isFiringPositionChanges to set.
Since:
v0.3

getPropertyChangeManager

protected PropertyChangeManager getPropertyChangeManager()
Return the property change manager.

Since:
v0.2

setIndex

protected void setIndex(int index)
Parameters:
index - the index to set
Since:
v0.3


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02