Package net.sf.freecol.common.model
Class NationOptions
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColSpecObject
-
- net.sf.freecol.common.model.NationOptions
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>,ObjectWithId
public class NationOptions extends FreeColSpecObject
The options specific to a nation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNationOptions.AdvantagesType of national advantages for European players.static classNationOptions.NationStateNations may be available to all players, to AI players only, or to no players.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Loggerloggerprivate static java.lang.StringNATION_OPTION_TAGprivate static java.lang.StringNATIONAL_ADVANTAGES_TAGprivate NationOptions.AdvantagesnationalAdvantagesThe type of European national advantages.private java.util.Map<Nation,NationOptions.NationState>nationsAll nations in the game.private static java.lang.StringOLD_NATION_TAGprivate static java.lang.StringOLD_NATIONS_TAGprivate static java.lang.StringSTATE_TAGstatic java.lang.StringTAG-
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 NationOptions(FreeColXMLReader xr, Specification specification)Creates a newNationOptionsinstance by reading a stream.NationOptions(Specification specification)Creates a newNationOptionsinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends FreeColObject>
booleancopyIn(T other)Copy another FreeColObject into this one if it is compatible.NationOptions.AdvantagesgetNationalAdvantages()Get the national advantages.java.util.Map<Nation,NationOptions.NationState>getNations()Get the nations in the game.NationOptions.NationStategetNationState(Nation nation)Get theNationStatevalue of a particular Nation.java.lang.StringgetXMLTagName()Get the serialization tag for this object.protected voidreadAttributes(FreeColXMLReader xr)Reads the attributes of this object from an XML stream.protected voidreadChild(FreeColXMLReader xr)Reads a single child object.protected voidreadChildren(FreeColXMLReader xr)Reads the children of this object from an XML stream.protected voidsetNations(java.util.Map<Nation,NationOptions.NationState> nations)Set the nation map.voidsetNationState(Nation nation, NationOptions.NationState state)Set theNationStatevalue of a particular Nation.java.lang.StringtoString()voidwriteAttributes(FreeColXMLWriter xw)Write the attributes of this object to a stream.voidwriteChildren(FreeColXMLWriter xw)Write the children of this object to a stream.-
Methods inherited from class net.sf.freecol.common.model.FreeColSpecObject
getSpecification, 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, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getClassIndex, getDefenceModifiers, getDisplayObject, getFeatureContainer, getFreeColObjectClass, getFreeColObjectClassByName, getGame, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hashCode, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readFromXML, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setGame, setId, toXML, toXML, toXMLPartial, toXMLPartial
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
nationalAdvantages
private NationOptions.Advantages nationalAdvantages
The type of European national advantages.
-
nations
private final java.util.Map<Nation,NationOptions.NationState> nations
All nations in the game.
-
NATIONAL_ADVANTAGES_TAG
private static final java.lang.String NATIONAL_ADVANTAGES_TAG
- See Also:
- Constant Field Values
-
NATION_OPTION_TAG
private static final java.lang.String NATION_OPTION_TAG
- See Also:
- Constant Field Values
-
STATE_TAG
private static final java.lang.String STATE_TAG
- See Also:
- Constant Field Values
-
OLD_NATION_TAG
private static final java.lang.String OLD_NATION_TAG
- See Also:
- Constant Field Values
-
OLD_NATIONS_TAG
private static final java.lang.String OLD_NATIONS_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NationOptions
public NationOptions(Specification specification)
Creates a newNationOptionsinstance.- Parameters:
specification- TheSpecificationto refer to.
-
NationOptions
public NationOptions(FreeColXMLReader xr, Specification specification) throws javax.xml.stream.XMLStreamException
Creates a newNationOptionsinstance by reading a stream.- Parameters:
xr- TheFreeColXMLReaderto read from.specification- TheSpecificationto refer to.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
-
Method Detail
-
getNationalAdvantages
public final NationOptions.Advantages getNationalAdvantages()
Get the national advantages.- Returns:
- The national advantages.
-
getNations
public final java.util.Map<Nation,NationOptions.NationState> getNations()
Get the nations in the game.- Returns:
- A map of the nations.
-
setNations
protected void setNations(java.util.Map<Nation,NationOptions.NationState> nations)
Set the nation map.- Parameters:
nations- The new nations map.
-
getNationState
public final NationOptions.NationState getNationState(Nation nation)
Get theNationStatevalue of a particular Nation.- Parameters:
nation- TheNationto query.- Returns:
- The corresponding
NationState.
-
setNationState
public final void setNationState(Nation nation, NationOptions.NationState state)
Set theNationStatevalue of a particular Nation.- Parameters:
nation- TheNationto set the state for.state- TheNationStateto set.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.- Overrides:
copyInin classFreeColSpecObject- Type Parameters:
T- TheFreeColObjectsubclass of the object to copy in.- Parameters:
other- The other object.- Returns:
- True if the copy in is succesful.
-
writeAttributes
public 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:
writeAttributesin classFreeColObject- Parameters:
xw- TheFreeColXMLWriterto write to.- Throws:
javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
-
writeChildren
public void writeChildren(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the children of this object to a stream. To be overridden if required by any object that has children and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
writeChildrenin classFreeColObject- Parameters:
xw- TheFreeColXMLWriterto 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:
readAttributesin classFreeColObject- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
readChildren
protected void readChildren(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the children of this object from an XML stream.- Overrides:
readChildrenin classFreeColObject- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
readChild
protected void readChild(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads a single child object. Subclasses must override to read their enclosed elements. This particular instance of the routine always throws XMLStreamException because we should never arrive here. However it is very useful to always call super.readChild() when an unexpected tag is encountered, as the exception thrown here provides some useful debugging context.- Overrides:
readChildin classFreeColObject- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Specified by:
getXMLTagNamein classFreeColObject- Returns:
- The tag.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classFreeColObject
-
-