net.sf.freecol.common.model
Class Region

java.lang.Object
  extended by net.sf.freecol.common.model.FreeColObject
      extended by net.sf.freecol.common.model.FreeColGameObject
          extended by net.sf.freecol.common.model.Region
All Implemented Interfaces:
Nameable, Named
Direct Known Subclasses:
ServerRegion

public class Region
extends FreeColGameObject
implements Nameable

A named region on the map.


Nested Class Summary
static class Region.RegionType
           
 
Field Summary
static java.lang.String PACIFIC_NAME_KEY
           
 
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ID_ATTRIBUTE_TAG
 
Constructor Summary
Region(Game game)
          Creates a new Region instance.
Region(Game game, java.lang.String id)
          Creates a new Region instance.
Region(Game game, javax.xml.stream.XMLStreamReader in)
          Initiates a new Region from an XML representation.
 
Method Summary
 void discover(Player player, Turn turn, java.lang.String newName)
          Mark the Region as discovered.
 java.util.List<Region> getChildren()
          Get the Children value.
 Region getDiscoverableRegion()
          Returns a discoverable Region or null.
 Player getDiscoveredBy()
          Get the DiscoveredBy value.
 Turn getDiscoveredIn()
          Get the DiscoveredIn value.
 java.lang.String getDisplayName()
          Returns the name or default name of this Region.
 java.lang.String getName()
          Get the Name value.
 java.lang.String getNameKey()
          Get the NameKey value.
 Region getParent()
          Get the Parent value.
 int getScoreValue()
          Get the ScoreValue value.
 Region.RegionType getType()
          Get the Type value.
 java.lang.String getTypeName()
           
static java.lang.String getXMLElementTagName()
          Gets the tag name of the root element representing this object.
 boolean isClaimable()
          Get the Claimable value.
 boolean isDiscoverable()
          Get the Discoverable value.
 boolean isLeaf()
          Returns true if this is a leaf node.
 boolean isPacific()
          Returns true if this Region is the Pacific Ocean.
 boolean isPrediscovered()
          Get the Prediscovered value.
 boolean isRoot()
          Returns true if this is the whole map Region.
 void setChildren(java.util.List<Region> newChildren)
          Set the Children value.
 void setClaimable(boolean newClaimable)
          Set the Claimable value.
 void setDiscoverable(boolean newDiscoverable)
          Set the Discoverable value.
 void setDiscoveredBy(Player newDiscoveredBy)
          Set the DiscoveredBy value.
 void setDiscoveredIn(Turn newDiscoveredIn)
          Set the DiscoveredIn value.
 void setName(java.lang.String newName)
          Set the Name value.
 void setNameKey(java.lang.String newNameKey)
          Set the NameKey value.
 void setParent(Region newParent)
          Set the Parent value.
 void setPrediscovered(boolean newPrediscovered)
          Set the Prediscovered value.
 void setScoreValue(int newScoreValue)
          Set the ScoreValue value.
 void setType(Region.RegionType newType)
          Set the Type value.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class net.sf.freecol.common.model.FreeColGameObject
addToRemoveElement, dispose, equals, equals, getFreeColGameObject, getFreeColGameObject, getGame, getGameOptions, getIntegerID, hashCode, hasID, isDisposed, isUninitialized, readFromXML, setGame, setId, toSavedXML, toXML, updateFreeColGameObject, updateID
 
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, hasAbility, hasAttribute, hasListeners, readFromXMLElement, removePropertyChangeListener, removePropertyChangeListener, toXML, toXML, toXMLElement, toXMLElement, toXMLElement, toXMLElement, toXMLElementPartial, writeAttribute, writeFreeColGameObject
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PACIFIC_NAME_KEY

public static final java.lang.String PACIFIC_NAME_KEY
See Also:
Constant Field Values
Constructor Detail

Region

public Region(Game game)
Creates a new Region instance.

Parameters:
game - a Game value

Region

public Region(Game game,
              java.lang.String id)
Creates a new Region instance.

Parameters:
game - a Game value
id - a String value

Region

public Region(Game game,
              javax.xml.stream.XMLStreamReader in)
       throws javax.xml.stream.XMLStreamException
Initiates a new Region from an XML representation.

Parameters:
game - The Game this object belongs to.
in - The input stream containing the XML.
Throws:
javax.xml.stream.XMLStreamException - if an error occurred during parsing.
Method Detail

getNameKey

public final java.lang.String getNameKey()
Get the NameKey value.

Returns:
a String value

setNameKey

public final void setNameKey(java.lang.String newNameKey)
Set the NameKey value.

Parameters:
newNameKey - The new NameKey value.

isPacific

public boolean isPacific()
Returns true if this Region is the Pacific Ocean. The Pacific Ocean is special in so far as it is the only Region that could be discovered in the original game.

Returns:
a boolean value

getName

public final java.lang.String getName()
Get the Name value.

Specified by:
getName in interface Named
Returns:
a String value

setName

public final void setName(java.lang.String newName)
Set the Name value.

Specified by:
setName in interface Nameable
Parameters:
newName - The new Name value.

getDisplayName

public java.lang.String getDisplayName()
Returns the name or default name of this Region.

Returns:
a String value

getTypeName

public java.lang.String getTypeName()

getParent

public final Region getParent()
Get the Parent value.

Returns:
a Region value

setParent

public final void setParent(Region newParent)
Set the Parent value.

Parameters:
newParent - The new Parent value.

getChildren

public final java.util.List<Region> getChildren()
Get the Children value.

Returns:
a List value

setChildren

public final void setChildren(java.util.List<Region> newChildren)
Set the Children value.

Parameters:
newChildren - The new Children value.

isClaimable

public final boolean isClaimable()
Get the Claimable value.

Returns:
a boolean value

setClaimable

public final void setClaimable(boolean newClaimable)
Set the Claimable value.

Parameters:
newClaimable - The new Claimable value.

isDiscoverable

public final boolean isDiscoverable()
Get the Discoverable value.

Returns:
a boolean value

setDiscoverable

public final void setDiscoverable(boolean newDiscoverable)
Set the Discoverable value.

Parameters:
newDiscoverable - The new Discoverable value.

isPrediscovered

public final boolean isPrediscovered()
Get the Prediscovered value.

Returns:
a boolean value

setPrediscovered

public final void setPrediscovered(boolean newPrediscovered)
Set the Prediscovered value.

Parameters:
newPrediscovered - The new Prediscovered value.

getScoreValue

public final int getScoreValue()
Get the ScoreValue value.

Returns:
an int value

setScoreValue

public final void setScoreValue(int newScoreValue)
Set the ScoreValue value.

Parameters:
newScoreValue - The new ScoreValue value.

getType

public final Region.RegionType getType()
Get the Type value.

Returns:
a RegionType value

setType

public final void setType(Region.RegionType newType)
Set the Type value.

Parameters:
newType - The new Type value.

isRoot

public boolean isRoot()
Returns true if this is the whole map Region.

Returns:
a boolean value

isLeaf

public boolean isLeaf()
Returns true if this is a leaf node.

Returns:
a boolean value

getDiscoverableRegion

public Region getDiscoverableRegion()
Returns a discoverable Region or null. If this region is discoverable, it is returned. If not, a discoverable parent is returned, unless there is none. This is intended for discovering the Pacific Ocean when discovering one of its sub-Regions.

Returns:
a Region value

getDiscoveredIn

public final Turn getDiscoveredIn()
Get the DiscoveredIn value.

Returns:
a Turn value

setDiscoveredIn

public final void setDiscoveredIn(Turn newDiscoveredIn)
Set the DiscoveredIn value.

Parameters:
newDiscoveredIn - The new DiscoveredIn value.

getDiscoveredBy

public final Player getDiscoveredBy()
Get the DiscoveredBy value.

Returns:
a Player value

setDiscoveredBy

public final void setDiscoveredBy(Player newDiscoveredBy)
Set the DiscoveredBy value.

Parameters:
newDiscoveredBy - The new DiscoveredBy value.

discover

public void discover(Player player,
                     Turn turn,
                     java.lang.String newName)
Mark the Region as discovered.

Parameters:
player - a Player value
turn - a Turn value
newName - a String value

getXMLElementTagName

public static java.lang.String getXMLElementTagName()
Gets the tag name of the root element representing this object.

Returns:
"region".

toString

public java.lang.String toString()
Description copied from class: FreeColGameObject
Returns a string representation of the object.

Overrides:
toString in class FreeColGameObject
Returns:
The String