|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.Specification
public final class Specification
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.
| Constructor Summary | |
|---|---|
protected |
Specification(java.io.InputStream in)
Creates a new Specification object by loading it from the specification.xml. |
| 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)
|
|
|
getType(java.lang.String Id,
java.lang.Class<T> type)
Returns the FreeColGameObjectType with the given
ID. |
|
|
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. |
|
|
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. |
|
private java.lang.String |
mangle(java.lang.String id)
|
|
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 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final FreeColGameObjectType MOVEMENT_PENALTY_SOURCE
public static final FreeColGameObjectType ARTILLERY_PENALTY_SOURCE
public static final FreeColGameObjectType ATTACK_BONUS_SOURCE
public static final FreeColGameObjectType FORTIFICATION_BONUS_SOURCE
public static final FreeColGameObjectType INDIAN_RAID_BONUS_SOURCE
public static final FreeColGameObjectType BASE_OFFENCE_SOURCE
public static final FreeColGameObjectType BASE_DEFENCE_SOURCE
public static final FreeColGameObjectType CARGO_PENALTY_SOURCE
public static final FreeColGameObjectType AMBUSH_BONUS_SOURCE
public static final FreeColGameObjectType IN_SETTLEMENT
public static final FreeColGameObjectType IN_CAPITAL
public static final FreeColGameObjectType COLONY_GOODS_PARTY
protected static Specification specification
private static final java.util.logging.Logger logger
private final java.util.Map<java.lang.String,FreeColGameObjectType> allTypes
private final java.util.Map<java.lang.String,AbstractOption> allOptions
private final java.util.Map<java.lang.String,OptionGroup> allOptionGroups
private final java.util.Map<GoodsType,UnitType> experts
private final java.util.Map<java.lang.String,java.util.List<Ability>> allAbilities
private final java.util.Map<java.lang.String,java.util.List<Modifier>> allModifiers
private final java.util.List<BuildingType> buildingTypeList
private final java.util.List<GoodsType> goodsTypeList
private final java.util.List<GoodsType> farmedGoodsTypeList
private final java.util.List<GoodsType> foodGoodsTypeList
private final java.util.List<GoodsType> newWorldGoodsTypeList
private final java.util.List<GoodsType> libertyGoodsTypeList
private final java.util.List<GoodsType> immigrationGoodsTypeList
private final java.util.List<ResourceType> resourceTypeList
private final java.util.List<TileType> tileTypeList
private final java.util.List<TileImprovementType> tileImprovementTypeList
private final java.util.List<ImprovementActionType> improvementActionTypeList
private final java.util.List<UnitType> unitTypeList
private final java.util.List<UnitType> unitTypesTrainedInEurope
private final java.util.List<UnitType> unitTypesPurchasedInEurope
private final java.util.List<FoundingFather> foundingFathers
private final java.util.List<Nation> nations
private final java.util.List<Nation> europeanNations
private final java.util.List<Nation> REFNations
private final java.util.List<Nation> indianNations
private final java.util.List<NationType> nationTypes
private final java.util.List<EuropeanNationType> europeanNationTypes
private final java.util.List<EuropeanNationType> REFNationTypes
private final java.util.List<IndianNationType> indianNationTypes
private final java.util.List<EquipmentType> equipmentTypes
private final java.util.List<DifficultyLevel> difficultyLevels
private int storableTypes
private boolean initialized
| Constructor Detail |
|---|
protected Specification(java.io.InputStream in)
Goods to the most important
GoodsTypes. If another specification object is created these links would
not work anymore for the previously created specification.
To get hold of an Specification object use the static method
getSpecification() which returns a singleton instance of the
Specification class.
| Method Detail |
|---|
public void addAbility(Ability ability)
ability - an Ability valuepublic void addAbility(java.lang.String id)
id - a String valuepublic java.util.List<Ability> getAbilities(java.lang.String id)
id - the ability id
public java.util.List<FreeColGameObjectType> getTypesProviding(java.lang.String id,
boolean value)
id - the ability idvalue - the ability value
public void addModifier(Modifier modifier)
modifier - a Modifier valuepublic java.util.List<Modifier> getModifiers(java.lang.String id)
id - the modifier id
public <T extends FreeColGameObjectType> T getType(java.lang.String Id,
java.lang.Class<T> type)
throws java.lang.IllegalArgumentException
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.
Id - a String valuetype - a Class value
FreeColGameObjectType value
java.lang.IllegalArgumentException - if an error occursprivate java.lang.String mangle(java.lang.String id)
public FreeColGameObjectType getType(java.lang.String Id)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public <T extends FreeColGameObjectType> java.util.List<T> getTypesWithAbility(java.lang.Class<T> resultType,
java.lang.String... abilities)
abilities - The abilities for the search
List of UnitTypepublic boolean hasOption(java.lang.String Id)
Id - a String value
public AbstractOption getOption(java.lang.String Id)
throws java.lang.IllegalArgumentException
AbstractOption with the given ID. Throws an
IllegalArgumentException if the ID is null or unknown.
Id - a String value
AbstractOption value
java.lang.IllegalArgumentException
public OptionGroup getOptionGroup(java.lang.String Id)
throws java.lang.IllegalArgumentException
OptionGroup with the given ID. Throws an
IllegalArgumentException if the ID is null or unknown.
Id - a String value
OptionGroup value
java.lang.IllegalArgumentExceptionpublic void addOptionGroup(OptionGroup optionGroup)
OptionGroup to the specification
optionGroup - OptionGroup to addpublic void addAbstractOption(AbstractOption abstractOption)
AbstractOption to the specification
abstractOption - AbstractOption to addpublic IntegerOption getIntegerOption(java.lang.String Id)
IntegerOption with the given ID. Throws an
IllegalArgumentException if the ID is null, or if no such Type can be
retrieved.
Id - a String value
IntegerOption valuepublic RangeOption getRangeOption(java.lang.String Id)
RangeOption with the given ID. Throws an
IllegalArgumentException if the ID is null, or if no such Type can be
retrieved.
Id - a String value
RangeOption valuepublic BooleanOption getBooleanOption(java.lang.String Id)
BooleanOption with the given ID. Throws an
IllegalArgumentException if the ID is null, or if no such Type can be
retrieved.
Id - a String value
BooleanOption valuepublic StringOption getStringOption(java.lang.String Id)
StringOption with the given ID. Throws an
IllegalArgumentException if the ID is null, or if no such Type can be
retrieved.
Id - a String value
StringOption valuepublic java.util.List<BuildingType> getBuildingTypeList()
public int numberOfBuildingTypes()
numberOfBuildingTypes method here.
int valuepublic BuildingType getBuildingType(int buildingTypeIndex)
getBuildingType method here.
buildingTypeIndex - an int value
BuildingType valuepublic BuildingType getBuildingType(java.lang.String id)
public java.util.List<GoodsType> getGoodsTypeList()
public int numberOfGoodsTypes()
numberOfGoodsTypes method here.
int valuepublic int numberOfStoredGoodsTypes()
public java.util.List<GoodsType> getFarmedGoodsTypeList()
public java.util.List<GoodsType> getNewWorldGoodsTypeList()
public java.util.List<GoodsType> getLibertyGoodsTypeList()
public java.util.List<GoodsType> getImmigrationGoodsTypeList()
public int numberOfFarmedGoodsTypes()
numberOfFarmedGoodsTypes method here.
int valuepublic GoodsType getGoodsType(java.lang.String id)
getGoodsType method here.
id - a String value
GoodsType valuepublic java.util.List<GoodsType> getGoodsFood()
public java.util.List<ResourceType> getResourceTypeList()
public int numberOfResourceTypes()
public ResourceType getResourceType(java.lang.String id)
public java.util.List<TileType> getTileTypeList()
public int numberOfTileTypes()
public TileType getTileType(java.lang.String id)
public java.util.List<TileImprovementType> getTileImprovementTypeList()
public TileImprovementType getTileImprovementType(java.lang.String id)
public java.util.List<ImprovementActionType> getImprovementActionTypeList()
public ImprovementActionType getImprovementActionType(java.lang.String id)
public java.util.List<UnitType> getUnitTypeList()
public int numberOfUnitTypes()
public UnitType getUnitType(java.lang.String id)
public UnitType getExpertForProducing(GoodsType goodsType)
public java.util.List<UnitType> getUnitTypesWithAbility(java.lang.String... abilities)
abilities - The abilities for the search
List of UnitTypepublic java.util.List<UnitType> getUnitTypesTrainedInEurope()
public java.util.List<UnitType> getUnitTypesPurchasedInEurope()
public java.util.List<FoundingFather> getFoundingFathers()
public int numberOfFoundingFathers()
public FoundingFather getFoundingFather(java.lang.String id)
public java.util.List<NationType> getNationTypes()
public java.util.List<EuropeanNationType> getEuropeanNationTypes()
public java.util.List<EuropeanNationType> getREFNationTypes()
public java.util.List<IndianNationType> getIndianNationTypes()
public int numberOfNationTypes()
public NationType getNationType(java.lang.String id)
public java.util.List<Nation> getNations()
public Nation getNation(java.lang.String id)
public java.util.List<Nation> getEuropeanNations()
public java.util.List<Nation> getIndianNations()
public java.util.List<Nation> getREFNations()
public java.util.List<EquipmentType> getEquipmentTypeList()
public EquipmentType getEquipmentType(java.lang.String id)
public java.util.List<DifficultyLevel> getDifficultyLevels()
public DifficultyLevel getDifficultyLevel(java.lang.String id)
getDifficultyLevel method here.
id - a String value
DifficultyLevel valuepublic DifficultyLevel getDifficultyLevel(int level)
getDifficultyLevel method here.
level - an int value
DifficultyLevel valuepublic void applyDifficultyLevel(int difficultyLevel)
difficultyLevel - difficulty level to applypublic static void createSpecification(java.io.InputStream is)
is - The stream to load the specification from.public static Specification getSpecification()
public <T extends FreeColGameObjectType> T getType(javax.xml.stream.XMLStreamReader in,
java.lang.String attributeName,
java.lang.Class<T> returnClass,
T defaultValue)
in - the XMLStreamReaderattributeName - the name of the attribute identifying the
FreeColGameObjectTypereturnClass - the class of the return valuedefaultValue - the value to return if there is no
attribute named attributeName
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||