Class Configuration

java.lang.Object
marauroa.common.Configuration

public class Configuration extends Object
This class is a basic configuration file manager
  • Constructor Details

    • Configuration

      public Configuration(ConfigurationParams params) throws IOException
      Create a new COnfiguration instance using filename etc from the given params parameter.
      Parameters:
      params -
      Throws:
      IOException
  • Method Details

    • setConfigurationFile

      public static void setConfigurationFile(String conf)
      This method defines the default configuration file for all the instances of Configuration
      Parameters:
      conf - the location of the file
    • setConfigurationFile

      public static void setConfigurationFile(boolean relativeToHome, String basedir, String conf)
      This method defines the default configuration file for all the instances of Configuration
      Parameters:
      relativeToHome - should this file be placed below the users home directory?
      basedir - directory prefix which is ignore in webstart environment
      conf - the location of the file
    • setConfigurationPersitance

      public static void setConfigurationPersitance(boolean persistence)
      Should the configuration be read from and write to a file?
      Parameters:
      persistence - true to use files, false otherwise
    • getConfigurationFile

      public static String getConfigurationFile()
      Returns the name of the configuration file
      Returns:
      the name of the configuration file
    • getConfiguration

      public static Configuration getConfiguration() throws IOException
      This method returns an instance of Configuration
      Returns:
      a shared instance of Configuration
      Throws:
      IOException
    • get

      public String get(String property)
      This method returns a String with the value of the property.
      Parameters:
      property - the property we want the value
      Returns:
      a string containing the value of the property
    • get

      public String get(String property, String defaultValue)
      This method returns a String with the value of the property.
      Parameters:
      property - the property we want the value
      defaultValue - a default value in case the property is not defined
      Returns:
      a string containing the value of the property
    • getInt

      public int getInt(String property, int defaultValue)
      This method returns an integer with the value of the property.
      Parameters:
      property - the property we want the value
      defaultValue - a default value in case the property is not defined
      Returns:
      a string containing the value of the property
    • has

      public boolean has(String property)
      This method returns true if the property exists.
      Parameters:
      property -
      Returns:
      true if the property exists
    • set

      public void set(String property, String value)
      This method sets a property with the value we pass as parameter
      Parameters:
      property - the property we want to set the value
      value - the value to set
    • propertyNames

      public Enumeration<?> propertyNames()
      This method returns an enumeration of the properties that the file contains
      Returns:
      enumeration of keys
    • clear

      public void clear()
      Clears the configuration.
    • getAsProperties

      public Properties getAsProperties()
      gets a copy of the configuration as Properties object
      Returns:
      Properties