Package net.sf.freecol.common.model
Class WorkLocation
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColGameObject
-
- net.sf.freecol.common.model.UnitLocation
-
- net.sf.freecol.common.model.WorkLocation
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>
,Location
,Ownable
,ObjectWithId
- Direct Known Subclasses:
Building
,ColonyTile
public abstract class WorkLocation extends UnitLocation implements Ownable
TheWorkLocation
is a place in aColony
whereUnits
can work. The unit capacity of a WorkLocation is likely to be limited. ColonyTiles can only hold a single worker, and Buildings can hold no more than three workers, for example. WorkLocations do not store any Goods. They take any Goods they consume from the Colony, and put all Goods they produce there, too. Although the WorkLocation implementsOwnable
, its owner can not be changed directly, as it is always owned by the owner of the Colony.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WorkLocation.Suggestion
Container class to suggest a better use of a unit.-
Nested classes/interfaces inherited from class net.sf.freecol.common.model.UnitLocation
UnitLocation.NoAddReason
-
-
Field Summary
Fields Modifier and Type Field Description protected Colony
colony
The colony that contains this work location.private static java.lang.String
COLONY_TAG
static java.util.List<AbstractGoods>
EMPTY_LIST
private static java.util.logging.Logger
logger
private ProductionType
productionType
The production type of this WorkLocation.-
Fields inherited from class net.sf.freecol.common.model.FreeColGameObject
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
-
Fields inherited from interface net.sf.freecol.common.model.Location
LOCATION_RANK_EUROPE, LOCATION_RANK_HIGHSEAS, LOCATION_RANK_NOWHERE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
WorkLocation(Game game)
Constructor for ServerWorkLocation.WorkLocation(Game game, java.lang.String id)
Creates a newWorkLocation
with the given identifier.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
add(Locatable locatable)
Adds aLocatable
to this Location.abstract boolean
canAutoProduce()
Can this work location can produce goods without workers?boolean
canBeWorked()
Checks if this work location can actually be worked.abstract boolean
canProduce(GoodsType goodsType, UnitType unitType)
Can this work location produce a given goods type with an optional unit.boolean
canTeach()
Does this work location have teaching capability?<T extends FreeColObject>
booleancopyIn(T other)
Copy another FreeColObject into this one if it is compatible.int
evaluateFor(Player player)
Evaluate this work location for a given player.abstract java.util.List<ProductionType>
getAvailableProductionTypes(boolean unattended)
Get the production types available for this work location.abstract int
getBaseProduction(ProductionType productionType, GoodsType goodsType, UnitType unitType)
Gets the base production of a given goods type optionally using a unit of a given type in this work location.ProductionType
getBestProductionType(boolean unattended, GoodsType workType)
Get the best available production type at this work location.StringTemplate
getClaimTemplate()
Gets a template describing whether this work location can/needs-to be claimed.Colony
getColony()
Get the colony at this location.abstract float
getCompetenceFactor()
Get a work location specific factor to multiply any goods-specific unit production bonuses by.GoodsType
getCurrentWorkType()
Get the current work type of any unit present.UnitType
getExpertUnitType()
Gets the unit type that is the expert for this work location using its first output for which an expert type can be found.int
getGenericPotential(GoodsType goodsType)
Get the potential production of a given goods type using the default unit.java.util.stream.Stream<AbstractGoods>
getInputs()
Get theAbstractGoods
consumed by this work location.abstract StringTemplate
getLabel()
Get a description of the work location, with any expected extra detail.abstract int
getLevel()
Get the "level" of this work location.StringTemplate
getLocationLabelFor(Player player)
Get a label for this location for a particular player.int
getMaximumProductionOf(GoodsType goodsType)
Gets the maximum production of this work location for a given goods type, assuming the current workers and input goods.UnitLocation.NoAddReason
getNoAddReason(Locatable locatable)
Gets the reason why a givenLocatable
can not be added to this Location.abstract UnitLocation.NoAddReason
getNoWorkReason()
Checks if this work location is available to the colony to be worked.Occupation
getOccupation(Unit unit, boolean userMode)
Gets the best occupation for a given unit at this work location.Occupation
getOccupation(UnitType unitType)
Gets the best occupation for a given unit type at this work location.java.util.stream.Stream<AbstractGoods>
getOutputs()
Get theAbstractGoods
produced by this work location.Player
getOwner()
Gets the owner of thisOwnable
.int
getPotentialProduction(GoodsType goodsType, UnitType unitType)
Get the potential production of a given goods type at this location.java.util.List<AbstractGoods>
getProduction()
Gets the production at this work location.AbstractGoods
getProductionDeficit(GoodsType goodsType)
Helper to get the production deficit for a type of goods.ProductionInfo
getProductionInfo()
Gets the ProductionInfo for this WorkLocation from the Colony's cache.abstract java.util.stream.Stream<Modifier>
getProductionModifiers(GoodsType goodsType, UnitType unitType)
Gets the production modifiers for the given type of goods and unit type.int
getProductionOf(Unit unit, GoodsType goodsType)
Gets the production of a unit of the given type of goods.ProductionType
getProductionType()
Get the production type.int
getRank()
Get a integer for this location, for the benefit of location comparators.abstract float
getRebelFactor()
Get a work location specific factor to multiply the colony rebel bonus by.Settlement
getSettlement()
Gets theSettlement
thisLocation
is located in.private WorkLocation.Suggestion
getSuggestion(Unit unit, ProductionType productionType, GoodsType goodsType)
Is it a good idea to produce a goods type at this work location using a better unit type?java.util.Map<Unit,WorkLocation.Suggestion>
getSuggestions()
Get a map of suggestions for better or additional units.Tile
getTile()
Gets the Tile associated with this Location.int
getTotalProductionOf(GoodsType goodsType)
Gets the total production of a specified goods type at this work location.int
getUnitProduction(Unit unit, GoodsType goodsType)
Gets the productivity of a unit working in this work location, considering *only* the contribution of the unit, exclusive of that of the work location.GoodsType
getWorkFor(Unit unit)
Get the best work type for a unit at this work location, favouring the existing work.abstract Tile
getWorkTile()
Get an associated tile, if any.protected boolean
goodSuggestionCheck(UnitType unitType, Unit unit, GoodsType goodsType)
Determines whether aWorkLocation
is a good suggestionprotected boolean
goodSuggestionCheck(UnitType unitType, Unit unit, GoodsType goodsType, WorkLocation workLocation)
Determines whether aWorkLocation
is a good suggestionboolean
hasInputs()
Does this work location have any inputs.boolean
hasOutputs()
Does this work location have any outputs.abstract boolean
isAvailable()
Is this work location available?abstract boolean
isCurrent()
Is this a current work location of this colony?boolean
produces(GoodsType goodsType)
Does this work location produce a given type of goods?protected void
readAttributes(FreeColXMLReader xr)
Reads the attributes of this object from an XML stream.void
readChild(FreeColXMLReader xr)
Reads a single child object.boolean
remove(Locatable locatable)
Removes aLocatable
from this Location.void
setColony(Colony colony)
void
setOwner(Player p)
Sets the owner of thisOwnable
.void
setProductionType(ProductionType newProductionType)
Set the prodution type.boolean
setWorkFor(Unit unit)
Install a unit at the best occupation for it at this work location.void
updateProductionType()
Update production type on the basis of the current work location type (which might change due to an upgrade) and the work type of units present.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.UnitLocation
canAdd, clearUnitList, contains, disposeResources, equipForRole, getCarrierForUnit, getDisposables, getFirstUnit, getGoodsContainer, getIndianSettlement, getLastUnit, getLocationLabel, getNavalUnits, getSpaceTaken, getTotalUnitCount, getUnitCapacity, getUnitCount, getUnitList, getUnits, hasCarrierWithSpace, intern, isEmpty, isFull, moveToFront, priceGoods, readChildren
-
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
checkIntegrity, dispose, equals, fundamentalDispose, getClassIndex, getGame, getLinkTarget, getSpecification, hashCode, internId, isDisposed, isInitialized, isInternable, readFromXML, setGame, 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, 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, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setId, toString, toXML, toXML, toXMLPartial, toXMLPartial
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.freecol.common.model.Location
getId, getLocationImageKey, toShortString, up
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
EMPTY_LIST
public static final java.util.List<AbstractGoods> EMPTY_LIST
-
colony
protected Colony colony
The colony that contains this work location.
-
productionType
private ProductionType productionType
The production type of this WorkLocation.
-
COLONY_TAG
private static final java.lang.String COLONY_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WorkLocation
protected WorkLocation(Game game)
Constructor for ServerWorkLocation.- Parameters:
game
- The enclosingGame
.
-
WorkLocation
public WorkLocation(Game game, java.lang.String id)
Creates a newWorkLocation
with the given identifier. The object should be initialized later.- Parameters:
game
- The enclosingGame
.id
- The object identifier.
-
-
Method Detail
-
setColony
public void setColony(Colony colony)
-
getProductionType
public final ProductionType getProductionType()
Get the production type.- Returns:
- The
ProductionType
for this work location.
-
setProductionType
public final void setProductionType(ProductionType newProductionType)
Set the prodution type.- Parameters:
newProductionType
- The newProductionType
value.
-
getCurrentWorkType
public GoodsType getCurrentWorkType()
Get the current work type of any unit present. This assumes that all units in a work location are doing the same work, which is true for now.- Returns:
- The current
GoodsType
being produced, or null if none.
-
updateProductionType
public void updateProductionType()
Update production type on the basis of the current work location type (which might change due to an upgrade) and the work type of units present.
-
getBestProductionType
public ProductionType getBestProductionType(boolean unattended, GoodsType workType)
Get the best available production type at this work location.- Parameters:
unattended
- Whether to require unattended production.workType
- An optional work type to require.- Returns:
- The best available
ProductionType
given the argument constraints.
-
getOccupation
public Occupation getOccupation(Unit unit, boolean userMode)
Gets the best occupation for a given unit at this work location.- Parameters:
unit
- TheUnit
to find anOccupation
for.userMode
- If a user requested this, favour the current work type, if not favour goods that the unit requires.- Returns:
- An
Occupation
for the given unit, or null if none found.
-
getOccupation
public Occupation getOccupation(UnitType unitType)
Gets the best occupation for a given unit type at this work location.- Parameters:
unitType
- An optionalUnitType
to find anOccupation
for. If null, use the default unit type.- Returns:
- An
Occupation
for the given unit, or null if none found.
-
getWorkFor
public GoodsType getWorkFor(Unit unit)
Get the best work type for a unit at this work location, favouring the existing work.- Parameters:
unit
- TheUnit
to find a work type for.- Returns:
- The best work
GoodsType
for the unit, or null if none found.
-
setWorkFor
public boolean setWorkFor(Unit unit)
Install a unit at the best occupation for it at this work location.- Parameters:
unit
- TheUnit
to install.- Returns:
- True if the installation succeeds.
-
getSuggestion
private WorkLocation.Suggestion getSuggestion(Unit unit, ProductionType productionType, GoodsType goodsType)
Is it a good idea to produce a goods type at this work location using a better unit type?- Parameters:
unit
- TheUnit
that is doing the job at present, which may be null if none is at work.productionType
- TheProductionType
to use.goodsType
- TheGoodsType
to produce.- Returns:
- A
Suggestion
for a better worker, or null if improvement is not worthwhile.
-
goodSuggestionCheck
protected boolean goodSuggestionCheck(UnitType unitType, Unit unit, GoodsType goodsType)
Determines whether aWorkLocation
is a good suggestion- Parameters:
unitType
- The type ofUnit
to check.unit
- The Unit itself.goodsType
- TheGoodsType
to check.- Returns:
- True or false, depending on whether the suggestion is valid.
-
goodSuggestionCheck
protected boolean goodSuggestionCheck(UnitType unitType, Unit unit, GoodsType goodsType, WorkLocation workLocation)
Determines whether aWorkLocation
is a good suggestion- Parameters:
unitType
- The type ofUnit
to check.unit
- The Unit itself.goodsType
- TheGoodsType
to check.workLocation
- TheWorkLocation
to check. This can be overloaded with a default parameter of "this" to call the WorkLocation instance currently in in reference.- Returns:
- True or false, depending on whether the suggestion is valid.
-
getSuggestions
public java.util.Map<Unit,WorkLocation.Suggestion> getSuggestions()
Get a map of suggestions for better or additional units.- Returns:
- A mapping of either existing units or null (denoting
adding a unit) to a
Suggestion
.
-
getInputs
public java.util.stream.Stream<AbstractGoods> getInputs()
Get theAbstractGoods
consumed by this work location.- Returns:
- A stream of
AbstractGoods
consumed.
-
getOutputs
public java.util.stream.Stream<AbstractGoods> getOutputs()
Get theAbstractGoods
produced by this work location.- Returns:
- A stream of
AbstractGoods
produced.
-
produces
public boolean produces(GoodsType goodsType)
Does this work location produce a given type of goods?- Parameters:
goodsType
- TheGoodsType
to check.- Returns:
- True if this
WorkLocation
produces the givenGoodsType
.
-
hasInputs
public boolean hasInputs()
Does this work location have any inputs.- Returns:
- True if there are any inputs.
-
hasOutputs
public boolean hasOutputs()
Does this work location have any outputs.- Returns:
- True if there are any outputs.
-
canBeWorked
public boolean canBeWorked()
Checks if this work location can actually be worked.- Returns:
- True if the work location can be worked.
-
canTeach
public boolean canTeach()
Does this work location have teaching capability?- Returns:
- True if this is a teaching location.
- See Also:
Ability.TEACH
-
getProductionInfo
public ProductionInfo getProductionInfo()
Gets the ProductionInfo for this WorkLocation from the Colony's cache.- Returns:
- The work location
ProductionInfo
.
-
getProduction
public java.util.List<AbstractGoods> getProduction()
Gets the production at this work location.- Returns:
- The work location production.
-
getTotalProductionOf
public int getTotalProductionOf(GoodsType goodsType)
Gets the total production of a specified goods type at this work location.- Parameters:
goodsType
- TheGoodsType
to check.- Returns:
- The amount of production.
-
getMaximumProductionOf
public int getMaximumProductionOf(GoodsType goodsType)
Gets the maximum production of this work location for a given goods type, assuming the current workers and input goods.- Parameters:
goodsType
- TheGoodsType
to check.- Returns:
- The maximum production of the goods at this work location.
-
getExpertUnitType
public UnitType getExpertUnitType()
Gets the unit type that is the expert for this work location using its first output for which an expert type can be found.- Returns:
- The expert
UnitType
or null if none found.
-
getGenericPotential
public int getGenericPotential(GoodsType goodsType)
Get the potential production of a given goods type using the default unit. This is useful for planning.- Parameters:
goodsType
- TheGoodsType
to check.- Returns:
- The potential production.
-
getUnitProduction
public int getUnitProduction(Unit unit, GoodsType goodsType)
Gets the productivity of a unit working in this work location, considering *only* the contribution of the unit, exclusive of that of the work location. Used below, only public for the test suite.- Parameters:
unit
- TheUnit
to check.goodsType
- TheGoodsType
to check the production of.- Returns:
- The maximum return from this unit.
-
getProductionOf
public int getProductionOf(Unit unit, GoodsType goodsType)
Gets the production of a unit of the given type of goods.- Parameters:
unit
- The unit to do the work.goodsType
- The type of goods to get the production of.- Returns:
- The production of the given type of goods.
-
getPotentialProduction
public int getPotentialProduction(GoodsType goodsType, UnitType unitType)
Get the potential production of a given goods type at this location. An optional unit type to do the production may be specified, however if null the unattended production will be calculated. Usually if a unit type is specified and a unit can not be added to the work location, zero production is returned. However, this routine is intended to be used for planning purposes, so some exceptions are allowed --- the calculation proceeds: - for unclaimed tiles - when the location is currently full of units which are conditions that an AI might plausibly be able and willing to change (a case could be made for including the OCCUPIED_BY_ENEMY condition).- Parameters:
goodsType
- TheGoodsType
to produce.unitType
- The optionalUnitType
to do the work.- Returns:
- The potential production with the given goods type and unit type.
-
getProductionDeficit
public AbstractGoods getProductionDeficit(GoodsType goodsType)
Helper to get the production deficit for a type of goods.- Parameters:
goodsType
- TheGoodsType
to check.- Returns:
- The production deficit as
AbstractGoods
, or null if not in deficit.
-
getLocationLabelFor
public StringTemplate getLocationLabelFor(Player player)
Get a label for this location for a particular player.- Specified by:
getLocationLabelFor
in interfaceLocation
- Overrides:
getLocationLabelFor
in classUnitLocation
- Parameters:
player
- ThePlayer
to return the name for.- Returns:
- A label for this location.
-
getTile
public final Tile getTile()
Gets the Tile associated with this Location.- Specified by:
getTile
in interfaceLocation
- Overrides:
getTile
in classUnitLocation
- Returns:
- The Tile associated with this Location, or null if none found.
-
add
public boolean add(Locatable locatable)
Adds aLocatable
to this Location.- Specified by:
add
in interfaceLocation
- Overrides:
add
in classUnitLocation
- Parameters:
locatable
- TheLocatable
to add to this Location.- Returns:
- True if the locatable was added.
-
remove
public boolean remove(Locatable locatable)
Removes aLocatable
from this Location.- Specified by:
remove
in interfaceLocation
- Overrides:
remove
in classUnitLocation
- Parameters:
locatable
- TheLocatable
to remove from this Location.- Returns:
- True if the locatable was removed.
-
getSettlement
public final Settlement getSettlement()
Gets theSettlement
thisLocation
is located in.- Specified by:
getSettlement
in interfaceLocation
- Overrides:
getSettlement
in classUnitLocation
- Returns:
- The associated
Settlement
, or null if none.
-
getColony
public final Colony getColony()
Get the colony at this location.- Specified by:
getColony
in interfaceLocation
- Overrides:
getColony
in classUnitLocation
- Returns:
- A
Colony
at this location if any, or null if none found.
-
getRank
public final int getRank()
Get a integer for this location, for the benefit of location comparators.
-
getNoAddReason
public UnitLocation.NoAddReason getNoAddReason(Locatable locatable)
Gets the reason why a givenLocatable
can not be added to this Location. Be careful to test for unit presence last before success (NoAddReason.NONE) except perhaps for the capacity test, so that we can treat ALREADY_PRESENT as success in some cases (e.g. if the unit changes type --- does it still have a required skill?) FIXME: consider moving this up to Location?- Overrides:
getNoAddReason
in classUnitLocation
- Parameters:
locatable
- TheLocatable
to test.- Returns:
- The reason why adding would fail.
-
getLabel
public abstract StringTemplate getLabel()
Get a description of the work location, with any expected extra detail.- Returns:
- A label
StringTemplate
for this work location.
-
isAvailable
public abstract boolean isAvailable()
Is this work location available?- Returns:
- True if the work location is either current or can be claimed.
-
isCurrent
public abstract boolean isCurrent()
Is this a current work location of this colony?- Returns:
- True if the work location is current.
-
getNoWorkReason
public abstract UnitLocation.NoAddReason getNoWorkReason()
Checks if this work location is available to the colony to be worked.- Returns:
- The reason why/not the work location can be worked.
-
getWorkTile
public abstract Tile getWorkTile()
Get an associated tile, if any.- Returns:
- The underlying
Tile
which is worked, if any.
-
getLevel
public abstract int getLevel()
Get the "level" of this work location. Note: only meaningful for buildings at present.- Returns:
- The work location level.
-
canAutoProduce
public abstract boolean canAutoProduce()
Can this work location can produce goods without workers?- Returns:
- True if this work location can produce goods without workers.
-
canProduce
public abstract boolean canProduce(GoodsType goodsType, UnitType unitType)
Can this work location produce a given goods type with an optional unit.- Parameters:
goodsType
- TheGoodsType
to produce.unitType
- An optionalUnitType
, if null the unattended production is considered.- Returns:
- True if this location can produce the goods.
-
getBaseProduction
public abstract int getBaseProduction(ProductionType productionType, GoodsType goodsType, UnitType unitType)
Gets the base production of a given goods type optionally using a unit of a given type in this work location. That is, the production exclusive of any modifiers. If no unit type is specified, the unattended production is calculated.- Parameters:
productionType
- An optionalProductionType
to use, if null the best available one is used.goodsType
- TheGoodsType
to produce.unitType
- An optionalUnitType
to produce the goods.- Returns:
- The amount of goods potentially produced.
-
getProductionModifiers
public abstract java.util.stream.Stream<Modifier> getProductionModifiers(GoodsType goodsType, UnitType unitType)
Gets the production modifiers for the given type of goods and unit type. If no unit is specified the unattended production is calculated.- Parameters:
goodsType
- TheGoodsType
to produce.unitType
- The optionalUnitType
to produce them.- Returns:
- A stream of the applicable modifiers.
-
getAvailableProductionTypes
public abstract java.util.List<ProductionType> getAvailableProductionTypes(boolean unattended)
Get the production types available for this work location.- Parameters:
unattended
- If true, get unattended production types.- Returns:
- A list of suitable
ProductionType
s.
-
getCompetenceFactor
public abstract float getCompetenceFactor()
Get a work location specific factor to multiply any goods-specific unit production bonuses by.- Returns:
- The competence factor.
-
getRebelFactor
public abstract float getRebelFactor()
Get a work location specific factor to multiply the colony rebel bonus by.- Returns:
- The rebel factor.
-
evaluateFor
public int evaluateFor(Player player)
Evaluate this work location for a given player. To be overridden by subclasses.- Parameters:
player
- ThePlayer
to evaluate for.- Returns:
- A value for the player.
-
getClaimTemplate
public StringTemplate getClaimTemplate()
Gets a template describing whether this work location can/needs-to be claimed. To be overridden by classes where this is meaningful. This is a default null implementation.- Returns:
- A suitable template.
-
getOwner
public Player getOwner()
Gets the owner of thisOwnable
.
-
setOwner
public void setOwner(Player p)
Sets the owner of thisOwnable
. Do not call this method, ever. The owner of this WorkLocation is the owner of the Colony, you must set the owner of the Colony instead.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.- Overrides:
copyIn
in classUnitLocation
- 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 classUnitLocation
- 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 classFreeColGameObject
- Parameters:
xr
- TheFreeColXMLReader
to read from.- Throws:
javax.xml.stream.XMLStreamException
- if there is a problem reading the stream.
-
readChild
public 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 classUnitLocation
- Parameters:
xr
- TheFreeColXMLReader
to read from.- Throws:
javax.xml.stream.XMLStreamException
- if there is a problem reading the stream.
-
-