|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.model.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.
| Nested Class Summary | |
|---|---|
private static interface |
Specification.ChildReader
|
private class |
Specification.ModifierReader
|
private class |
Specification.OptionReader
|
private class |
Specification.TypeReader<T extends FreeColGameObjectType>
|
| Constructor Summary | |
|---|---|
Specification()
|
|
Specification(java.io.InputStream in)
Creates a new Specification object by loading it from the given InputStream. |
|
| 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. |
|
private void |
addOptionGroup(OptionGroup optionGroup,
boolean recursive)
Adds an OptionGroup to the specification |
|
void |
applyDifficultyLevel(int difficultyLevel)
Applies the difficulty level identified by the given integer to the current specification. |
|
void |
applyDifficultyLevel(OptionGroup level)
Applies the given difficulty level to the current specification. |
|
void |
applyDifficultyLevel(java.lang.String difficultyLevel)
Applies the difficulty level identified by the given String to the current specification. |
|
void |
clean()
|
|
java.util.List<Ability> |
getAbilities(java.lang.String id)
Return a list of all Abilities with the given id. |
|
boolean |
getBoolean(java.lang.String id)
Gets the boolean value of an option. |
|
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()
|
|
UnitType |
getDefaultUnitType()
Gets the most vanilla unit type. |
|
OptionGroup |
getDifficultyLevel()
Return the current difficulty level. |
|
OptionGroup |
getDifficultyLevel(int level)
Describe getDifficultyLevel method here. |
|
OptionGroup |
getDifficultyLevel(java.lang.String id)
Describe getDifficultyLevel method here. |
|
java.util.List<OptionGroup> |
getDifficultyLevels()
|
|
EquipmentType |
getEquipmentType(java.lang.String id)
|
|
java.util.List<EquipmentType> |
getEquipmentTypeList()
|
|
java.util.List<Nation> |
getEuropeanNations()
|
|
java.util.List<EuropeanNationType> |
getEuropeanNationTypes()
|
|
Event |
getEvent(java.lang.String id)
|
|
java.util.List<Event> |
getEvents()
|
|
UnitType |
getExpertForProducing(GoodsType goodsType)
|
|
java.util.List<GoodsType> |
getFarmedGoodsTypeList()
|
|
java.util.List<GoodsType> |
getFoodGoodsTypeList()
|
|
FoundingFather |
getFoundingFather(java.lang.String id)
|
|
java.util.List<FoundingFather> |
getFoundingFathers()
|
|
GoodsType |
getGoodsType(java.lang.String id)
Describe getGoodsType method here. |
|
java.util.List<GoodsType> |
getGoodsTypeList()
|
|
java.lang.String |
getId()
Describe getId method here. |
|
java.util.List<GoodsType> |
getImmigrationGoodsTypeList()
|
|
java.util.List<Nation> |
getIndianNations()
|
|
java.util.List<IndianNationType> |
getIndianNationTypes()
|
|
int |
getInteger(java.lang.String id)
Gets the integer value of an option. |
|
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. |
|
GoodsType |
getPrimaryFoodType()
The general "Food" type is handled as a special case in many places. |
|
RangeOption |
getRangeOption(java.lang.String Id)
Returns the RangeOption with the given ID. |
|
java.util.List<GoodsType> |
getRawBuildingGoodsTypeList()
|
|
java.util.List<Nation> |
getREFNations()
|
|
java.util.List<EuropeanNationType> |
getREFNationTypes()
|
|
ResourceType |
getResourceType(java.lang.String id)
|
|
java.util.List<ResourceType> |
getResourceTypeList()
|
|
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. |
|
|
getTypesWithoutAbility(java.lang.Class<T> resultType,
java.lang.String... abilities)
Return all types which have none 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 |
|
java.util.List<UnitType> |
getUnitTypesWithoutAbility(java.lang.String... abilities)
Return the unit types which have none of the given abilities |
|
static java.lang.String |
getXMLElementTagName()
|
|
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 void |
load(java.io.InputStream in)
|
|
void |
loadFragment(java.io.InputStream in)
|
|
private java.lang.String |
mangle(java.lang.String id)
|
|
int |
numberOfBuildingTypes()
Describe numberOfBuildingTypes method here. |
|
int |
numberOfFarmedGoodsTypes()
|
|
int |
numberOfFoundingFathers()
|
|
int |
numberOfGoodsTypes()
Describe numberOfGoodsTypes method here. |
|
int |
numberOfNationTypes()
|
|
int |
numberOfResourceTypes()
|
|
int |
numberOfStoredGoodsTypes()
|
|
int |
numberOfTileTypes()
|
|
int |
numberOfUnitTypes()
|
|
void |
readFromXMLImpl(javax.xml.stream.XMLStreamReader xsr)
|
|
protected void |
toXMLImpl(javax.xml.stream.XMLStreamWriter out)
Makes an XML-representation of this object. |
|
private
|
writeSection(javax.xml.stream.XMLStreamWriter out,
java.lang.String section,
java.util.Collection<T> items)
|
|
| 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 AMPHIBIOUS_ATTACK_PENALTY_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 COLONY_GOODS_PARTY_SOURCE
public static final FreeColGameObjectType SHIP_TRADE_PENALTY_SOURCE
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<GoodsType> rawBuildingGoodsTypeList
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<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<Event> events
private final java.util.List<Modifier> specialModifiers
private final java.util.Map<java.lang.String,Specification.ChildReader> readerMap
private int storableTypes
private boolean initialized
private java.lang.String id
private java.lang.String difficultyLevel
| Constructor Detail |
|---|
public Specification(java.io.InputStream in)
InputStream.
in - an InputStream valuepublic Specification()
| Method Detail |
|---|
private void load(java.io.InputStream in)
public void loadFragment(java.io.InputStream in)
public void clean()
public java.lang.String getId()
getId method here.
String valuepublic 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 UnitType
public <T extends FreeColGameObjectType> java.util.List<T> getTypesWithoutAbility(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.IllegalArgumentException
private void addOptionGroup(OptionGroup optionGroup,
boolean recursive)
OptionGroup to the specification
optionGroup - OptionGroup to addrecursive - a boolean valuepublic 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 int getInteger(java.lang.String id)
id - The id of the option.
java.lang.IllegalArgumentException - If there is no integer
value associated with the specified option.
java.lang.NullPointerException - if the given Option does not exist.public boolean getBoolean(java.lang.String id)
id - The id of the option.
java.lang.IllegalArgumentException - If there is no boolean
value associated with the specified option.
java.lang.NullPointerException - if the given Option does not exist.public 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 java.util.List<GoodsType> getFoodGoodsTypeList()
public int numberOfFarmedGoodsTypes()
public final java.util.List<GoodsType> getRawBuildingGoodsTypeList()
public GoodsType getGoodsType(java.lang.String id)
getGoodsType method here.
id - a String value
GoodsType valuepublic GoodsType getPrimaryFoodType()
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<UnitType> getUnitTypeList()
public int numberOfUnitTypes()
public UnitType getUnitType(java.lang.String id)
public UnitType getDefaultUnitType()
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> getUnitTypesWithoutAbility(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<OptionGroup> getDifficultyLevels()
public OptionGroup getDifficultyLevel()
public OptionGroup getDifficultyLevel(java.lang.String id)
getDifficultyLevel method here.
id - a String value
DifficultyLevel valuepublic OptionGroup getDifficultyLevel(int level)
getDifficultyLevel method here.
level - an int value
DifficultyLevel valuepublic void applyDifficultyLevel(int difficultyLevel)
difficultyLevel - index of difficulty level to applypublic void applyDifficultyLevel(java.lang.String difficultyLevel)
difficultyLevel - id of difficulty level to applypublic void applyDifficultyLevel(OptionGroup level)
level - difficulty level to applypublic java.util.List<Event> getEvents()
public Event getEvent(java.lang.String id)
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
protected void toXMLImpl(javax.xml.stream.XMLStreamWriter out)
throws javax.xml.stream.XMLStreamException
out - The output stream.
javax.xml.stream.XMLStreamException - if there are any problems writing to the
stream.
private <T extends FreeColObject> void writeSection(javax.xml.stream.XMLStreamWriter out,
java.lang.String section,
java.util.Collection<T> items)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void readFromXMLImpl(javax.xml.stream.XMLStreamReader xsr)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamExceptionpublic static java.lang.String getXMLElementTagName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||