Package net.sf.freecol.common.model
Class NationType
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColSpecObject
-
- net.sf.freecol.common.model.FreeColSpecObjectType
-
- net.sf.freecol.common.model.NationType
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>
,Named
,ObjectWithId
- Direct Known Subclasses:
EuropeanNationType
,IndianNationType
public abstract class NationType extends FreeColSpecObjectType
Represents the type of one of the nations present in the game.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NationType.AggressionLevel
static class
NationType.SettlementNumber
-
Field Summary
Fields Modifier and Type Field Description private NationType.AggressionLevel
aggression
The aggression of this Nation.private static java.lang.String
AGGRESSION_TAG
private static java.lang.String
NUMBER_OF_SETTLEMENTS_TAG
private NationType.SettlementNumber
numberOfSettlements
The number of settlements this Nation has.private static java.lang.String
SETTLEMENT_TAG
private java.util.List<SettlementType>
settlementTypes
The types of settlement this Nation has.-
Fields inherited from class net.sf.freecol.common.model.FreeColSpecObjectType
DELETE_TAG, EXTENDS_TAG, PRESERVE_TAG
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, logger, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Constructor Description NationType(java.lang.String id, Specification specification)
Default nation type constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private void
addSettlementType(SettlementType settlementType)
Add a settlement type.private void
addSettlementTypes(java.util.List<SettlementType> types)
Add settlement types.<T extends FreeColObject>
booleancopyIn(T other)
Copy another FreeColObject into this one if it is compatible.NationType.AggressionLevel
getAggression()
Get the national aggression.SettlementType
getCapitalType()
Gets the settlement type for the national capital.NationType.SettlementNumber
getNumberOfSettlements()
Get the national number of settlements.SettlementType
getSettlementType(boolean isCapital)
Gets the settlement type for a settlement of this nation.SettlementType
getSettlementType(java.lang.String id)
Get a settlement type by identifier.java.util.List<SettlementType>
getSettlementTypes()
Get the settlement types.abstract boolean
isEuropean()
Whether this is a EuropeanNation, i.e.abstract boolean
isIndian()
Whether this is a IndianNation.abstract boolean
isREF()
Whether this is a EuropeanREFNation.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.void
setSettlementTypes(java.util.List<SettlementType> settlementTypes)
Set the settlement types.protected void
writeAttributes(FreeColXMLWriter xw)
Write the attributes of this object to a stream.protected void
writeChildren(FreeColXMLWriter xw)
Write the children of this object to a stream.-
Methods inherited from class net.sf.freecol.common.model.FreeColSpecObjectType
addScope, appliesTo, copyScopes, getDescriptionKey, getFeatureContainer, getIndex, getNameKey, getScopeList, getScopes, isAbstractType, removeScope, setIndex, toString
-
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, getFreeColObjectClass, getFreeColObjectClassByName, getGame, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, getXMLTagName, 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
-
numberOfSettlements
private NationType.SettlementNumber numberOfSettlements
The number of settlements this Nation has.
-
aggression
private NationType.AggressionLevel aggression
The aggression of this Nation.
-
settlementTypes
private java.util.List<SettlementType> settlementTypes
The types of settlement this Nation has.
-
AGGRESSION_TAG
private static final java.lang.String AGGRESSION_TAG
- See Also:
- Constant Field Values
-
NUMBER_OF_SETTLEMENTS_TAG
private static final java.lang.String NUMBER_OF_SETTLEMENTS_TAG
- See Also:
- Constant Field Values
-
SETTLEMENT_TAG
private static final java.lang.String SETTLEMENT_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NationType
public NationType(java.lang.String id, Specification specification)
Default nation type constructor.- Parameters:
id
- The object identifier.specification
- TheSpecification
to refer to.
-
-
Method Detail
-
getSettlementTypes
public final java.util.List<SettlementType> getSettlementTypes()
Get the settlement types.- Returns:
- A list of
SettlementType
s.
-
setSettlementTypes
public final void setSettlementTypes(java.util.List<SettlementType> settlementTypes)
Set the settlement types.- Parameters:
settlementTypes
- A new list ofSettlementType
s.
-
addSettlementType
private void addSettlementType(SettlementType settlementType)
Add a settlement type.- Parameters:
settlementType
- TheSettlementType
to add.
-
addSettlementTypes
private void addSettlementTypes(java.util.List<SettlementType> types)
Add settlement types.- Parameters:
types
- A list ofSettlementType
s to add.
-
getCapitalType
public SettlementType getCapitalType()
Gets the settlement type for the national capital.- Returns:
- The capital
SettlementType
.
-
getSettlementType
public SettlementType getSettlementType(boolean isCapital)
Gets the settlement type for a settlement of this nation.- Parameters:
isCapital
- If true, get the capital type.- Returns:
- The settlement type.
-
getSettlementType
public SettlementType getSettlementType(java.lang.String id)
Get a settlement type by identifier.- Parameters:
id
- The object identifier.- Returns:
- The settlement type.
-
getNumberOfSettlements
public final NationType.SettlementNumber getNumberOfSettlements()
Get the national number of settlements.- Returns:
- The
SettlementNumber
.
-
getAggression
public final NationType.AggressionLevel getAggression()
Get the national aggression.- Returns:
- The national
AggressionLevel
.
-
isEuropean
public abstract boolean isEuropean()
Whether this is a EuropeanNation, i.e. a player or a REF.- Returns:
- True if this is an European nation.
-
isIndian
public abstract boolean isIndian()
Whether this is a IndianNation.- Returns:
- True if this is a native nation.
-
isREF
public abstract boolean isREF()
Whether this is a EuropeanREFNation.- Returns:
- True if this is a REF nation.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.- Overrides:
copyIn
in classFreeColSpecObjectType
- 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
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.
-
writeChildren
protected 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 classFreeColSpecObjectType
- 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 classFreeColSpecObjectType
- 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 classFreeColSpecObjectType
- 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 classFreeColSpecObjectType
- Parameters:
xr
- TheFreeColXMLReader
to read from.- Throws:
javax.xml.stream.XMLStreamException
- if there is a problem reading the stream.
-
-