net.sf.freecol.common.model
Class AbstractGoods

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.AbstractGoods
Direct Known Subclasses:
Goods

public class AbstractGoods
extends FreeColObject

Represents a certain amount of a GoodsType. It does not correspond to actual cargo present in a Location. It is intended to represent things such as the amount of Lumber necessary to build something, or the amount of cargo to load at a certain Location.


Field Summary
private  int amount
          Describe amount here.
private  GoodsType type
          Describe type here.
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE, ID_ATTRIBUTE, ID_ATTRIBUTE_TAG, INFINITY, logger, NO_ID, PARTIAL_ATTRIBUTE, UNDEFINED, VALUE_TAG
 
Constructor Summary
AbstractGoods()
          Creates a new AbstractGoods instance.
AbstractGoods(AbstractGoods other)
          Creates a new AbstractGoods instance.
AbstractGoods(GoodsType type, int amount)
          Creates a new AbstractGoods instance.
 
Method Summary
 boolean equals(AbstractGoods other)
           
 int getAmount()
          Get the Amount value.
 java.lang.String getNameKey()
           
 GoodsType getType()
          Get the Type value.
static java.lang.String getXMLElementTagName()
          Gets the tag name of the root element representing this object.
protected  void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
          Initialize this object from an XML-representation of this object.
 void setAmount(int newAmount)
          Set the Amount value.
 void setType(GoodsType newType)
          Set the Type value.
 java.lang.String toString()
           
 void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          This method writes an XML-representation of this object to the given stream.
protected  void writeAttributes(javax.xml.stream.XMLStreamWriter out)
          Write the attributes of this object to a stream.
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, getSpecification, hasAbility, hasAttribute, hasListeners, readAttributes, readAttributes, readChild, readChild, readChildren, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXML, readFromXMLElement, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute, writeChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

private GoodsType type
Describe type here.


amount

private int amount
Describe amount here.

Constructor Detail

AbstractGoods

public AbstractGoods()
Creates a new AbstractGoods instance.


AbstractGoods

public AbstractGoods(GoodsType type,
                     int amount)
Creates a new AbstractGoods instance.

Parameters:
type - a GoodsType value
amount - an int value

AbstractGoods

public AbstractGoods(AbstractGoods other)
Creates a new AbstractGoods instance.

Parameters:
other - an AbstractGoods value
Method Detail

getType

public final GoodsType getType()
Get the Type value.

Returns:
a GoodsType value

getNameKey

public java.lang.String getNameKey()

setType

public final void setType(GoodsType newType)
Set the Type value.

Parameters:
newType - The new Type value.

getAmount

public final int getAmount()
Get the Amount value.

Returns:
an int value

setAmount

public final void setAmount(int newAmount)
Set the Amount value.

Parameters:
newAmount - The new Amount value.

equals

public boolean equals(AbstractGoods other)

toXMLImpl

public void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
               throws javax.xml.stream.XMLStreamException
This method writes an XML-representation of this object to the given stream.

Specified by:
toXMLImpl in class FreeColObject
Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

writeAttributes

protected void writeAttributes(javax.xml.stream.XMLStreamWriter out)
                        throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream.

Overrides:
writeAttributes in class FreeColObject
Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readFromXMLImpl

protected void readFromXMLImpl(javax.xml.stream.XMLStreamReader in)
                        throws javax.xml.stream.XMLStreamException
Initialize this object from an XML-representation of this object.

Overrides:
readFromXMLImpl in class FreeColObject
Parameters:
in - The input stream with the XML.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Gets the tag name of the root element representing this object.

Returns:
"abstractGoods".