Package name.moore.kevin.ze.game
Class gameConfig
- All Implemented Interfaces:
Serializable,Cloneable,Map<Object,Object>
Read an XML properties configuration file of game settings.
This class provides default values for all properties which can be individually overridden in the XML config.
These properties are transferred into the game application settings in main()
The config file is either in the working directory or on the classpath.
- Author:
- Kevin Moore
<dev@kevin.moore.name> - See Also:
main.start(java.lang.String[]), Serialized Form
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEnum all the allowed settings values in the gameConfig file or provided on the command line and associate defaults. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate FileThe config file that was actually found and loaded.private static org.slf4j.LoggerFields inherited from class java.util.Properties
defaults -
Constructor Summary
ConstructorsConstructorDescriptiongameConfig(List<File> paths)Initialise this Property list's defaults with the the keys and defaults allowed by the keys enum. -
Method Summary
Modifier and TypeMethodDescriptiongetProperty(String p)Override the Properties method to test if the provided string is actually one of the allowed enums.Get the requested value by enum key, will always provide a value.voidParse the requested XML properties file into the fields of this object.Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
searchpaths
-
configFile
The config file that was actually found and loaded.
-
-
Constructor Details
-
gameConfig
Initialise this Property list's defaults with the the keys and defaults allowed by the keys enum.- Parameters:
paths- additional locations to search for the config file - generally initialised to the java classpath
-
-
Method Details
-
parse
Parse the requested XML properties file into the fields of this object.The file is searched for along the paths provided in the constructor. The keys will be lowercase which means future searching needs to be lowercase.
- Parameters:
cf- filename eg zodiac.xml- Throws:
IOException
-
getConfigFile
-
getProperty
Get the requested value by enum key, will always provide a value.- Parameters:
e-- Returns:
-
getProperty
Override the Properties method to test if the provided string is actually one of the allowed enums.This means we cant just create or get arbitrary keys, it has to have been defined in our enum.
- Overrides:
getPropertyin classProperties- Parameters:
p-- Returns:
- See Also:
gameConfig.keys
-