Package net.sf.freecol.common.model
Class HighSeas
- 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.HighSeas
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>,Location,ObjectWithId
public class HighSeas extends UnitLocation
An object representing the high seas between continents.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.freecol.common.model.UnitLocation
UnitLocation.NoAddReason
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDESTINATION_TAGprivate java.util.List<Location>destinationsThe destinations this HighSeas object connects.private static java.util.logging.Loggerloggerstatic java.lang.StringTAG-
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDestination(Location destination)Add a single destination to this HighSeas instance.<T extends FreeColObject>
booleancopyIn(T other)Copy another FreeColObject into this one if it is compatible.java.lang.StringdestinationsToString()Convenience debug function to collect the destination ids.java.util.List<Location>getDestinations()Get the destinations connected by these seas.FreeColGameObjectgetLinkTarget(Player player)Get a suitable game object to use as a clickable link in messages to a player.StringTemplategetLocationLabel()Get a label for this location.UnitLocation.NoAddReasongetNoAddReason(Locatable locatable)Gets the reason why a givenLocatablecan not be added to this Location.intgetRank()Get a integer for this location, for the benefit of location comparators.java.lang.StringgetXMLTagName()Get the serialization tag for this object.protected voidreadChild(FreeColXMLReader xr)Reads a single child object.protected voidreadChildren(FreeColXMLReader xr)Reads the children of this object from an XML stream.voidremoveDestination(Location destination)Remove a single destination from this HighSeas instance.protected voidsetDestinations(java.util.List<Location> destinations)Set the destination list.java.lang.StringtoShortString()Get a short description of this location.java.lang.StringtoString()Locationup()Promote this location to a more meaningful one if possible.protected voidwriteChildren(FreeColXMLWriter xw)Write the children of this object to a stream.-
Methods inherited from class net.sf.freecol.common.model.UnitLocation
add, canAdd, clearUnitList, contains, disposeResources, equipForRole, getCarrierForUnit, getColony, getDisposables, getFirstUnit, getGoodsContainer, getIndianSettlement, getLastUnit, getLocationLabelFor, getNavalUnits, getSettlement, getSpaceTaken, getTile, getTotalUnitCount, getUnitCapacity, getUnitCount, getUnitList, getUnits, hasCarrierWithSpace, intern, isEmpty, isFull, moveToFront, priceGoods, remove
-
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
checkIntegrity, dispose, equals, fundamentalDispose, getClassIndex, getGame, getSpecification, hashCode, internId, isDisposed, isInitialized, isInternable, readAttributes, 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, 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, toXML, toXML, toXMLPartial, toXMLPartial, writeAttributes
-
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
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
destinations
private final java.util.List<Location> destinations
The destinations this HighSeas object connects.
-
DESTINATION_TAG
private static final java.lang.String DESTINATION_TAG
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDestinations
public final java.util.List<Location> getDestinations()
Get the destinations connected by these seas.- Returns:
- A list of
Locations.
-
destinationsToString
public final java.lang.String destinationsToString()
Convenience debug function to collect the destination ids.- Returns:
- A string representation of the destination identifiers.
-
setDestinations
protected void setDestinations(java.util.List<Location> destinations)
Set the destination list.- Parameters:
destinations- The new list of destinationLocations.
-
addDestination
public void addDestination(Location destination)
Add a single destination to this HighSeas instance.- Parameters:
destination- A destinationLocation.
-
removeDestination
public void removeDestination(Location destination)
Remove a single destination from this HighSeas instance.- Parameters:
destination- A destinationLocation.
-
getLocationLabel
public StringTemplate getLocationLabel()
Get a label for this location.- Specified by:
getLocationLabelin interfaceLocation- Overrides:
getLocationLabelin classUnitLocation- Returns:
- A label for this location.
-
up
public Location up()
Promote this location to a more meaningful one if possible. For example: a settlement is more meaningful than the tile it occupies.- Returns:
- A more meaningful
Location, or this one.
-
getRank
public int getRank()
Get a integer for this location, for the benefit of location comparators.- Returns:
- A suitable integer.
-
toShortString
public java.lang.String toShortString()
Get a short description of this location.- Returns:
- A short description.
-
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.
-
getLinkTarget
public FreeColGameObject getLinkTarget(Player player)
Get a suitable game object to use as a clickable link in messages to a player. Objects do not have links by default, hence the null return here. However, for example, a player's colony should return itself as a link target.- Overrides:
getLinkTargetin classFreeColGameObject- Parameters:
player- ThePlayerto make a link for.- Returns:
- A suitable link target if available, although usually null.
-
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.
-
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.
-
readChildren
protected void readChildren(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the children of this object from an XML stream.- Overrides:
readChildrenin classUnitLocation- 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 classUnitLocation- 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.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classFreeColObject
-
-