Package net.sf.freecol.server.ai
Class ValuedAIObject
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.server.ai.AIObject
-
- net.sf.freecol.server.ai.ValuedAIObject
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>
,ObjectWithId
- Direct Known Subclasses:
TileImprovementPlan
,TransportableAIObject
,Wish
public abstract class ValuedAIObject extends AIObject
Abstract class of AI object with a simple enclosed comparable integer value.
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<? super ValuedAIObject>
ascendingValueComparator
A comparator by ascending AI object value.static java.util.Comparator<? super ValuedAIObject>
descendingValueComparator
A comparator by descending AI object value.private int
value
The value of this AIObject.-
Fields inherited from class net.sf.freecol.server.ai.AIObject
initialized
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Constructor Description ValuedAIObject(AIMain aiMain)
Creates a newValuedAIObject
instance.ValuedAIObject(AIMain aiMain, java.lang.String id)
Creates a new uninitializedValuedAIObject
instance.ValuedAIObject(AIMain aiMain, FreeColXMLReader xr)
Creates a newValuedAIObject
from the given XML-representation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
int
getValue()
Get the value.int
hashCode()
protected void
readAttributes(FreeColXMLReader xr)
Reads the attributes of this object from an XML stream.void
setValue(int newValue)
Set the value.protected void
writeAttributes(FreeColXMLWriter xw)
Write the attributes of this object to a stream.-
Methods inherited from class net.sf.freecol.server.ai.AIObject
addAIObjectWithId, checkIntegrity, checkIntegrity, copyIn, dispose, getAIMain, getGame, getSpecification, isDisposed, setGame, setInitialized, setSpecification
-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getClassIndex, getDefenceModifiers, getDisplayObject, getFeatureContainer, getFreeColObjectClass, getFreeColObjectClassByName, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, getXMLTagName, hasAbility, hasAbility, hasAbility, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readChild, readChildren, readFromXML, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setId, toString, toXML, toXML, toXMLPartial, toXMLPartial, writeChildren
-
-
-
-
Field Detail
-
ascendingValueComparator
public static final java.util.Comparator<? super ValuedAIObject> ascendingValueComparator
A comparator by ascending AI object value.
-
descendingValueComparator
public static final java.util.Comparator<? super ValuedAIObject> descendingValueComparator
A comparator by descending AI object value.
-
value
private int value
The value of this AIObject.
-
-
Constructor Detail
-
ValuedAIObject
public ValuedAIObject(AIMain aiMain)
Creates a newValuedAIObject
instance.- Parameters:
aiMain
- anAIMain
value
-
ValuedAIObject
public ValuedAIObject(AIMain aiMain, java.lang.String id)
Creates a new uninitializedValuedAIObject
instance.- Parameters:
aiMain
- anAIMain
valueid
- The object identifier.
-
ValuedAIObject
public ValuedAIObject(AIMain aiMain, FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Creates a newValuedAIObject
from the given XML-representation.- Parameters:
aiMain
- The main AI-object.xr
- The input stream containing the XML.- Throws:
javax.xml.stream.XMLStreamException
- if a problem was encountered during parsing.
-
-
Method Detail
-
getValue
public final int getValue()
Get the value.- Returns:
- The value.
-
setValue
public final void setValue(int newValue)
Set the value.- Parameters:
newValue
- The new value.
-
writeAttributes
protected void writeAttributes(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream. To be overridden if required by any object that has attributes and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
writeAttributes
in classFreeColObject
- Parameters:
xw
- TheFreeColXMLWriter
to write to.- Throws:
javax.xml.stream.XMLStreamException
- if there are any problems writing to the stream.
-
readAttributes
protected void readAttributes(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.- Overrides:
readAttributes
in classFreeColObject
- Parameters:
xr
- TheFreeColXMLReader
to read from.- Throws:
javax.xml.stream.XMLStreamException
- if there is a problem reading the stream.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classFreeColObject
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classFreeColObject
-
-