net.sf.freecol.server.ai
Class WorkerWish

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
                  extended by net.sf.freecol.server.ai.WorkerWish
All Implemented Interfaces:
java.lang.Comparable<ValuedAIObject>

public class WorkerWish
extends Wish

Represents the need for a worker within a Colony.


Field Summary
private  boolean expertNeeded
           
private static java.util.logging.Logger logger
           
private  UnitType unitType
           
 
Fields inherited from class net.sf.freecol.server.ai.Wish
destination, transportable
 
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
WorkerWish(AIMain aiMain, org.w3c.dom.Element element)
          Creates a new WorkerWish from the given XML-representation.
WorkerWish(AIMain aiMain, Location destination, int value, UnitType unitType, boolean expertNeeded)
          Creates a new WorkerWish.
WorkerWish(AIMain aiMain, java.lang.String id)
          Creates a new WorkerWish from the given XML-representation.
WorkerWish(AIMain aiMain, javax.xml.stream.XMLStreamReader in)
          Creates a new WorkerWish from the given XML-representation.
 
Method Summary
 UnitType getUnitType()
          Returns the type of unit needed for releasing this wish.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
protected  void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Reads information for this object from an XML stream.
 java.lang.String toString()
           
protected  void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          Writes this object to an XML stream.
 void update(int value, UnitType unitType, boolean expertNeeded)
          Updates this WorkerWish with the given attributes.
 
Methods inherited from class net.sf.freecol.server.ai.Wish
attachToDestination, dispose, getDestination, getDestinationAIColony, getTransportable, setTransportable, shouldBeStored
 
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, 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, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, setSpecification, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute, writeAttributes, writeChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

unitType

private UnitType unitType

expertNeeded

private boolean expertNeeded
Constructor Detail

WorkerWish

public WorkerWish(AIMain aiMain,
                  Location destination,
                  int value,
                  UnitType unitType,
                  boolean expertNeeded)
Creates a new WorkerWish.

Parameters:
aiMain - The main AI-object.
destination - The Location in which the transportable assigned to this WorkerWish will have to reach.
value - The value identifying the importance of this Wish.
unitType - The type of unit needed for releasing this wish completly.
expertNeeded - Determines wether the unitType is required or not.

WorkerWish

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

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

WorkerWish

public WorkerWish(AIMain aiMain,
                  java.lang.String id)
Creates a new WorkerWish from the given XML-representation.

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

WorkerWish

public WorkerWish(AIMain aiMain,
                  javax.xml.stream.XMLStreamReader in)
           throws javax.xml.stream.XMLStreamException
Creates a new WorkerWish 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

update

public void update(int value,
                   UnitType unitType,
                   boolean expertNeeded)
Updates this WorkerWish with the given attributes.

Parameters:
value - The value identifying the importance of this Wish.
unitType - The type of unit needed for releasing this wish completly.
expertNeeded - Determines wether the unitType is required or not.

getUnitType

public UnitType getUnitType()
Returns the type of unit needed for releasing this wish.

Returns:
The type of unit.

toXMLImpl

protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
                  throws javax.xml.stream.XMLStreamException
Writes this object to an XML stream.

Specified by:
toXMLImpl in class FreeColObject
Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readFromXMLImpl

protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
                        throws javax.xml.stream.XMLStreamException
Reads information for this object from an XML stream.

Overrides:
readFromXMLImpl in class FreeColObject
Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems reading from the stream.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Returns the tag name of the root element representing this object.

Returns:
"workerWish"