- java.lang.Object
-
- be.yildizgames.common.client.config.Configuration
-
public final class Configuration extends Object
Configuration data, data are retrieved by parsing the property file. If the file does not contains the required property, a default value is returned.- Author:
- Grégory Van Den Borre
-
-
Field Summary
Fields Modifier and Type Field Description static StringAUTHENTICATION_HOST_KEYProperty key for the authentication host address.static StringAUTHENTICATION_PORT_KEYProperty key for the authentication port number.static StringDEBUG_KEYProperty key to check the debug mode.static StringLANGUAGE_KEYProperty key for language.static StringLOGIN_KEYProperty key for login.static StringPWD_KEYProperty key for password.static StringSAVE_CREDENTIALS_KEYProperty key for save credentials.static StringSERVER_HOST_KEYProperty key for the server host address.static StringSERVER_PORT_KEYProperty key for the server port number.
-
Method Summary
Modifier and Type Method Description StringgetAuthenticationHost()intgetAuthenticationPort()static ConfigurationgetInstance()be.yildizgames.common.util.language.LanguagegetLanguage()StringgetLogin()StringgetPassword()StringgetServerHost()intgetServerPort()booleanisDebug()Flag to check if the application must be run in debug mode, this flag is hard coded.booleanisSaveCredentialsChecked()ConfigurationreadFromProperties(Properties p)Test if the configuration has been loaded from the file and return it.ConfigurationsetAuthenticationHost(String value)ConfigurationsetAuthenticationPort(int value)ConfigurationsetLanguage(be.yildizgames.common.util.language.Language language)Change the language to use.ConfigurationsetLogin(String value)ConfigurationsetPassword(String value)ConfigurationsetSaveCredentialsChecked(boolean checked)ConfigurationsetServerHost(String value)ConfigurationsetServerPort(int value)voidswapSaveCredentialsChecked()Invert the flag to save or not the credentials on the client computer.
-
-
-
Field Detail
-
LANGUAGE_KEY
public static final String LANGUAGE_KEY
Property key for language.- See Also:
- Constant Field Values
-
SAVE_CREDENTIALS_KEY
public static final String SAVE_CREDENTIALS_KEY
Property key for save credentials.- See Also:
- Constant Field Values
-
LOGIN_KEY
public static final String LOGIN_KEY
Property key for login.- See Also:
- Constant Field Values
-
PWD_KEY
public static final String PWD_KEY
Property key for password.- See Also:
- Constant Field Values
-
AUTHENTICATION_HOST_KEY
public static final String AUTHENTICATION_HOST_KEY
Property key for the authentication host address.- See Also:
- Constant Field Values
-
AUTHENTICATION_PORT_KEY
public static final String AUTHENTICATION_PORT_KEY
Property key for the authentication port number.- See Also:
- Constant Field Values
-
SERVER_HOST_KEY
public static final String SERVER_HOST_KEY
Property key for the server host address.- See Also:
- Constant Field Values
-
SERVER_PORT_KEY
public static final String SERVER_PORT_KEY
Property key for the server port number.- See Also:
- Constant Field Values
-
DEBUG_KEY
public static final String DEBUG_KEY
Property key to check the debug mode.- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static Configuration getInstance()
-
readFromProperties
public Configuration readFromProperties(Properties p)
Test if the configuration has been loaded from the file and return it.- Parameters:
p- Properties containing the configuration.- Returns:
- A full copy of the config data to prevent any change in it.
-
getLogin
public String getLogin()
- Returns:
- The login, or "" if the property is not found in this configuration.
-
setLogin
public Configuration setLogin(String value)
- Parameters:
value- The login to set.- Returns:
- This object for chaining.
-
getPassword
public String getPassword()
- Returns:
- The password or "" if tht property is not found in this configuration.
-
setPassword
public Configuration setPassword(String value)
- Parameters:
value- The password to set.- Returns:
- This object for chaining.
-
isSaveCredentialsChecked
public boolean isSaveCredentialsChecked()
- Returns:
trueif credentials have to be persisted on client computer, false otherwise.
-
setSaveCredentialsChecked
public Configuration setSaveCredentialsChecked(boolean checked)
- Parameters:
checked- Flag to persist or not the credentials on client computer.- Returns:
- This object for chaining.
-
swapSaveCredentialsChecked
public void swapSaveCredentialsChecked()
Invert the flag to save or not the credentials on the client computer.
-
getLanguage
public be.yildizgames.common.util.language.Language getLanguage()
- Returns:
- The language used for the game, or English if the value in property file is empty or invalid.
-
setLanguage
public Configuration setLanguage(be.yildizgames.common.util.language.Language language)
Change the language to use.- Parameters:
language- New language.- Returns:
- This object for chaining.
-
isDebug
public boolean isDebug()
Flag to check if the application must be run in debug mode, this flag is hard coded.- Returns:
trueIf the application must be run in debug mode.
-
getAuthenticationHost
public String getAuthenticationHost()
- Returns:
- The Authentication host address or "localhost" if that property is not found in this configuration.
-
setAuthenticationHost
public Configuration setAuthenticationHost(String value)
- Parameters:
value- The authentication host address to set.- Returns:
- This object for chaining.
- Throws:
NullPointerException- If value is null.
-
getAuthenticationPort
public int getAuthenticationPort()
- Returns:
- The Authentication port number or 15023 if that property is not found in this configuration.
-
setAuthenticationPort
public Configuration setAuthenticationPort(int value)
- Parameters:
value- The authentication port number to set.- Returns:
- This object for chaining.
-
getServerHost
public String getServerHost()
- Returns:
- The server host address or "localhost" if that property is not found in this configuration.
-
setServerHost
public Configuration setServerHost(String value)
- Parameters:
value- The server host address to set.- Returns:
- This object for chaining.
- Throws:
NullPointerException- If value is null.
-
getServerPort
public int getServerPort()
- Returns:
- The server port number or 11139 if that property is not found in this configuration.
-
setServerPort
public Configuration setServerPort(int value)
- Parameters:
value- The server port number to set.- Returns:
- This object for chaining.
-
-