Package net.sf.freecol.common.model
Class EuropeanNationType
- 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
-
- net.sf.freecol.common.model.EuropeanNationType
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>,Named,ObjectWithId
public class EuropeanNationType extends NationType
Represents one of the European nations present in the game, i.e. both REFs and possible human players.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.freecol.common.model.NationType
NationType.AggressionLevel, NationType.SettlementNumber
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDEFAULT_MAP_KEYprivate static java.lang.StringEXPERT_MAP_KEYprivate static java.lang.StringEXPERT_STARTING_UNITS_TAGprivate booleanrefWhether this is an REF Nation.private static java.lang.StringREF_TAGprivate static java.lang.StringROLE_TAGprivate java.util.Map<java.lang.String,java.util.Map<java.lang.String,AbstractUnit>>startingUnitMapStores the starting units of this Nation at various difficulties.static java.lang.StringTAGprivate static java.lang.StringTYPE_TAGprivate static java.lang.StringUNIT_TAG-
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 EuropeanNationType(java.lang.String id, Specification specification)Create a new European nation type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddStartingUnit(java.lang.String id, AbstractUnit unit, boolean expert)Add a starting unit.<T extends FreeColObject>
booleancopyIn(T other)Copy another FreeColObject into this one if it is compatible.private java.lang.StringgetMapKey(boolean b)Get the map key, either expert or default, according to a boolean.protected java.util.Map<java.lang.String,java.util.Map<java.lang.String,AbstractUnit>>getStartingUnitMap()Get the starting unit map.java.util.List<AbstractUnit>getStartingUnits()Gets the starting units for this nation type.java.util.List<AbstractUnit>getStartingUnits(java.lang.String key)Gets a list of this Nation's starting units at the given difficulty.java.lang.StringgetXMLTagName()Get the serialization tag for this object.booleanisEuropean()Is this a European nation type?booleanisIndian()Is this a native nation type?booleanisREF()Is this a REF nation type?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 voidsetStartingUnitMap(java.util.Map<java.lang.String,java.util.Map<java.lang.String,AbstractUnit>> startingUnitMap)Set the starting unit map.protected voidwriteAttributes(FreeColXMLWriter xw)Write the attributes of this object to a stream.protected voidwriteChildren(FreeColXMLWriter xw)Write the children of this object to a stream.private voidwriteUnit(FreeColXMLWriter xw, java.lang.String id, AbstractUnit au, boolean expert)-
Methods inherited from class net.sf.freecol.common.model.NationType
getAggression, getCapitalType, getNumberOfSettlements, getSettlementType, getSettlementType, getSettlementTypes, setSettlementTypes
-
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, 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
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
DEFAULT_MAP_KEY
private static final java.lang.String DEFAULT_MAP_KEY
- See Also:
- Constant Field Values
-
EXPERT_MAP_KEY
private static final java.lang.String EXPERT_MAP_KEY
- See Also:
- Constant Field Values
-
ref
private boolean ref
Whether this is an REF Nation.
-
startingUnitMap
private final java.util.Map<java.lang.String,java.util.Map<java.lang.String,AbstractUnit>> startingUnitMap
Stores the starting units of this Nation at various difficulties.
-
EXPERT_STARTING_UNITS_TAG
private static final java.lang.String EXPERT_STARTING_UNITS_TAG
- See Also:
- Constant Field Values
-
REF_TAG
private static final java.lang.String REF_TAG
- See Also:
- Constant Field Values
-
ROLE_TAG
private static final java.lang.String ROLE_TAG
- See Also:
- Constant Field Values
-
TYPE_TAG
private static final java.lang.String TYPE_TAG
- See Also:
- Constant Field Values
-
UNIT_TAG
private static final java.lang.String UNIT_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EuropeanNationType
public EuropeanNationType(java.lang.String id, Specification specification)Create a new European nation type.- Parameters:
id- The object identifier.specification- TheSpecificationto refer to.
-
-
Method Detail
-
getStartingUnitMap
protected java.util.Map<java.lang.String,java.util.Map<java.lang.String,AbstractUnit>> getStartingUnitMap()
Get the starting unit map.- Returns:
- The map of national starting units by difficulty.
-
setStartingUnitMap
protected void setStartingUnitMap(java.util.Map<java.lang.String,java.util.Map<java.lang.String,AbstractUnit>> startingUnitMap)
Set the starting unit map.- Parameters:
startingUnitMap- The new map of national starting units.
-
getMapKey
private java.lang.String getMapKey(boolean b)
Get the map key, either expert or default, according to a boolean.- Parameters:
b- The boolean to test.- Returns:
- The map key.
-
getStartingUnits
public java.util.List<AbstractUnit> getStartingUnits()
Gets the starting units for this nation type.- Returns:
- A list of
AbstractUnits to start with.
-
getStartingUnits
public java.util.List<AbstractUnit> getStartingUnits(java.lang.String key)
Gets a list of this Nation's starting units at the given difficulty.- Parameters:
key- The value of the expert-starting-units field.- Returns:
- A list of
AbstractUnits to start with.
-
addStartingUnit
private void addStartingUnit(java.lang.String id, AbstractUnit unit, boolean expert)Add a starting unit.- Parameters:
id- The unit identifier.unit- TheAbstractUnitto add.expert- Is this an expert unit?
-
isREF
public final boolean isREF()
Is this a REF nation type?- Specified by:
isREFin classNationType- Returns:
- True if this is a REF nation type.
-
isEuropean
public boolean isEuropean()
Is this a European nation type?- Specified by:
isEuropeanin classNationType- Returns:
- True.
-
isIndian
public boolean isIndian()
Is this a native nation type?- Specified by:
isIndianin classNationType- Returns:
- False.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.- Overrides:
copyInin classNationType- Type Parameters:
T- TheFreeColObjectsubclass 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:
writeAttributesin classNationType- Parameters:
xw- TheFreeColXMLWriterto 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:
writeChildrenin classNationType- Parameters:
xw- TheFreeColXMLWriterto write to.- Throws:
javax.xml.stream.XMLStreamException- if there are any problems writing to the stream.
-
writeUnit
private void writeUnit(FreeColXMLWriter xw, java.lang.String id, AbstractUnit au, boolean expert) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
readAttributes
protected void readAttributes(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.- Overrides:
readAttributesin classNationType- 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 classNationType- 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 classNationType- 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.
-
-