|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.model.FreeColObject
net.sf.freecol.common.model.FreeColGameObject
net.sf.freecol.common.model.UnitLocation
public abstract class UnitLocation
The UnitLocation is a place where a Unit
can be put. The UnitLocation can not store any other Locatables,
such as Goods, or TileItems.
Locatable| Nested Class Summary | |
|---|---|
static class |
UnitLocation.NoAddReason
|
| Field Summary | |
|---|---|
private static java.util.logging.Logger |
logger
|
private java.util.List<Unit> |
units
The Units present in this Location. |
| Fields inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
UNITS_TAG_NAME |
| Fields inherited from class net.sf.freecol.common.model.FreeColObject |
|---|
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG |
| Constructor Summary | |
|---|---|
protected |
UnitLocation()
|
|
UnitLocation(Game game)
Creates a new UnitLocation instance. |
|
UnitLocation(Game game,
java.lang.String id)
Creates a new UnitLocation instance. |
|
UnitLocation(Game game,
javax.xml.stream.XMLStreamReader in)
Creates a new UnitLocation instance. |
| Method Summary | |
|---|---|
boolean |
add(Locatable locatable)
Adds a Locatable to this Location. |
boolean |
canAdd(Locatable locatable)
Checks whether or not the specified locatable may be added to this Location. |
boolean |
contains(Locatable locatable)
Checks if this Location contains the specified
Locatable. |
void |
dispose()
Dispose of this UnitLocation. |
java.util.List<FreeColGameObject> |
disposeList()
Removes all references to this object. |
Colony |
getColony()
Returns the Colony this Location is
located in, or null if it is not located in a colony. |
GoodsContainer |
getGoodsContainer()
Gets the GoodsContainer this Location
use for storing it's goods, or null if the
Location cannot store any goods. |
StringTemplate |
getLocationName()
Returns the name of this location. |
StringTemplate |
getLocationNameFor(Player player)
Returns the name of this location for a particular player. |
UnitLocation.NoAddReason |
getNoAddReason(Locatable locatable)
Gets the reason why a given Locatable can not be
added to this Location. |
Settlement |
getSettlement()
Returns the Settlement this Location
is located in, or null if it is not located in any
settlement. |
int |
getSpaceTaken()
Gets the current space taken by the units in this location. |
Tile |
getTile()
Returns the Tile where this Location
is located, or null if it is not located on a Tile. |
int |
getUnitCapacity()
Gets the maximum number of Units this Location
can hold. |
int |
getUnitCount()
Returns the number of Units at this Location. |
java.util.Iterator<Unit> |
getUnitIterator()
Gets a Iterator of every Unit directly
located on this Location. |
java.util.List<Unit> |
getUnitList()
Gets the Units present at this Location. |
boolean |
isEmpty()
Returns true if there are no Units present in this Location. |
boolean |
isFull()
Is this unit location full? |
protected void |
readChild(javax.xml.stream.XMLStreamReader in)
Reads a single child object. |
protected void |
readChildren(javax.xml.stream.XMLStreamReader in)
Reads the children of this object from an XML stream. |
boolean |
remove(Locatable locatable)
Removes a Locatable from this Location. |
protected void |
writeAttributes(javax.xml.stream.XMLStreamWriter out)
Write the attributes of this object to a stream. |
protected void |
writeChildren(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
Serialize the children of this UnitLocation, i.e. |
| Methods inherited from class net.sf.freecol.common.model.FreeColGameObject |
|---|
equals, equals, fundamentalDispose, getFreeColGameObject, getFreeColGameObject, getGame, getIntegerID, getSpecification, getXMLElementTagName, hashCode, isDisposed, isUninitialized, newLocation, readFromXML, readFromXMLPartialByClass, setDefaultId, setGame, setId, toString, toXML, toXMLImpl, toXMLImpl, toXMLPartialByClass, updateFreeColGameObject |
| 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 |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
private final java.util.List<Unit> units
| Constructor Detail |
|---|
protected UnitLocation()
public UnitLocation(Game game)
UnitLocation instance.
game - a Game value
public UnitLocation(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
UnitLocation instance.
game - a Game valuein - a XMLStreamReader value
javax.xml.stream.XMLStreamException - if an error occurs
public UnitLocation(Game game,
java.lang.String id)
UnitLocation instance.
game - a Game valueid - a String value| Method Detail |
|---|
public int getUnitCapacity()
Units this Location
can hold. To be overridden by subclasses.
public int getSpaceTaken()
public StringTemplate getLocationName()
getLocationName in interface Locationpublic StringTemplate getLocationNameFor(Player player)
getLocationNameFor in interface Locationplayer - The Player to return the name for.
public boolean canAdd(Locatable locatable)
Location.
canAdd in interface Locationlocatable - The Locatable to add.
public UnitLocation.NoAddReason getNoAddReason(Locatable locatable)
Locatable can not be
added to this Location.
locatable - The Locatable to test.
public boolean add(Locatable locatable)
Locatable to this Location.
add in interface Locationlocatable - The Locatable to add to this Location.public boolean remove(Locatable locatable)
Locatable from this Location.
remove in interface Locationlocatable - The Locatable to remove from this Location.public boolean contains(Locatable locatable)
Location contains the specified
Locatable.
contains in interface Locationlocatable - The Locatable to test the presence of.
Locatable is
on this Location and
public int getUnitCount()
getUnitCount in interface Locationpublic boolean isEmpty()
boolean valuepublic boolean isFull()
public java.util.List<Unit> getUnitList()
getUnitList in interface Locationpublic java.util.Iterator<Unit> getUnitIterator()
Iterator of every Unit directly
located on this Location.
getUnitIterator in interface LocationIterator.public Tile getTile()
Tile where this Location
is located, or null if it is not located on a Tile.
getTile in interface LocationTile valuepublic Colony getColony()
Colony this Location is
located in, or null if it is not located in a colony.
getColony in interface LocationColonypublic Settlement getSettlement()
Settlement this Location
is located in, or null if it is not located in any
settlement.
getSettlement in interface LocationSettlement valuepublic GoodsContainer getGoodsContainer()
GoodsContainer this Location
use for storing it's goods, or null if the
Location cannot store any goods.
getGoodsContainer in interface LocationGoodsContainer valuepublic java.util.List<FreeColGameObject> disposeList()
disposeList in class FreeColGameObjectpublic void dispose()
dispose in class FreeColGameObject
protected void writeAttributes(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
writeAttributes in class FreeColObjectout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
protected void writeChildren(javax.xml.stream.XMLStreamWriter out,
Player player,
boolean showAll,
boolean toSavedGame)
throws javax.xml.stream.XMLStreamException
out - a XMLStreamWriter valueplayer - a Player valueshowAll - a boolean valuetoSavedGame - a boolean value
javax.xml.stream.XMLStreamException - if an error occurs
protected void readChildren(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readChildren in class FreeColObjectin - The XML input stream.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.
protected void readChild(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
FreeColObject
readChild in class FreeColObjectin - The XML input stream.
javax.xml.stream.XMLStreamException - if an error occurs
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||