net.sf.freecol.common
Class Specification

java.lang.Object
  extended by net.sf.freecol.common.Specification

public final class Specification
extends java.lang.Object

This class encapsulates any parts of the "specification" for FreeCol that are expressed best using XML. The XML is loaded through the class loader from the resource named "specification.xml" in the same package as this class.


Field Summary
static FreeColGameObjectType AMBUSH_BONUS_SOURCE
           
static FreeColGameObjectType ARTILLERY_PENALTY_SOURCE
           
static FreeColGameObjectType ATTACK_BONUS_SOURCE
           
static FreeColGameObjectType BASE_DEFENCE_SOURCE
           
static FreeColGameObjectType BASE_OFFENCE_SOURCE
           
static FreeColGameObjectType CARGO_PENALTY_SOURCE
           
static FreeColGameObjectType COLONY_GOODS_PARTY
           
static FreeColGameObjectType FORTIFICATION_BONUS_SOURCE
           
static FreeColGameObjectType IN_CAPITAL
           
static FreeColGameObjectType IN_SETTLEMENT
           
static FreeColGameObjectType INDIAN_RAID_BONUS_SOURCE
           
static FreeColGameObjectType MOVEMENT_PENALTY_SOURCE
           
 
Method Summary
 void addAbility(Ability ability)
          Registers an Ability as defined.
 void addAbility(java.lang.String id)
          Registers an Ability's id as defined.
 void addAbstractOption(AbstractOption abstractOption)
          Adds an AbstractOption to the specification
 void addModifier(Modifier modifier)
          Add a modifier.
 void addOptionGroup(OptionGroup optionGroup)
          Adds an OptionGroup to the specification
 void applyDifficultyLevel(int difficultyLevel)
          Applies the difficulty level to the current specification.
static void createSpecification(java.io.InputStream is)
          Loads the specification.
 java.util.List<Ability> getAbilities(java.lang.String id)
          Return a list of all Abilities with the given id.
 BooleanOption getBooleanOption(java.lang.String Id)
          Returns the BooleanOption with the given ID.
 BuildingType getBuildingType(int buildingTypeIndex)
          Describe getBuildingType method here.
 BuildingType getBuildingType(java.lang.String id)
           
 java.util.List<BuildingType> getBuildingTypeList()
           
 DifficultyLevel getDifficultyLevel(int level)
          Describe getDifficultyLevel method here.
 DifficultyLevel getDifficultyLevel(java.lang.String id)
          Describe getDifficultyLevel method here.
 java.util.List<DifficultyLevel> getDifficultyLevels()
           
 EquipmentType getEquipmentType(java.lang.String id)
           
 java.util.List<EquipmentType> getEquipmentTypeList()
           
 java.util.List<Nation> getEuropeanNations()
           
 java.util.List<EuropeanNationType> getEuropeanNationTypes()
           
 UnitType getExpertForProducing(GoodsType goodsType)
           
 java.util.List<GoodsType> getFarmedGoodsTypeList()
           
 FoundingFather getFoundingFather(java.lang.String id)
           
 java.util.List<FoundingFather> getFoundingFathers()
           
 java.util.List<GoodsType> getGoodsFood()
           
 GoodsType getGoodsType(java.lang.String id)
          Describe getGoodsType method here.
 java.util.List<GoodsType> getGoodsTypeList()
           
 java.util.List<GoodsType> getImmigrationGoodsTypeList()
           
 ImprovementActionType getImprovementActionType(java.lang.String id)
           
 java.util.List<ImprovementActionType> getImprovementActionTypeList()
           
 java.util.List<Nation> getIndianNations()
           
 java.util.List<IndianNationType> getIndianNationTypes()
           
 IntegerOption getIntegerOption(java.lang.String Id)
          Returns the IntegerOption with the given ID.
 java.util.List<GoodsType> getLibertyGoodsTypeList()
           
 java.util.List<Modifier> getModifiers(java.lang.String id)
          Return a list of all Modifiers with the given id.
 Nation getNation(java.lang.String id)
           
 java.util.List<Nation> getNations()
           
 NationType getNationType(java.lang.String id)
           
 java.util.List<NationType> getNationTypes()
           
 java.util.List<GoodsType> getNewWorldGoodsTypeList()
           
 AbstractOption getOption(java.lang.String Id)
          Returns the AbstractOption with the given ID.
 OptionGroup getOptionGroup(java.lang.String Id)
          Returns the OptionGroup with the given ID.
 RangeOption getRangeOption(java.lang.String Id)
          Returns the RangeOption with the given ID.
 java.util.List<Nation> getREFNations()
           
 java.util.List<EuropeanNationType> getREFNationTypes()
           
 ResourceType getResourceType(java.lang.String id)
           
 java.util.List<ResourceType> getResourceTypeList()
           
static Specification getSpecification()
           
 StringOption getStringOption(java.lang.String Id)
          Returns the StringOption with the given ID.
 TileImprovementType getTileImprovementType(java.lang.String id)
           
 java.util.List<TileImprovementType> getTileImprovementTypeList()
           
 TileType getTileType(java.lang.String id)
           
 java.util.List<TileType> getTileTypeList()
           
 FreeColGameObjectType getType(java.lang.String Id)
           
<T extends FreeColGameObjectType>
T
getType(java.lang.String Id, java.lang.Class<T> type)
          Returns the FreeColGameObjectType with the given ID.
<T extends FreeColGameObjectType>
T
getType(javax.xml.stream.XMLStreamReader in, java.lang.String attributeName, java.lang.Class<T> returnClass, T defaultValue)
          Returns the FreeColGameObjectType identified by the attributeName, or the default value if there is no such attribute.
 java.util.List<FreeColGameObjectType> getTypesProviding(java.lang.String id, boolean value)
          Return a list of FreeColGameObjectTypes that provide the required ability.
<T extends FreeColGameObjectType>
java.util.List<T>
getTypesWithAbility(java.lang.Class<T> resultType, java.lang.String... abilities)
          Return all types which have any of the given abilities.
 UnitType getUnitType(java.lang.String id)
           
 java.util.List<UnitType> getUnitTypeList()
           
 java.util.List<UnitType> getUnitTypesPurchasedInEurope()
          Returns the unit types that can be purchased in Europe.
 java.util.List<UnitType> getUnitTypesTrainedInEurope()
          Returns the unit types that can be trained in Europe.
 java.util.List<UnitType> getUnitTypesWithAbility(java.lang.String... abilities)
          Return the unit types which have any of the given abilities
 boolean hasOption(java.lang.String Id)
          Is option with this ID present? This is helpful when options are optionally(!) present, for example model.option.priceIncrease.artillery exists but model.option.priceIncrease.frigate does not.
 int numberOfBuildingTypes()
          Describe numberOfBuildingTypes method here.
 int numberOfFarmedGoodsTypes()
          Describe numberOfFarmedGoodsTypes method here.
 int numberOfFoundingFathers()
           
 int numberOfGoodsTypes()
          Describe numberOfGoodsTypes method here.
 int numberOfNationTypes()
           
 int numberOfResourceTypes()
           
 int numberOfStoredGoodsTypes()
           
 int numberOfTileTypes()
           
 int numberOfUnitTypes()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MOVEMENT_PENALTY_SOURCE

public static final FreeColGameObjectType MOVEMENT_PENALTY_SOURCE

ARTILLERY_PENALTY_SOURCE

public static final FreeColGameObjectType ARTILLERY_PENALTY_SOURCE

ATTACK_BONUS_SOURCE

public static final FreeColGameObjectType ATTACK_BONUS_SOURCE

FORTIFICATION_BONUS_SOURCE

public static final FreeColGameObjectType FORTIFICATION_BONUS_SOURCE

INDIAN_RAID_BONUS_SOURCE

public static final FreeColGameObjectType INDIAN_RAID_BONUS_SOURCE

BASE_OFFENCE_SOURCE

public static final FreeColGameObjectType BASE_OFFENCE_SOURCE

BASE_DEFENCE_SOURCE

public static final FreeColGameObjectType BASE_DEFENCE_SOURCE

CARGO_PENALTY_SOURCE

public static final FreeColGameObjectType CARGO_PENALTY_SOURCE

AMBUSH_BONUS_SOURCE

public static final FreeColGameObjectType AMBUSH_BONUS_SOURCE

IN_SETTLEMENT

public static final FreeColGameObjectType IN_SETTLEMENT

IN_CAPITAL

public static final FreeColGameObjectType IN_CAPITAL

COLONY_GOODS_PARTY

public static final FreeColGameObjectType COLONY_GOODS_PARTY
Method Detail

addAbility

public void addAbility(Ability ability)
Registers an Ability as defined.

Parameters:
ability - an Ability value

addAbility

public void addAbility(java.lang.String id)
Registers an Ability's id as defined. This is useful for abilities that are required rather than provided by FreeColGameObjectTypes.

Parameters:
id - a String value

getAbilities

public java.util.List<Ability> getAbilities(java.lang.String id)
Return a list of all Abilities with the given id.

Parameters:
id - the ability id

getTypesProviding

public java.util.List<FreeColGameObjectType> getTypesProviding(java.lang.String id,
                                                               boolean value)
Return a list of FreeColGameObjectTypes that provide the required ability.

Parameters:
id - the ability id
value - the ability value
Returns:
a list of FreeColGameObjectTypes that provide the required ability.

addModifier

public void addModifier(Modifier modifier)
Add a modifier.

Parameters:
modifier - a Modifier value

getModifiers

public java.util.List<Modifier> getModifiers(java.lang.String id)
Return a list of all Modifiers with the given id.

Parameters:
id - the modifier id

getType

public <T extends FreeColGameObjectType> T getType(java.lang.String Id,
                                                   java.lang.Class<T> type)
                                        throws java.lang.IllegalArgumentException
Returns the FreeColGameObjectType with the given ID. Throws an IllegalArgumentException if the ID is null. Throws and IllegalArgumentException if no such Type can be retrieved and initialization is complete.

Parameters:
Id - a String value
type - a Class value
Returns:
a FreeColGameObjectType value
Throws:
java.lang.IllegalArgumentException - if an error occurs

getType

public FreeColGameObjectType getType(java.lang.String Id)
                              throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

getTypesWithAbility

public <T extends FreeColGameObjectType> java.util.List<T> getTypesWithAbility(java.lang.Class<T> resultType,
                                                                               java.lang.String... abilities)
Return all types which have any of the given abilities.

Parameters:
abilities - The abilities for the search
Returns:
a List of UnitType

hasOption

public boolean hasOption(java.lang.String Id)
Is option with this ID present? This is helpful when options are optionally(!) present, for example model.option.priceIncrease.artillery exists but model.option.priceIncrease.frigate does not.

Parameters:
Id - a String value
Returns:
True/false on presence of option Id

getOption

public AbstractOption getOption(java.lang.String Id)
                         throws java.lang.IllegalArgumentException
Returns the AbstractOption with the given ID. Throws an IllegalArgumentException if the ID is null or unknown.

Parameters:
Id - a String value
Returns:
an AbstractOption value
Throws:
java.lang.IllegalArgumentException

getOptionGroup

public OptionGroup getOptionGroup(java.lang.String Id)
                           throws java.lang.IllegalArgumentException
Returns the OptionGroup with the given ID. Throws an IllegalArgumentException if the ID is null or unknown.

Parameters:
Id - a String value
Returns:
an OptionGroup value
Throws:
java.lang.IllegalArgumentException

addOptionGroup

public void addOptionGroup(OptionGroup optionGroup)
Adds an OptionGroup to the specification

Parameters:
optionGroup - OptionGroup to add

addAbstractOption

public void addAbstractOption(AbstractOption abstractOption)
Adds an AbstractOption to the specification

Parameters:
abstractOption - AbstractOption to add

getIntegerOption

public IntegerOption getIntegerOption(java.lang.String Id)
Returns the IntegerOption with the given ID. Throws an IllegalArgumentException if the ID is null, or if no such Type can be retrieved.

Parameters:
Id - a String value
Returns:
an IntegerOption value

getRangeOption

public RangeOption getRangeOption(java.lang.String Id)
Returns the RangeOption with the given ID. Throws an IllegalArgumentException if the ID is null, or if no such Type can be retrieved.

Parameters:
Id - a String value
Returns:
an RangeOption value

getBooleanOption

public BooleanOption getBooleanOption(java.lang.String Id)
Returns the BooleanOption with the given ID. Throws an IllegalArgumentException if the ID is null, or if no such Type can be retrieved.

Parameters:
Id - a String value
Returns:
an BooleanOption value

getStringOption

public StringOption getStringOption(java.lang.String Id)
Returns the StringOption with the given ID. Throws an IllegalArgumentException if the ID is null, or if no such Type can be retrieved.

Parameters:
Id - a String value
Returns:
an StringOption value

getBuildingTypeList

public java.util.List<BuildingType> getBuildingTypeList()

numberOfBuildingTypes

public int numberOfBuildingTypes()
Describe numberOfBuildingTypes method here.

Returns:
an int value

getBuildingType

public BuildingType getBuildingType(int buildingTypeIndex)
Describe getBuildingType method here.

Parameters:
buildingTypeIndex - an int value
Returns:
a BuildingType value

getBuildingType

public BuildingType getBuildingType(java.lang.String id)

getGoodsTypeList

public java.util.List<GoodsType> getGoodsTypeList()

numberOfGoodsTypes

public int numberOfGoodsTypes()
Describe numberOfGoodsTypes method here.

Returns:
an int value

numberOfStoredGoodsTypes

public int numberOfStoredGoodsTypes()

getFarmedGoodsTypeList

public java.util.List<GoodsType> getFarmedGoodsTypeList()

getNewWorldGoodsTypeList

public java.util.List<GoodsType> getNewWorldGoodsTypeList()

getLibertyGoodsTypeList

public java.util.List<GoodsType> getLibertyGoodsTypeList()

getImmigrationGoodsTypeList

public java.util.List<GoodsType> getImmigrationGoodsTypeList()

numberOfFarmedGoodsTypes

public int numberOfFarmedGoodsTypes()
Describe numberOfFarmedGoodsTypes method here.

Returns:
an int value

getGoodsType

public GoodsType getGoodsType(java.lang.String id)
Describe getGoodsType method here.

Parameters:
id - a String value
Returns:
a GoodsType value

getGoodsFood

public java.util.List<GoodsType> getGoodsFood()

getResourceTypeList

public java.util.List<ResourceType> getResourceTypeList()

numberOfResourceTypes

public int numberOfResourceTypes()

getResourceType

public ResourceType getResourceType(java.lang.String id)

getTileTypeList

public java.util.List<TileType> getTileTypeList()

numberOfTileTypes

public int numberOfTileTypes()

getTileType

public TileType getTileType(java.lang.String id)

getTileImprovementTypeList

public java.util.List<TileImprovementType> getTileImprovementTypeList()

getTileImprovementType

public TileImprovementType getTileImprovementType(java.lang.String id)

getImprovementActionTypeList

public java.util.List<ImprovementActionType> getImprovementActionTypeList()

getImprovementActionType

public ImprovementActionType getImprovementActionType(java.lang.String id)

getUnitTypeList

public java.util.List<UnitType> getUnitTypeList()

numberOfUnitTypes

public int numberOfUnitTypes()

getUnitType

public UnitType getUnitType(java.lang.String id)

getExpertForProducing

public UnitType getExpertForProducing(GoodsType goodsType)

getUnitTypesWithAbility

public java.util.List<UnitType> getUnitTypesWithAbility(java.lang.String... abilities)
Return the unit types which have any of the given abilities

Parameters:
abilities - The abilities for the search
Returns:
a List of UnitType

getUnitTypesTrainedInEurope

public java.util.List<UnitType> getUnitTypesTrainedInEurope()
Returns the unit types that can be trained in Europe.


getUnitTypesPurchasedInEurope

public java.util.List<UnitType> getUnitTypesPurchasedInEurope()
Returns the unit types that can be purchased in Europe.


getFoundingFathers

public java.util.List<FoundingFather> getFoundingFathers()

numberOfFoundingFathers

public int numberOfFoundingFathers()

getFoundingFather

public FoundingFather getFoundingFather(java.lang.String id)

getNationTypes

public java.util.List<NationType> getNationTypes()

getEuropeanNationTypes

public java.util.List<EuropeanNationType> getEuropeanNationTypes()

getREFNationTypes

public java.util.List<EuropeanNationType> getREFNationTypes()

getIndianNationTypes

public java.util.List<IndianNationType> getIndianNationTypes()

numberOfNationTypes

public int numberOfNationTypes()

getNationType

public NationType getNationType(java.lang.String id)

getNations

public java.util.List<Nation> getNations()

getNation

public Nation getNation(java.lang.String id)

getEuropeanNations

public java.util.List<Nation> getEuropeanNations()

getIndianNations

public java.util.List<Nation> getIndianNations()

getREFNations

public java.util.List<Nation> getREFNations()

getEquipmentTypeList

public java.util.List<EquipmentType> getEquipmentTypeList()

getEquipmentType

public EquipmentType getEquipmentType(java.lang.String id)

getDifficultyLevels

public java.util.List<DifficultyLevel> getDifficultyLevels()

getDifficultyLevel

public DifficultyLevel getDifficultyLevel(java.lang.String id)
Describe getDifficultyLevel method here.

Parameters:
id - a String value
Returns:
a DifficultyLevel value

getDifficultyLevel

public DifficultyLevel getDifficultyLevel(int level)
Describe getDifficultyLevel method here.

Parameters:
level - an int value
Returns:
a DifficultyLevel value

applyDifficultyLevel

public void applyDifficultyLevel(int difficultyLevel)
Applies the difficulty level to the current specification.

Parameters:
difficultyLevel - difficulty level to apply

createSpecification

public static void createSpecification(java.io.InputStream is)
Loads the specification.

Parameters:
is - The stream to load the specification from.

getSpecification

public static Specification getSpecification()

getType

public <T extends FreeColGameObjectType> T getType(javax.xml.stream.XMLStreamReader in,
                                                   java.lang.String attributeName,
                                                   java.lang.Class<T> returnClass,
                                                   T defaultValue)
Returns the FreeColGameObjectType identified by the attributeName, or the default value if there is no such attribute.

Parameters:
in - the XMLStreamReader
attributeName - the name of the attribute identifying the FreeColGameObjectType
returnClass - the class of the return value
defaultValue - the value to return if there is no attribute named attributeName
Returns:
a FreeColGameObjectType value