net.sf.freecol.server.ai
Class Wish

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.server.ai.AIObject
          extended by net.sf.freecol.server.ai.ValuedAIObject
              extended by net.sf.freecol.server.ai.Wish
All Implemented Interfaces:
java.lang.Comparable<ValuedAIObject>
Direct Known Subclasses:
GoodsWish, WorkerWish

public abstract class Wish
extends ValuedAIObject

Represents a need for something at a given Location.


Field Summary
protected  Location destination
           
private static java.util.logging.Logger logger
           
protected  Transportable transportable
          The Transportable which will realize the wish, or null if no Transportable has been chosen.
 
Fields inherited from class net.sf.freecol.server.ai.AIObject
uninitialized
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG
 
Constructor Summary
Wish(AIMain aiMain, org.w3c.dom.Element element)
          Creates a new Wish from the given XML-representation.
Wish(AIMain aiMain, java.lang.String id)
          Creates a new Wish.
Wish(AIMain aiMain, javax.xml.stream.XMLStreamReader in)
          Creates a new Wish from the given XML-representation.
 
Method Summary
 void attachToDestination()
          Attaches this wish to its destination AI colony, if any.
 void dispose()
          Disposes this AIObject by removing any referances to this object.
 Location getDestination()
          Gets the destination of this Wish.
 AIColony getDestinationAIColony()
          Gets the destination AI colony, if any.
 Transportable getTransportable()
          Gets the Transportable assigned to this Wish.
 void setTransportable(Transportable transportable)
          Assigns a Transportable to this Wish.
 boolean shouldBeStored()
          Checks if this Wish needs to be stored in a savegame.
 
Methods inherited from class net.sf.freecol.server.ai.ValuedAIObject
compareTo, getValue, setValue
 
Methods inherited from class net.sf.freecol.server.ai.AIObject
getAIMain, getGame, getSpecification, getXMLElementTagName, isUninitialized, readFromXML
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, hasAbility, hasAttribute, hasListeners, readAttributes, readAttributes, readChild, readChild, readChildren, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXMLElement, readFromXMLImpl, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, setSpecification, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLImpl, toXMLPartialImpl, writeAttribute, writeAttributes, writeChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

destination

protected Location destination

transportable

protected Transportable transportable
The Transportable which will realize the wish, or null if no Transportable has been chosen.

Constructor Detail

Wish

public Wish(AIMain aiMain,
            java.lang.String id)
Creates a new Wish.

Parameters:
aiMain - The main AI-object.
id - The unique ID of this object.

Wish

public Wish(AIMain aiMain,
            org.w3c.dom.Element element)
Creates a new Wish from the given XML-representation.

Parameters:
aiMain - The main AI-object.
element - The root element for the XML-representation of a Wish.

Wish

public Wish(AIMain aiMain,
            javax.xml.stream.XMLStreamReader in)
     throws javax.xml.stream.XMLStreamException
Creates a new Wish from the given XML-representation.

Parameters:
aiMain - The main AI-object.
in - The input stream containing the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.
Method Detail

shouldBeStored

public boolean shouldBeStored()
Checks if this Wish needs to be stored in a savegame.

Returns:
The result.

setTransportable

public void setTransportable(Transportable transportable)
Assigns a Transportable to this Wish.

Parameters:
transportable - The Transportable which should realize this wish.
See Also:
getTransportable(), WishRealizationMission

getTransportable

public Transportable getTransportable()
Gets the Transportable assigned to this Wish.

Returns:
The Transportable which will realize this wish, or null if none has been assigned.
See Also:
setTransportable(net.sf.freecol.server.ai.Transportable), WishRealizationMission

dispose

public void dispose()
Disposes this AIObject by removing any referances to this object.

Overrides:
dispose in class AIObject

getDestination

public Location getDestination()
Gets the destination of this Wish.

Returns:
The Location in which the transportable assigned to this Wish will have to reach.

getDestinationAIColony

public AIColony getDestinationAIColony()
Gets the destination AI colony, if any.

Returns:
The destination AIColony.

attachToDestination

public void attachToDestination()
Attaches this wish to its destination AI colony, if any.