net.sf.freecol.common.model
Class Feature

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.Feature
Direct Known Subclasses:
Ability, Modifier

public abstract class Feature
extends FreeColObject

The Feature class encapsulates a bonus or penalty that can be applied to any action within the game, most obviously combat.


Field Summary
private  Turn firstTurn
          The first Turn in which this Feature applies.
private  Turn lastTurn
          The last Turn in which this Feature applies.
private  java.util.List<Scope> scopes
          A list of Scopes limiting the applicability of this Feature.
private  FreeColGameObjectType source
          The source of this Feature, e.g.
 
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
Feature()
           
 
Method Summary
 boolean appliesTo(FreeColGameObjectType objectType)
          Returns true if the appliesTo method of at least one Scope object returns true.
 boolean appliesTo(FreeColGameObjectType objectType, Turn turn)
          Returns true if the appliesTo method of at least one Scope object returns true.
protected  void copy(Feature other)
           
 boolean equals(java.lang.Object o)
          
 Turn getFirstTurn()
          Get the firstTurn value.
 Turn getLastTurn()
          Get the LastTurn value.
 java.lang.String getNameKey()
          Describe getNameKey method here.
 java.util.List<Scope> getScopes()
          Get the Scopes value.
 FreeColGameObjectType getSource()
          Get the Source value.
 int hashCode()
          
 boolean hasScope()
          Get the Scope value.
 boolean hasTimeLimit()
          Get the TimeLimit value.
 boolean isOutOfDate(Turn turn)
          Returns true if the Feature has an lastTurn turn smaller than the turn given.
protected  void readAttributes(javax.xml.stream.XMLStreamReader in, Specification specification)
          Reads the attributes of this object from an XML stream.
protected  void readChildren(javax.xml.stream.XMLStreamReader in, Specification specification)
          Reads the children of this object from an XML stream.
 void setFirstTurn(Turn newFirstTurn)
          Set the firstTurn value.
 void setLastTurn(Turn newLastTurn)
          Set the LastTurn value.
 void setScopes(java.util.List<Scope> newScopes)
          Set the Scopes value.
 void setSource(FreeColGameObjectType newSource)
          Set the Source value.
protected  void writeAttributes(javax.xml.stream.XMLStreamWriter out)
          Write the attributes of this object to a 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, hasAbility, hasAttribute, hasListeners, readAttributes, readChild, readChild, readChildren, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXML, readFromXMLElement, readFromXMLImpl, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, save, save, setId, setSpecification, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLImpl, toXMLPartialImpl, writeAttribute
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

private FreeColGameObjectType source
The source of this Feature, e.g. a UnitType.


firstTurn

private Turn firstTurn
The first Turn in which this Feature applies.


lastTurn

private Turn lastTurn
The last Turn in which this Feature applies.


scopes

private java.util.List<Scope> scopes
A list of Scopes limiting the applicability of this Feature.

Constructor Detail

Feature

public Feature()
Method Detail

hasTimeLimit

public final boolean hasTimeLimit()
Get the TimeLimit value.

Returns:
a boolean value

hasScope

public final boolean hasScope()
Get the Scope value.

Returns:
a boolean value

getNameKey

public java.lang.String getNameKey()
Describe getNameKey method here.

Returns:
a String value

getScopes

public final java.util.List<Scope> getScopes()
Get the Scopes value.

Returns:
a List value

setScopes

public final void setScopes(java.util.List<Scope> newScopes)
Set the Scopes value.

Parameters:
newScopes - The new Scopes value.

getFirstTurn

public final Turn getFirstTurn()
Get the firstTurn value.

Returns:
a Turn value

setFirstTurn

public final void setFirstTurn(Turn newFirstTurn)
Set the firstTurn value.

Parameters:
newFirstTurn - The new FirstTurn value.

getLastTurn

public final Turn getLastTurn()
Get the LastTurn value.

Returns:
a Turn value

setLastTurn

public final void setLastTurn(Turn newLastTurn)
Set the LastTurn value.

Parameters:
newLastTurn - The new LastTurn value.

getSource

public final FreeColGameObjectType getSource()
Get the Source value.

Returns:
a String value

setSource

public final void setSource(FreeColGameObjectType newSource)
Set the Source value.

Parameters:
newSource - The new Source value.

appliesTo

public boolean appliesTo(FreeColGameObjectType objectType)
Returns true if the appliesTo method of at least one Scope object returns true.

Parameters:
objectType - a FreeColGameObjectType value
Returns:
a boolean value

appliesTo

public boolean appliesTo(FreeColGameObjectType objectType,
                         Turn turn)
Returns true if the appliesTo method of at least one Scope object returns true.

Parameters:
objectType - a FreeColGameObjectType value
turn - a Turn value
Returns:
a boolean value

isOutOfDate

public boolean isOutOfDate(Turn turn)
Returns true if the Feature has an lastTurn turn smaller than the turn given.

Parameters:
turn - a Turn value
Returns:
a boolean value

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

copy

protected void copy(Feature other)

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.

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,
                              Specification specification)
                       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.
specification - A Specification to use.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

readChildren

protected void readChildren(javax.xml.stream.XMLStreamReader in,
                            Specification specification)
                     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.
specification - A Specification to use.
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.