Class Configuration

  • Direct Known Subclasses:
    RunConfiguration

    public class Configuration
    extends Object
    This class define a configuration
    Since:
    3.0
    Author:
    Laurent Jourdren
    • Constructor Detail

      • Configuration

        public Configuration()
        Default constructor.
      • Configuration

        public Configuration​(Configuration conf)
        Constructor.
        Parameters:
        conf - configuration to copy
    • Method Detail

      • containsKey

        public boolean containsKey​(String key)
        Test if configuration contains a key.
        Parameters:
        key - the key to test
        Returns:
        true if the configuration contains the key
      • get

        public String get​(String key)
        Get the value for a configuration key.
        Parameters:
        key - the key. The key must exists
        Returns:
        a String with the value
      • getBoolean

        public boolean getBoolean​(String key)
        Get a boolean configuration key.
        Parameters:
        key - the key The key must exists
        Returns:
        a boolean value
      • getInt

        public int getInt​(String key)
        Get an int configuration key.
        Parameters:
        key - the key The key must exists
        Returns:
        a integer value
      • getLong

        public long getLong​(String key)
        Get a long configuration key.
        Parameters:
        key - the key The key must exists
        Returns:
        a long value
      • getDouble

        public double getDouble​(String key)
        Get a double configuration key.
        Parameters:
        key - the key The key must exists
        Returns:
        a double value
      • getPath

        public Path getPath​(String key)
        Get Path configuration key.
        Parameters:
        key - the key The key must exists
        Returns:
        a Path value
      • get

        public String get​(String key,
                          String defaultValue)
        Get the value for a configuration key.
        Parameters:
        key - the key
        defaultValue - value if the key does not exists
        Returns:
        a String with the value
      • getBoolean

        public boolean getBoolean​(String key,
                                  boolean defaultValue)
        Get a boolean value for a configuration key.
        Parameters:
        key - the key
        defaultValue - value if the key does not exists
        Returns:
        a String with the value
      • getInt

        public int getInt​(String key,
                          int defaultValue)
        Get an integer value for a configuration key.
        Parameters:
        key - the key
        defaultValue - value if the key does not exists
        Returns:
        a integer
      • getLong

        public long getLong​(String key,
                            long defaultValue)
        Get a long value for a configuration key.
        Parameters:
        key - the key
        defaultValue - value if the key does not exists
        Returns:
        a long
      • getDouble

        public double getDouble​(String key,
                                double defaultValue)
        Get a double value for a configuration key.
        Parameters:
        key - the key
        defaultValue - value if the key does not exists
        Returns:
        a double
      • getPath

        public Path getPath​(String key,
                            Path defaultValue)
        Get a Path value for a configuration key.
        Parameters:
        key - the key
        defaultValue - value if the key does not exists
        Returns:
        a Path
      • set

        public void set​(String key,
                        String value)
        Set a value.
        Parameters:
        key - the key
        value - the value
      • setIfNotExists

        public void setIfNotExists​(String key,
                                   String value)
        Set a value if key does not exists.
        Parameters:
        key - the key
        value - the value
      • set

        public void set​(String key,
                        boolean value)
        Set a value.
        Parameters:
        key - the key
        value - the value
      • setIfNotExists

        public void setIfNotExists​(String key,
                                   boolean value)
        Set a value if key does not exists.
        Parameters:
        key - the key
        value - the value
      • set

        public void set​(String key,
                        Number value)
        Set a value.
        Parameters:
        key - the key
        value - the value
      • setIfNotExists

        public void setIfNotExists​(String key,
                                   Number value)
        Set a value if key does not exists.
        Parameters:
        key - the key
        value - the value
      • set

        public void set​(Configuration conf)
        Add all the keys and value of a Configuration object in this one.
        Parameters:
        conf - the configuration to add
      • setFromOtherConf

        public void setFromOtherConf​(Configuration conf,
                                     String key)
        Set a value from the value of another configuration.
        Parameters:
        conf - the configuration where retriving the value
        key - the ley
      • setFromOtherConfIfExists

        public void setFromOtherConfIfExists​(Configuration conf,
                                             String key)
        Set a value from the value of another configuration.
        Parameters:
        conf - the configuration where retriving the value
        key - the ley
      • setFromOtherConf

        public void setFromOtherConf​(Configuration conf,
                                     String key,
                                     String defaultValue)
        Set a value from the value of another configuration.
        Parameters:
        conf - the configuration where retrieving the value
        key - the key
        defaultValue - value if the key does not exists
      • parseAndSet

        public void parseAndSet​(String s)
        Parse a string (e.g. key=value) and set the key and value in the configuration.
        Parameters:
        s - String to parse
      • toMap

        public Map<String,​String> toMap()
        Convert the configuration as a Map.
        Returns:
        a copy of the configuration object in a map
      • size

        public int size()
        Return the size of the configuration.
        Returns:
        the number of elements in the configuration
      • isEmpty

        public boolean isEmpty()
        Test if the configuration is empty.
        Returns:
        true if the configuration is empty
      • load

        public void load​(Path file)
                  throws Aozan3Exception
        Load configuration.
        Parameters:
        file - file to save
        Throws:
        Aozan3Exception - if an error occurs while reading the file
      • load

        public void load​(Path file,
                         boolean aozan2Compatibility)
                  throws Aozan3Exception
        Load configuration.
        Parameters:
        file - file to save
        Throws:
        Aozan3Exception - if an error occurs while reading the file