|
|||||||||
| 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.AbstractGoods
net.sf.freecol.common.model.Goods
public class Goods
Represents locatable goods of a specified type and amount. Use AbstractGoods to represent abstract or potential goods that need not be present in any particular location.
AbstractGoods| Field Summary | |
|---|---|
private Game |
game
|
private Location |
location
|
private static java.util.logging.Logger |
logger
|
| 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 | |
|---|---|
Goods(Game game,
org.w3c.dom.Element e)
Creates a new Goods instance. |
|
Goods(Game game,
Location location,
GoodsType type,
int amount)
Creates a standard Goods-instance given the place where
the goods is. |
|
Goods(Game game,
javax.xml.stream.XMLStreamReader in)
Creates a new Goods instance. |
|
| Method Summary | |
|---|---|
void |
adjustAmount()
If the amount of goods is greater than the container can hold, then this method adjusts the amount to the maximum amount possible. |
void |
changeLocation(Location location)
DO NOT USE, this is going away (into the server) soon. |
boolean |
equals(java.lang.Object obj)
|
Game |
getGame()
Gets the game object this Goods belongs to. |
StringTemplate |
getLabel(boolean sellable)
Returns the name of this type of goods. |
Location |
getLocation()
Gets the location of this goods. |
Player |
getOwner()
Gets the owner of this Ownable. |
int |
getSpaceTaken()
Gets the amount of space this Goods take. |
Tile |
getTile()
Returns the Tile where this Goods is located,
or null if it's location is Europe. |
static java.lang.String |
getXMLElementTagName()
Gets the tag name of the root element representing this object. |
int |
hashCode()
|
protected void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
Initialize this object from an XML-representation of this object. |
void |
setLocation(Location location)
Sets the location of the goods. |
void |
setOwner(Player p)
Sets the owner of this Ownable. |
java.lang.String |
toString()
Returns a textual representation of this object. |
static java.lang.String |
toString(Goods goods)
|
static java.lang.String |
toString(GoodsType goodsType,
int amount)
|
void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out)
This method writes an XML-representation of this object to the given stream. |
| Methods inherited from class net.sf.freecol.common.model.AbstractGoods |
|---|
equals, getAmount, getNameKey, getType, setAmount, setType, 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.Named |
|---|
getNameKey |
| Field Detail |
|---|
private static java.util.logging.Logger logger
private Game game
private Location location
| Constructor Detail |
|---|
public Goods(Game game,
Location location,
GoodsType type,
int amount)
Goods-instance given the place where
the goods is.
This constructor only asserts that the game and
that the location (if given) can store goods. The goods will not
be added to the location (use Location.add for this).
game - The Game in which this object belongslocation - The location of the goods (may be null)type - The type of the goods.amount - The amount of the goods.
java.lang.IllegalArgumentException - if the location cannot store any goods.
public Goods(Game game,
javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
Goods instance.
game - a Game valuein - a XMLStreamReader value
javax.xml.stream.XMLStreamException - if an error occurs
public Goods(Game game,
org.w3c.dom.Element e)
Goods instance.
game - a Game valuee - an Element value| Method Detail |
|---|
public Player getOwner()
Ownable.
getOwner in interface OwnablePlayer controlling this
Ownable.public void setOwner(Player p)
Ownable.
setOwner in interface Ownablep - The Player that should take ownership
of this Ownable.
java.lang.UnsupportedOperationException - is always thrown by
this method.public java.lang.String toString()
toString in class AbstractGoodsString with the format:
public static java.lang.String toString(Goods goods)
public static java.lang.String toString(GoodsType goodsType,
int amount)
public StringTemplate getLabel(boolean sellable)
sellable - Whether this type of goods is sellable;
public Tile getTile()
Tile where this Goods is located,
or null if it's location is Europe.
getTile in interface Locatablepublic Location getLocation()
getLocation in interface Locatablepublic void setLocation(Location location)
setLocation in interface Locatablelocation - The new Location of the goods.public void changeLocation(Location location)
public int getSpaceTaken()
Goods take.
getSpaceTaken in interface Locatablepublic void adjustAmount()
public Game getGame()
Goods belongs to.
Game.public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Object
public void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
toXMLImpl in class AbstractGoodsout - The target stream.
javax.xml.stream.XMLStreamException - if there are any problems writing
to the stream.
protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
throws javax.xml.stream.XMLStreamException
readFromXMLImpl in class AbstractGoodsin - The input stream with the XML.
javax.xml.stream.XMLStreamException - if a problem was encountered
during parsing.public static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||