net.sf.freecol.common.model
Class FreeColGameObjectType

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.FreeColGameObjectType
Direct Known Subclasses:
BuildableType, Event, FoundingFather, GoodsType, Limit, Nation, NationType, ResourceType, SettlementType, TileImprovementType, TileType

public class FreeColGameObjectType
extends FreeColObject

The base class for all types defined by the specification. It can be instantiated in order to provide a source for modifiers and abilities that are provided by the code rather than defined in the specification, such as the "artillery in the open" penalty.


Field Summary
private  boolean abstractType
          Whether the type is abstract or can be instantiated.
private  FeatureContainer featureContainer
          Describe featureContainer here.
private  int index
           
private  int modifierIndex
          The default index of Modifiers provided by this type.
 
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
protected FreeColGameObjectType()
           
  FreeColGameObjectType(Specification specification)
           
  FreeColGameObjectType(java.lang.String id)
           
  FreeColGameObjectType(java.lang.String id, Specification specification)
           
 
Method Summary
 void addAbility(Ability ability)
           
 void addModifier(Modifier modifier)
           
 void applyDifficultyLevel(OptionGroup difficulty)
          Applies the difficulty level with the given ID to this FreeColGameObjectType.
 java.lang.String getDescriptionKey()
           
 FeatureContainer getFeatureContainer()
          Get the FeatureContainer value.
protected  int getIndex()
          Returns the index of this FreeColGameObjectType.
 int getModifierIndex()
          Get the ModifierIndex value.
 int getModifierIndex(Modifier modifier)
          Get the index for the given Modifier.
 java.util.Set<Modifier> getModifierSet(java.lang.String id)
           
 java.lang.String getNameKey()
           
 boolean hasAbility(java.lang.String id)
          Describe hasAbility method here.
 boolean hasAbility(java.lang.String id, FreeColGameObjectType type)
           
 boolean isAbstractType()
          Get the Abstract value.
protected  void readAttributes(javax.xml.stream.XMLStreamReader in)
          Reads the attributes of this object from an XML stream.
protected  void readChild(javax.xml.stream.XMLStreamReader in)
          Reads a common child object, i.e.
protected  void readChildren(javax.xml.stream.XMLStreamReader in)
          Reads the children of this object from an XML stream.
 void setAbstractType(boolean newAbstract)
          Set the Abstract value.
 void setFeatureContainer(FeatureContainer newFeatureContainer)
          Set the FeatureContainer value.
protected  void setIndex(int index)
          Describe setIndex method here.
 void setModifierIndex(int newModifierIndex)
          Set the ModifierIndex value.
 java.lang.String toString()
          Use only for debugging purposes! A human-readable and localized name is returned by getName().
protected  void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
          This method writes an XML-representation of this object to the given stream.
protected  void toXMLImpl(javax.xml.stream.XMLStreamWriter out, java.lang.String tag)
          This method writes an XML-representation of this object to the given stream.
protected  void writeChildren(javax.xml.stream.XMLStreamWriter out)
          Write the children 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, getXMLElementTagName, hasAttribute, hasListeners, readAttributes, readChild, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXML, readFromXMLElement, readFromXMLImpl, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, setSpecification, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLPartialImpl, writeAttribute, writeAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

index

private int index

modifierIndex

private int modifierIndex
The default index of Modifiers provided by this type.


abstractType

private boolean abstractType
Whether the type is abstract or can be instantiated.


featureContainer

private FeatureContainer featureContainer
Describe featureContainer here.

Constructor Detail

FreeColGameObjectType

protected FreeColGameObjectType()

FreeColGameObjectType

public FreeColGameObjectType(java.lang.String id)

FreeColGameObjectType

public FreeColGameObjectType(Specification specification)

FreeColGameObjectType

public FreeColGameObjectType(java.lang.String id,
                             Specification specification)
Method Detail

getFeatureContainer

public final FeatureContainer getFeatureContainer()
Get the FeatureContainer value.

Returns:
a FeatureContainer value

setFeatureContainer

public final void setFeatureContainer(FeatureContainer newFeatureContainer)
Set the FeatureContainer value.

Parameters:
newFeatureContainer - The new FeatureContainer value.

setIndex

protected final void setIndex(int index)
Describe setIndex method here.

Parameters:
index - an int value

getIndex

protected int getIndex()
Returns the index of this FreeColGameObjectType. The index imposes a total ordering consistent with equals on each class extending FreeColGameObjectType, but this ordering is nothing but the order in which the objects of the respective class were defined. It is guaranteed to remain stable only for a particular revision of a particular specification.

Returns:
an int value

getNameKey

public final java.lang.String getNameKey()

getDescriptionKey

public final java.lang.String getDescriptionKey()

hasAbility

public boolean hasAbility(java.lang.String id)
Description copied from class: FreeColObject
Describe hasAbility method here.

Overrides:
hasAbility in class FreeColObject
Parameters:
id - a String value
Returns:
a boolean value

hasAbility

public boolean hasAbility(java.lang.String id,
                          FreeColGameObjectType type)

addAbility

public void addAbility(Ability ability)

addModifier

public void addModifier(Modifier modifier)

getModifierSet

public java.util.Set<Modifier> getModifierSet(java.lang.String id)

applyDifficultyLevel

public void applyDifficultyLevel(OptionGroup difficulty)
Applies the difficulty level with the given ID to this FreeColGameObjectType. This method does nothing. If the behaviour of a FreeColGameObjectType depends on difficulty, it must override this method.

Parameters:
difficulty - difficulty level to apply

getModifierIndex

public final int getModifierIndex()
Get the ModifierIndex value.

Returns:
an int value

getModifierIndex

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

Parameters:
modifier - a Modifier value
Returns:
an int value

setModifierIndex

public final void setModifierIndex(int newModifierIndex)
Set the ModifierIndex value.

Parameters:
newModifierIndex - The new ModifierIndex value.

isAbstractType

public final boolean isAbstractType()
Get the Abstract value.

Returns:
a boolean value

setAbstractType

public final void setAbstractType(boolean newAbstract)
Set the Abstract value.

Parameters:
newAbstract - The new Abstract value.

toXMLImpl

protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
                  throws javax.xml.stream.XMLStreamException
Description copied from class: FreeColObject
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.

toXMLImpl

protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out,
                         java.lang.String tag)
                  throws javax.xml.stream.XMLStreamException
This method writes an XML-representation of this object to the given stream.

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

writeChildren

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

Overrides:
writeChildren in class FreeColObject
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 FreeColObject
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 FreeColObject
Parameters:
in - The XML input stream.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

readChild

protected void readChild(javax.xml.stream.XMLStreamReader in)
                  throws javax.xml.stream.XMLStreamException
Reads a common child object, i.e. an Ability or Modifier.

Overrides:
readChild in class FreeColObject
Parameters:
in - The XML input stream.
Throws:
javax.xml.stream.XMLStreamException - if an error occurs

toString

public java.lang.String toString()
Use only for debugging purposes! A human-readable and localized name is returned by getName().

Overrides:
toString in class java.lang.Object