net.sf.freecol.server.ai
Class AIObject

java.lang.Object
  extended by net.sf.freecol.server.ai.AIObject
Direct Known Subclasses:
AIColony, AIGoods, AIPlayer, AIUnit, Mission, TileImprovement, Wish

public abstract class AIObject
extends java.lang.Object

An AIObject contains AI-related information and methods. Each FreeColGameObject, that is owned by an AI-controlled player, can have a single AIObject attached to it.


Field Summary
static java.lang.String COPYRIGHT
           
protected  java.lang.String id
           
static java.lang.String LICENSE
           
static java.lang.String REVISION
           
protected  boolean uninitialized
           
 
Constructor Summary
AIObject(AIMain aiMain)
          Creates a new AIObject.
AIObject(AIMain aiMain, java.lang.String id)
          Creates a new AIObject and registers this object with AIMain.
 
Method Summary
 void dispose()
          Disposes this AIObject by removing any referances to this object.
 AIMain getAIMain()
          Returns the main AI-object.
 Game getGame()
          Returns the game.
abstract  java.lang.String getID()
          Returns the ID of this AIObject.
protected  PseudoRandom getRandom()
          Returns an instance of PseudoRandom.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
 boolean isUninitialized()
          Checks if this AIObject is uninitialized.
 void readFromXML(javax.xml.stream.XMLStreamReader in)
          Initialize this object from an XML-representation of this object.
 void readFromXMLElement(org.w3c.dom.Element element)
          Initialize this object from an XML-representation of this object.
protected abstract  void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Initialize this object from an XML-representation of this object.
 void toXML(javax.xml.stream.XMLStreamWriter out)
          This method writes an XML-representation of this object to the given stream.
 org.w3c.dom.Element toXMLElement(org.w3c.dom.Document document)
          This method writes an XML-representation of this object to the given stream.
protected abstract  void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          This method writes an XML-representation of this object to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values

LICENSE

public static final java.lang.String LICENSE
See Also:
Constant Field Values

REVISION

public static final java.lang.String REVISION
See Also:
Constant Field Values

uninitialized

protected boolean uninitialized

id

protected java.lang.String id
Constructor Detail

AIObject

public AIObject(AIMain aiMain)
Creates a new AIObject.

Parameters:
aiMain - The main AI-object.

AIObject

public AIObject(AIMain aiMain,
                java.lang.String id)
Creates a new AIObject and registers this object with AIMain.

Parameters:
aiMain - The main AI-object.
id - The unique identifier.
See Also:
AIMain.addAIObject(String, AIObject)
Method Detail

getAIMain

public AIMain getAIMain()
Returns the main AI-object.

Returns:
The AIMain.

isUninitialized

public boolean isUninitialized()
Checks if this AIObject is uninitialized. That is: it has been referenced by another object, but has not yet been updated with readFromXML(javax.xml.stream.XMLStreamReader).

Returns:
true if this object is not initialized.

getID

public abstract java.lang.String getID()
Returns the ID of this AIObject.

Returns:
The ID of this AIObject. This is normally the ID of the FreeColGameObject this object represents.

toXMLElement

public org.w3c.dom.Element toXMLElement(org.w3c.dom.Document document)
This method writes an XML-representation of this object to the given stream.

Parameters:
document - The Document.
Returns:
An XML-representation of this object.

readFromXMLElement

public void readFromXMLElement(org.w3c.dom.Element element)
Initialize this object from an XML-representation of this object.

Parameters:
element - An XML-element that will be used to initialize this object.

toXMLImpl

protected abstract void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
                           throws javax.xml.stream.XMLStreamException
This method writes an XML-representation of this object to the given stream.

Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readFromXMLImpl

protected abstract void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
                                 throws javax.xml.stream.XMLStreamException
Initialize this object from an XML-representation of this object.

Parameters:
in - The input stream containing the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

toXML

public final void toXML(javax.xml.stream.XMLStreamWriter out)
                 throws javax.xml.stream.XMLStreamException
This method writes an XML-representation of this object to the given stream.

Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readFromXML

public final void readFromXML(javax.xml.stream.XMLStreamReader in)
                       throws javax.xml.stream.XMLStreamException
Initialize this object from an XML-representation of this object.

Parameters:
in - The input stream containing the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

getRandom

protected PseudoRandom getRandom()
Returns an instance of PseudoRandom. It that can be used to generate random numbers.

Returns:
An instance of PseudoRandom.

dispose

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


getGame

public Game getGame()
Returns the game.

Returns:
The Game.

getXMLElementTagName

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

Returns:
The String "unknown".