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, logger, PARTIAL_ATTRIBUTE
 
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.
 boolean equals(java.lang.Object o)
           
 Turn getFirstTurn()
          Get the firstTurn value.
 Turn getLastTurn()
          Get the LastTurn value.
 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)
           
protected  void readChildren(javax.xml.stream.XMLStreamReader in)
           
protected  void readFromXMLImpl(javax.xml.stream.XMLStreamReader in, Specification specification)
          Initialize this object from an XML-representation of this object.
 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)
           
protected  void writeChildren(javax.xml.stream.XMLStreamWriter out)
           
 
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAttribute, getAttribute, getAttribute, getAttribute, getId, getPropertyChangeListeners, getPropertyChangeListeners, getXMLElementTagName, hasAbility, hasAttribute, hasListeners, readAttributes, readFromArrayElement, readFromArrayElement, readFromArrayElement, readFromListElement, readFromXML, readFromXMLElement, readFromXMLImpl, readFromXMLPartialImpl, removePropertyChangeListener, removePropertyChangeListener, setId, toArrayElement, toArrayElement, toListElement, toXML, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, toXMLImpl, toXMLPartialImpl, writeAttribute, writeFreeColGameObject
 
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

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

writeAttributes

protected void writeAttributes(javax.xml.stream.XMLStreamWriter out)
                        throws javax.xml.stream.XMLStreamException
Overrides:
writeAttributes in class FreeColObject
Throws:
javax.xml.stream.XMLStreamException

writeChildren

protected void writeChildren(javax.xml.stream.XMLStreamWriter out)
                      throws javax.xml.stream.XMLStreamException
Overrides:
writeChildren in class FreeColObject
Throws:
javax.xml.stream.XMLStreamException

readFromXMLImpl

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

Parameters:
in - The input stream with the XML.
specification - a Specification value
Throws:
javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.

readAttributes

protected void readAttributes(javax.xml.stream.XMLStreamReader in,
                              Specification specification)
                       throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

readChildren

protected void readChildren(javax.xml.stream.XMLStreamReader in)
                     throws javax.xml.stream.XMLStreamException
Overrides:
readChildren in class FreeColObject
Throws:
javax.xml.stream.XMLStreamException