Class 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 specfield login:String: Value of the login if the user saved it, empty string if not found. specfield password:String: Value of the password if the user saved it, saved in clear to be updated in view if necessary, empty string if not found. specfield language:String: Value of one possible language in the system, if empty of invalid, English is returned. specfield saveCredential: boolean: if true, the password and language will be persisted in the property file.
    • Method Detail

      • 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:
        true if 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:
        true If 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.