rails.util
Class Config

java.lang.Object
  extended by rails.util.Config

public final class Config
extends java.lang.Object

This is a simple utility class with a collection of static functions to load a property object from a property file, to retrieve a particular value from the property file etc.

Version:
2.0
Author:
Ramiah Bala, rewritten by Erik Vos, rewritten by Stefan Frey

Field Summary
protected static org.apache.log4j.Logger log
           
 
Method Summary
static boolean changeActiveProfile(java.lang.String profileName)
          change active Profile
static boolean createUserProfile(java.lang.String profileName, java.lang.String defaultProfile)
          create new profile
static java.lang.String get(java.lang.String key)
           
static java.lang.String get(java.lang.String key, java.lang.String defaultValue)
           
static java.lang.String getActiveFilepath()
          returns filename of active profile, (null if undefined or default profile)
static java.lang.String getActiveProfileName()
          returns name of active profile
static java.util.List<java.lang.String> getAllProfiles()
          get all (visible default + user) profiles
static java.util.Map<java.lang.String,java.util.List<ConfigItem>> getConfigSections()
           
static java.lang.String getDefaultProfileName()
          returns name of (active) default profile
static java.util.List<java.lang.String> getDefaultProfiles(boolean visibleOnly)
          get all default profiles
static java.lang.String getDefaultProfileSelection()
           
static java.lang.String getGameSpecific(java.lang.String key)
          First tries to return {key}.{gameName}, if undefined returns {key}
static int getMaxElementsInPanels()
           
static java.lang.String getSpecific(java.lang.String key, java.lang.String appendix)
          First tries to return {key}.{appendix}, if undefined returns {key}
static java.util.List<java.lang.String> getUserProfiles()
          get all user profiles
static boolean importProfileFromFile(java.io.File file)
          imports an external user profile into an existing profile defined by the filepath
static boolean isDefaultProfile(java.lang.String profileName)
          checks if profile is default profile
static boolean isFilePathDefined()
           
static boolean isLegacyConfigFile()
          returns true if legacy configfile is used
static boolean loadProfileFromFile(java.io.File file)
          loads an external user profile defined by the filepath
static void readConfigSetupXML()
          Reads the config.xml file that defines all config items
static void revertProfile()
          reverts all changes in configitems
static boolean saveActiveProfile()
          save active Profile
static boolean setActiveFilepath(java.lang.String filepath)
          sets filename for an active profile (and store list of profiles)
static void setConfigSelection()
          activates configuration settings based on default settings
static void setConfigTest()
          activates settings used for testing
static void updateProfile(boolean applyInitMethods)
          updates the profile according to the changes in configitems
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Logger log
Method Detail

readConfigSetupXML

public static void readConfigSetupXML()
Reads the config.xml file that defines all config items


getConfigSections

public static java.util.Map<java.lang.String,java.util.List<ConfigItem>> getConfigSections()

getMaxElementsInPanels

public static int getMaxElementsInPanels()

updateProfile

public static void updateProfile(boolean applyInitMethods)
updates the profile according to the changes in configitems


revertProfile

public static void revertProfile()
reverts all changes in configitems


getGameSpecific

public static java.lang.String getGameSpecific(java.lang.String key)
First tries to return {key}.{gameName}, if undefined returns {key}


getSpecific

public static java.lang.String getSpecific(java.lang.String key,
                                           java.lang.String appendix)
First tries to return {key}.{appendix}, if undefined returns {key}


get

public static java.lang.String get(java.lang.String key)

get

public static java.lang.String get(java.lang.String key,
                                   java.lang.String defaultValue)

saveActiveProfile

public static boolean saveActiveProfile()
save active Profile


changeActiveProfile

public static boolean changeActiveProfile(java.lang.String profileName)
change active Profile


createUserProfile

public static boolean createUserProfile(java.lang.String profileName,
                                        java.lang.String defaultProfile)
create new profile


getDefaultProfiles

public static java.util.List<java.lang.String> getDefaultProfiles(boolean visibleOnly)
get all default profiles


getDefaultProfileSelection

public static java.lang.String getDefaultProfileSelection()

getUserProfiles

public static java.util.List<java.lang.String> getUserProfiles()
get all user profiles


getAllProfiles

public static java.util.List<java.lang.String> getAllProfiles()
get all (visible default + user) profiles


isDefaultProfile

public static boolean isDefaultProfile(java.lang.String profileName)
checks if profile is default profile


getDefaultProfileName

public static java.lang.String getDefaultProfileName()
returns name of (active) default profile


getActiveProfileName

public static java.lang.String getActiveProfileName()
returns name of active profile


isLegacyConfigFile

public static boolean isLegacyConfigFile()
returns true if legacy configfile is used


setActiveFilepath

public static boolean setActiveFilepath(java.lang.String filepath)
sets filename for an active profile (and store list of profiles)

Returns:
false if list of profiles cannot be stored

getActiveFilepath

public static java.lang.String getActiveFilepath()
returns filename of active profile, (null if undefined or default profile)


isFilePathDefined

public static boolean isFilePathDefined()
Returns:
if user location is defined

setConfigTest

public static void setConfigTest()
activates settings used for testing


setConfigSelection

public static void setConfigSelection()
activates configuration settings based on default settings


loadProfileFromFile

public static boolean loadProfileFromFile(java.io.File file)
loads an external user profile defined by the filepath


importProfileFromFile

public static boolean importProfileFromFile(java.io.File file)
imports an external user profile into an existing profile defined by the filepath