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 class
NationOptions.Advantages
Type of national advantages for European players.static class
NationOptions.NationState
Nations 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.Logger
logger
private static java.lang.String
NATION_OPTION_TAG
private static java.lang.String
NATIONAL_ADVANTAGES_TAG
private NationOptions.Advantages
nationalAdvantages
The type of European national advantages.private java.util.Map<Nation,NationOptions.NationState>
nations
All nations in the game.private static java.lang.String
OLD_NATION_TAG
private static java.lang.String
OLD_NATIONS_TAG
private static java.lang.String
STATE_TAG
static java.lang.String
TAG
-
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 newNationOptions
instance by reading a stream.NationOptions(Specification specification)
Creates a newNationOptions
instance.
-
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.Advantages
getNationalAdvantages()
Get the national advantages.java.util.Map<Nation,NationOptions.NationState>
getNations()
Get the nations in the game.NationOptions.NationState
getNationState(Nation nation)
Get theNationState
value of a particular Nation.java.lang.String
getXMLTagName()
Get the serialization tag for this object.protected void
readAttributes(FreeColXMLReader xr)
Reads the attributes of this object from an XML stream.protected void
readChild(FreeColXMLReader xr)
Reads a single child object.protected void
readChildren(FreeColXMLReader xr)
Reads the children of this object from an XML stream.protected void
setNations(java.util.Map<Nation,NationOptions.NationState> nations)
Set the nation map.void
setNationState(Nation nation, NationOptions.NationState state)
Set theNationState
value of a particular Nation.java.lang.String
toString()
void
writeAttributes(FreeColXMLWriter xw)
Write the attributes of this object to a stream.void
writeChildren(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 newNationOptions
instance.- Parameters:
specification
- TheSpecification
to refer to.
-
NationOptions
public NationOptions(FreeColXMLReader xr, Specification specification) throws javax.xml.stream.XMLStreamException
Creates a newNationOptions
instance by reading a stream.- Parameters:
xr
- TheFreeColXMLReader
to read from.specification
- TheSpecification
to 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 theNationState
value of a particular Nation.- Parameters:
nation
- TheNation
to query.- Returns:
- The corresponding
NationState
.
-
setNationState
public final void setNationState(Nation nation, NationOptions.NationState state)
Set theNationState
value of a particular Nation.- Parameters:
nation
- TheNation
to set the state for.state
- TheNationState
to set.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.- Overrides:
copyIn
in classFreeColSpecObject
- Type Parameters:
T
- TheFreeColObject
subclass 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:
writeAttributes
in classFreeColObject
- Parameters:
xw
- TheFreeColXMLWriter
to 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:
writeChildren
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.
-
readChildren
protected void readChildren(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the children of this object from an XML stream.- Overrides:
readChildren
in classFreeColObject
- Parameters:
xr
- TheFreeColXMLReader
to 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:
readChild
in classFreeColObject
- Parameters:
xr
- TheFreeColXMLReader
to 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:
getXMLTagName
in classFreeColObject
- Returns:
- The tag.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classFreeColObject
-
-