net.sf.freecol.common.model
Class AbstractUnit

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.AbstractUnit

public class AbstractUnit
extends FreeColObject

Contains the information necessary to create a new unit.


Field Summary
private  int number
          The number of units.
private  Unit.Role role
          The role of this AbstractUnit.
 
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
AbstractUnit()
           
AbstractUnit(java.lang.String id, Unit.Role someRole, int someNumber)
           
AbstractUnit(UnitType unitType, Unit.Role someRole, int someNumber)
           
AbstractUnit(javax.xml.stream.XMLStreamReader in)
          Creates a new AbstractUnit instance.
 
Method Summary
 EquipmentType[] getEquipment(Specification specification)
          Returns the Equipment necessary to create a Unit with the same type and role as this AbstractUnit.
 StringTemplate getLabel(Specification spec)
          Describe getLabel method here.
 int getNumber()
          Get the Number value.
 Unit.Role getRole()
          Get the Role value.
 UnitType getUnitType(Specification specification)
          Get the UnitType value.
static java.lang.String getXMLElementTagName()
          Returns the tag name of the root element representing this object.
protected  void readAttributes(javax.xml.stream.XMLStreamReader in)
          Initialize this object from an XML-representation of this object.
 void setNumber(int newNumber)
          Set the Number value.
 void setRole(Unit.Role newRole)
          Set the Role value.
 java.lang.String toString()
           
protected  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, readChild, readChild, readChildren, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXML, readFromXMLElement, readFromXMLImpl, 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

role

private Unit.Role role
The role of this AbstractUnit.


number

private int number
The number of units.

Constructor Detail

AbstractUnit

public AbstractUnit()

AbstractUnit

public AbstractUnit(java.lang.String id,
                    Unit.Role someRole,
                    int someNumber)

AbstractUnit

public AbstractUnit(UnitType unitType,
                    Unit.Role someRole,
                    int someNumber)

AbstractUnit

public AbstractUnit(javax.xml.stream.XMLStreamReader in)
             throws javax.xml.stream.XMLStreamException
Creates a new AbstractUnit instance.

Parameters:
in - a XMLStreamReader value
Throws:
javax.xml.stream.XMLStreamException - if an error occurs
Method Detail

getUnitType

public final UnitType getUnitType(Specification specification)
Get the UnitType value.

Returns:
an UnitType value

getRole

public final Unit.Role getRole()
Get the Role value.

Returns:
a Role value

setRole

public final void setRole(Unit.Role newRole)
Set the Role value.

Parameters:
newRole - The new Role value.

getNumber

public final int getNumber()
Get the Number value.

Returns:
an int value

setNumber

public final void setNumber(int newNumber)
Set the Number value.

Parameters:
newNumber - The new Number value.

getLabel

public StringTemplate getLabel(Specification spec)
Describe getLabel method here.

Parameters:
spec - A Specification to query.
Returns:
a StringTemplate value

getEquipment

public EquipmentType[] getEquipment(Specification specification)
Returns the Equipment necessary to create a Unit with the same type and role as this AbstractUnit.

Returns:
an EquipmentType[] value

toXMLImpl

protected 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.

readAttributes

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

Overrides:
readAttributes 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()
Returns the tag name of the root element representing this object.

Returns:
"abstractUnit".