net.sf.freecol.common.model
Class BuildingType

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.FreeColGameObjectType
          extended by net.sf.freecol.common.model.BuildableType
              extended by net.sf.freecol.common.model.BuildingType
All Implemented Interfaces:
java.lang.Comparable<BuildingType>

public final class BuildingType
extends BuildableType
implements java.lang.Comparable<BuildingType>

Encapsulates data common to all instances of a particular kind of Building, such as the number of workplaces, and the types of goods it produces and consumes.


Field Summary
private  int basicProduction
           
private  GoodsType consumes
           
private  int level
           
private  int maxSkill
           
private  int minSkill
           
private  int priority
           
private  GoodsType produces
           
private  Modifier productionModifier
           
private  BuildingType upgradesFrom
           
private  BuildingType upgradesTo
           
private  int upkeep
           
private  int workPlaces
           
 
Fields inherited from class net.sf.freecol.common.model.BuildableType
NOTHING
 
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
BuildingType(java.lang.String id, Specification specification)
          Creates a new BuildingType instance.
 
Method Summary
 boolean canAdd(UnitType unitType)
          Returns true if the given UnitType could be added to a Building of this type.
 int compareTo(BuildingType other)
          Compares this BuildingType to another.
 void fixup09x()
          0.9.x compatibility hack, called from the specification reader when it is finishing up.
 int getBasicProduction()
          Returns the production of a single Unit in this BuildingType before any modifiers are applied.
 GoodsType getConsumedGoodsType()
          Returns the type of goods consumed by this BuildingType.
 BuildingType getFirstLevel()
          Returns the first level of this BuildingType.
 int getLevel()
          Returns the level of this BuildingType.
 int getModifierIndex(Modifier modifier)
          Get the index for the given Modifier.
 int getPriority()
          The consumption priority of a Building of this type.
 GoodsType getProducedGoodsType()
          Returns the type of goods produced by this BuildingType.
 Modifier getProductionModifier()
          Describe getProductionModifier method here.
 FreeColGameObjectType getType()
          Describe getType method here.
 BuildingType getUpgradesFrom()
          Returns the BuildingType this BuildingType upgrades from.
 BuildingType getUpgradesTo()
          Returns the BuildingType this BuildingType upgrades to.
 int getUpkeep()
          Returns the amount of gold necessary to maintain a Building of this type for one turn.
 int getWorkPlaces()
          Returns the number of workplaces, that is the maximum number of Units that can work in this BuildingType.
static java.lang.String getXMLElementTagName()
          Gets the tag name of the root element representing this object.
 boolean isAutomaticBuild()
          Is this building type automatically built in any colony?
protected  void readAttributes(javax.xml.stream.XMLStreamReader in)
          Reads the attributes of this object from an XML stream.
protected  void readChildren(javax.xml.stream.XMLStreamReader in)
          Reads the children of this object from an XML stream.
 void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          Makes an XML-representation of this object.
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.BuildableType
getAbilitiesRequired, getAmountRequiredOf, getGoodsRequired, getLimits, getPopulationRequired, needsGoodsToBuild, readChild, setGoodsRequired, setLimits, setPopulationRequired, writeChildren
 
Methods inherited from class net.sf.freecol.common.model.FreeColGameObjectType
addAbility, addModifier, applyDifficultyLevel, getDescriptionKey, getFeatureContainer, getIndex, getModifierIndex, getModifierSet, getNameKey, getSpecification, hasAbility, hasAbility, isAbstractType, setAbstractType, setFeatureContainer, setIndex, setModifierIndex, setSpecification, toString, toXMLImpl
 
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, hasAttribute, hasListeners, readAttributes, readChild, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXML, readFromXMLElement, readFromXMLImpl, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

level

private int level

workPlaces

private int workPlaces

basicProduction

private int basicProduction

minSkill

private int minSkill

maxSkill

private int maxSkill

upkeep

private int upkeep

priority

private int priority

consumes

private GoodsType consumes

produces

private GoodsType produces

productionModifier

private Modifier productionModifier

upgradesFrom

private BuildingType upgradesFrom

upgradesTo

private BuildingType upgradesTo
Constructor Detail

BuildingType

public BuildingType(java.lang.String id,
                    Specification specification)
Creates a new BuildingType instance.

Parameters:
id - a String value
specification - a Specification value
Method Detail

getUpgradesFrom

public BuildingType getUpgradesFrom()
Returns the BuildingType this BuildingType upgrades from.

Returns:
a BuildingType value

getUpgradesTo

public BuildingType getUpgradesTo()
Returns the BuildingType this BuildingType upgrades to.

Returns:
a BuildingType value

getFirstLevel

public BuildingType getFirstLevel()
Returns the first level of this BuildingType.

Returns:
a BuildingType value

getWorkPlaces

public int getWorkPlaces()
Returns the number of workplaces, that is the maximum number of Units that can work in this BuildingType.

Returns:
an int value

getBasicProduction

public int getBasicProduction()
Returns the production of a single Unit in this BuildingType before any modifiers are applied.

Returns:
an int value

getConsumedGoodsType

public GoodsType getConsumedGoodsType()
Returns the type of goods consumed by this BuildingType.

Returns:
an GoodsType value

getProducedGoodsType

public GoodsType getProducedGoodsType()
Returns the type of goods produced by this BuildingType.

Returns:
an GoodsType value

getLevel

public int getLevel()
Returns the level of this BuildingType.

Returns:
an int value

getUpkeep

public int getUpkeep()
Returns the amount of gold necessary to maintain a Building of this type for one turn.

Returns:
an int value

getPriority

public int getPriority()
The consumption priority of a Building of this type. The higher the priority, the earlier will the Consumer be allowed to consume the goods it requires.

Returns:
an int value

getType

public FreeColGameObjectType getType()
Describe getType method here.

Returns:
a FreeColGameObjectType value

getProductionModifier

public Modifier getProductionModifier()
Describe getProductionModifier method here.

Returns:
a Modifier value

compareTo

public int compareTo(BuildingType other)
Compares this BuildingType to another. BuildingTypes are sorted according to the order in which they are defined in the specification.

Specified by:
compareTo in interface java.lang.Comparable<BuildingType>
Parameters:
other - a BuildingType value
Returns:
an int value

canAdd

public boolean canAdd(UnitType unitType)
Returns true if the given UnitType could be added to a Building of this type.

Parameters:
unitType - an UnitType value
Returns:
a boolean value

isAutomaticBuild

public boolean isAutomaticBuild()
Is this building type automatically built in any colony?

Returns:
a boolean value

getModifierIndex

public final int getModifierIndex(Modifier modifier)
Get the index for the given Modifier.

Overrides:
getModifierIndex in class FreeColGameObjectType
Parameters:
modifier - a Modifier value
Returns:
an int value

toXMLImpl

public void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
               throws javax.xml.stream.XMLStreamException
Makes an XML-representation of this object.

Overrides:
toXMLImpl in class FreeColGameObjectType
Parameters:
out - The output 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 BuildableType
Parameters:
out - The target stream.
Throws:
javax.xml.stream.XMLStreamException - if there are any problems writing to the stream.

readAttributes

protected void readAttributes(javax.xml.stream.XMLStreamReader in)
                       throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.

Overrides:
readAttributes in class FreeColGameObjectType
Parameters:
in - The XML input stream.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

readChildren

protected void readChildren(javax.xml.stream.XMLStreamReader in)
                     throws javax.xml.stream.XMLStreamException
Reads the children of this object from an XML stream.

Overrides:
readChildren in class FreeColGameObjectType
Parameters:
in - The XML input stream.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

fixup09x

public void fixup09x()
0.9.x compatibility hack, called from the specification reader when it is finishing up.


getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Gets the tag name of the root element representing this object. This method should be overwritten by any sub-class, preferably with the name of the class with the first letter in lower case.

Returns:
"building-type".