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
TheWorkLocationis a place in aColonywhereUnitscan 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 classWorkLocation.SuggestionContainer 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 ColonycolonyThe colony that contains this work location.private static java.lang.StringCOLONY_TAGstatic java.util.List<AbstractGoods>EMPTY_LISTprivate static java.util.logging.Loggerloggerprivate ProductionTypeproductionTypeThe 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 protectedWorkLocation(Game game)Constructor for ServerWorkLocation.WorkLocation(Game game, java.lang.String id)Creates a newWorkLocationwith the given identifier.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanadd(Locatable locatable)Adds aLocatableto this Location.abstract booleancanAutoProduce()Can this work location can produce goods without workers?booleancanBeWorked()Checks if this work location can actually be worked.abstract booleancanProduce(GoodsType goodsType, UnitType unitType)Can this work location produce a given goods type with an optional unit.booleancanTeach()Does this work location have teaching capability?<T extends FreeColObject>
booleancopyIn(T other)Copy another FreeColObject into this one if it is compatible.intevaluateFor(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 intgetBaseProduction(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.ProductionTypegetBestProductionType(boolean unattended, GoodsType workType)Get the best available production type at this work location.StringTemplategetClaimTemplate()Gets a template describing whether this work location can/needs-to be claimed.ColonygetColony()Get the colony at this location.abstract floatgetCompetenceFactor()Get a work location specific factor to multiply any goods-specific unit production bonuses by.GoodsTypegetCurrentWorkType()Get the current work type of any unit present.UnitTypegetExpertUnitType()Gets the unit type that is the expert for this work location using its first output for which an expert type can be found.intgetGenericPotential(GoodsType goodsType)Get the potential production of a given goods type using the default unit.java.util.stream.Stream<AbstractGoods>getInputs()Get theAbstractGoodsconsumed by this work location.abstract StringTemplategetLabel()Get a description of the work location, with any expected extra detail.abstract intgetLevel()Get the "level" of this work location.StringTemplategetLocationLabelFor(Player player)Get a label for this location for a particular player.intgetMaximumProductionOf(GoodsType goodsType)Gets the maximum production of this work location for a given goods type, assuming the current workers and input goods.UnitLocation.NoAddReasongetNoAddReason(Locatable locatable)Gets the reason why a givenLocatablecan not be added to this Location.abstract UnitLocation.NoAddReasongetNoWorkReason()Checks if this work location is available to the colony to be worked.OccupationgetOccupation(Unit unit, boolean userMode)Gets the best occupation for a given unit at this work location.OccupationgetOccupation(UnitType unitType)Gets the best occupation for a given unit type at this work location.java.util.stream.Stream<AbstractGoods>getOutputs()Get theAbstractGoodsproduced by this work location.PlayergetOwner()Gets the owner of thisOwnable.intgetPotentialProduction(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.AbstractGoodsgetProductionDeficit(GoodsType goodsType)Helper to get the production deficit for a type of goods.ProductionInfogetProductionInfo()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.intgetProductionOf(Unit unit, GoodsType goodsType)Gets the production of a unit of the given type of goods.ProductionTypegetProductionType()Get the production type.intgetRank()Get a integer for this location, for the benefit of location comparators.abstract floatgetRebelFactor()Get a work location specific factor to multiply the colony rebel bonus by.SettlementgetSettlement()Gets theSettlementthisLocationis located in.private WorkLocation.SuggestiongetSuggestion(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.TilegetTile()Gets the Tile associated with this Location.intgetTotalProductionOf(GoodsType goodsType)Gets the total production of a specified goods type at this work location.intgetUnitProduction(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.GoodsTypegetWorkFor(Unit unit)Get the best work type for a unit at this work location, favouring the existing work.abstract TilegetWorkTile()Get an associated tile, if any.protected booleangoodSuggestionCheck(UnitType unitType, Unit unit, GoodsType goodsType)Determines whether aWorkLocationis a good suggestionprotected booleangoodSuggestionCheck(UnitType unitType, Unit unit, GoodsType goodsType, WorkLocation workLocation)Determines whether aWorkLocationis a good suggestionbooleanhasInputs()Does this work location have any inputs.booleanhasOutputs()Does this work location have any outputs.abstract booleanisAvailable()Is this work location available?abstract booleanisCurrent()Is this a current work location of this colony?booleanproduces(GoodsType goodsType)Does this work location produce a given type of goods?protected voidreadAttributes(FreeColXMLReader xr)Reads the attributes of this object from an XML stream.voidreadChild(FreeColXMLReader xr)Reads a single child object.booleanremove(Locatable locatable)Removes aLocatablefrom this Location.voidsetColony(Colony colony)voidsetOwner(Player p)Sets the owner of thisOwnable.voidsetProductionType(ProductionType newProductionType)Set the prodution type.booleansetWorkFor(Unit unit)Install a unit at the best occupation for it at this work location.voidupdateProductionType()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 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.-
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 newWorkLocationwith 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
ProductionTypefor this work location.
-
setProductionType
public final void setProductionType(ProductionType newProductionType)
Set the prodution type.- Parameters:
newProductionType- The newProductionTypevalue.
-
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
GoodsTypebeing 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
ProductionTypegiven 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- TheUnitto find anOccupationfor.userMode- If a user requested this, favour the current work type, if not favour goods that the unit requires.- Returns:
- An
Occupationfor 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 optionalUnitTypeto find anOccupationfor. If null, use the default unit type.- Returns:
- An
Occupationfor 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- TheUnitto find a work type for.- Returns:
- The best work
GoodsTypefor 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- TheUnitto 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- TheUnitthat is doing the job at present, which may be null if none is at work.productionType- TheProductionTypeto use.goodsType- TheGoodsTypeto produce.- Returns:
- A
Suggestionfor a better worker, or null if improvement is not worthwhile.
-
goodSuggestionCheck
protected boolean goodSuggestionCheck(UnitType unitType, Unit unit, GoodsType goodsType)
Determines whether aWorkLocationis a good suggestion- Parameters:
unitType- The type ofUnitto check.unit- The Unit itself.goodsType- TheGoodsTypeto 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 aWorkLocationis a good suggestion- Parameters:
unitType- The type ofUnitto check.unit- The Unit itself.goodsType- TheGoodsTypeto check.workLocation- TheWorkLocationto 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 theAbstractGoodsconsumed by this work location.- Returns:
- A stream of
AbstractGoodsconsumed.
-
getOutputs
public java.util.stream.Stream<AbstractGoods> getOutputs()
Get theAbstractGoodsproduced by this work location.- Returns:
- A stream of
AbstractGoodsproduced.
-
produces
public boolean produces(GoodsType goodsType)
Does this work location produce a given type of goods?- Parameters:
goodsType- TheGoodsTypeto check.- Returns:
- True if this
WorkLocationproduces 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- TheGoodsTypeto 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- TheGoodsTypeto 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
UnitTypeor 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- TheGoodsTypeto 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- TheUnitto check.goodsType- TheGoodsTypeto 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- TheGoodsTypeto produce.unitType- The optionalUnitTypeto 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- TheGoodsTypeto 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:
getLocationLabelForin interfaceLocation- Overrides:
getLocationLabelForin classUnitLocation- Parameters:
player- ThePlayerto return the name for.- Returns:
- A label for this location.
-
getTile
public final Tile getTile()
Gets the Tile associated with this Location.- Specified by:
getTilein interfaceLocation- Overrides:
getTilein classUnitLocation- Returns:
- The Tile associated with this Location, or null if none found.
-
add
public boolean add(Locatable locatable)
Adds aLocatableto this Location.- Specified by:
addin interfaceLocation- Overrides:
addin classUnitLocation- Parameters:
locatable- TheLocatableto add to this Location.- Returns:
- True if the locatable was added.
-
remove
public boolean remove(Locatable locatable)
Removes aLocatablefrom this Location.- Specified by:
removein interfaceLocation- Overrides:
removein classUnitLocation- Parameters:
locatable- TheLocatableto remove from this Location.- Returns:
- True if the locatable was removed.
-
getSettlement
public final Settlement getSettlement()
Gets theSettlementthisLocationis located in.- Specified by:
getSettlementin interfaceLocation- Overrides:
getSettlementin classUnitLocation- Returns:
- The associated
Settlement, or null if none.
-
getColony
public final Colony getColony()
Get the colony at this location.- Specified by:
getColonyin interfaceLocation- Overrides:
getColonyin classUnitLocation- Returns:
- A
Colonyat 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 givenLocatablecan 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:
getNoAddReasonin classUnitLocation- Parameters:
locatable- TheLocatableto 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
StringTemplatefor 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
Tilewhich 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- TheGoodsTypeto 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 optionalProductionTypeto use, if null the best available one is used.goodsType- TheGoodsTypeto produce.unitType- An optionalUnitTypeto 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- TheGoodsTypeto produce.unitType- The optionalUnitTypeto 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
ProductionTypes.
-
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- ThePlayerto 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:
copyInin classUnitLocation- 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 classFreeColObject- 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 classUnitLocation- 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 classFreeColGameObject- Parameters:
xr- TheFreeColXMLReaderto 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:
readChildin classUnitLocation- Parameters:
xr- TheFreeColXMLReaderto read from.- Throws:
javax.xml.stream.XMLStreamException- if there is a problem reading the stream.
-
-