Class SimpleConfiguration

java.lang.Object
org.jpos.core.SimpleConfiguration
All Implemented Interfaces:
Serializable, Configuration

public class SimpleConfiguration extends Object implements Configuration, Serializable
A Configuration implementation backed by a Properties object.
Since:
jPOS 1.1
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    Loads a configuration from a Java .properties file.
    Wraps the supplied Properties as a configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    get(String name)
    Returns the value of a configuration property.
    get(String name, String def)
    Returns the value of the configuration property named name, or the default value def.
    getAll(String name)
    Returns all property values with the given name.
    boolean
    Returns the value of a configuration property as a boolean.
    boolean
    getBoolean(String name, boolean def)
    Returns the value of a configuration property as a boolean, or a default.
    boolean[]
    Returns all values of a configuration property as a boolean array.
    double
    Returns the value of a configuration property as a double.
    double
    getDouble(String name, double def)
    Returns the value of a configuration property as a double, or a default.
    double[]
    Returns all values of a configuration property as a double array.
    int
    getInt(String name)
    Returns the value of a configuration property as an int.
    int
    getInt(String name, int def)
    Returns the value of a configuration property as an int, or a default.
    int[]
    Returns all values of a configuration property as an int array.
    long
    Returns the value of a configuration property as a long.
    long
    getLong(String name, long def)
    Returns the value of a configuration property as a long, or a default.
    long[]
    Returns all values of a configuration property as a long array.
    int
     
    Returns the set of all property names in this configuration.
    void
    load(String filename)
    Loads a Java .properties file into this configuration.
    void
    put(String name, Object value)
    Stores a property value.
     

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

  • Method Details

    • get

      public String get(String name, String def)
      Returns the value of the configuration property named name, or the default value def. If the property value has the format ${xxx} then its value is taken from a system property if it exists, or an environment variable. System property takes priority over environment variable. If the format is $sys{...} we read only a system property. if the format is $env{...} only an environment variable is used.
      Specified by:
      get in interface Configuration
      Parameters:
      name - The configuration property key name.
      def - The default value.
      Returns:
      The value stored under name, or def if there's no configuration property under the given name.
    • getAll

      public String[] getAll(String name)
      Description copied from interface: Configuration
      Returns all property values with the given name.
      Specified by:
      getAll in interface Configuration
      Parameters:
      name - the property name
      Returns:
      all matching values, or a zero-length array
    • getInts

      public int[] getInts(String name)
      Description copied from interface: Configuration
      Returns all values of a configuration property as an int array.
      Specified by:
      getInts in interface Configuration
      Parameters:
      name - the property name
      Returns:
      all values as int array
    • getLongs

      public long[] getLongs(String name)
      Description copied from interface: Configuration
      Returns all values of a configuration property as a long array.
      Specified by:
      getLongs in interface Configuration
      Parameters:
      name - the property name
      Returns:
      all values as long array
    • getDoubles

      public double[] getDoubles(String name)
      Description copied from interface: Configuration
      Returns all values of a configuration property as a double array.
      Specified by:
      getDoubles in interface Configuration
      Parameters:
      name - the property name
      Returns:
      all values as double array
    • getBooleans

      public boolean[] getBooleans(String name)
      Description copied from interface: Configuration
      Returns all values of a configuration property as a boolean array.
      Specified by:
      getBooleans in interface Configuration
      Parameters:
      name - the property name
      Returns:
      all values as boolean array
    • get

      public String get(String name)
      Description copied from interface: Configuration
      Returns the value of a configuration property.
      Specified by:
      get in interface Configuration
      Parameters:
      name - the property name
      Returns:
      the property value, or an empty string if not found
    • getInt

      public int getInt(String name)
      Description copied from interface: Configuration
      Returns the value of a configuration property as an int.
      Specified by:
      getInt in interface Configuration
      Parameters:
      name - the property name
      Returns:
      the value as an int, or 0 if not found
    • getInt

      public int getInt(String name, int def)
      Description copied from interface: Configuration
      Returns the value of a configuration property as an int, or a default.
      Specified by:
      getInt in interface Configuration
      Parameters:
      name - the property name
      def - default if not found
      Returns:
      the value as an int
    • getLong

      public long getLong(String name)
      Description copied from interface: Configuration
      Returns the value of a configuration property as a long.
      Specified by:
      getLong in interface Configuration
      Parameters:
      name - the property name
      Returns:
      the value as a long, or 0 if not found
    • getLong

      public long getLong(String name, long def)
      Description copied from interface: Configuration
      Returns the value of a configuration property as a long, or a default.
      Specified by:
      getLong in interface Configuration
      Parameters:
      name - the property name
      def - default if not found
      Returns:
      the value as a long
    • getDouble

      public double getDouble(String name)
      Description copied from interface: Configuration
      Returns the value of a configuration property as a double.
      Specified by:
      getDouble in interface Configuration
      Parameters:
      name - the property name
      Returns:
      the value as a double, or 0.0 if not found
    • getDouble

      public double getDouble(String name, double def)
      Description copied from interface: Configuration
      Returns the value of a configuration property as a double, or a default.
      Specified by:
      getDouble in interface Configuration
      Parameters:
      name - the property name
      def - default if not found
      Returns:
      the value as a double
    • getBoolean

      public boolean getBoolean(String name)
      Description copied from interface: Configuration
      Returns the value of a configuration property as a boolean.
      Specified by:
      getBoolean in interface Configuration
      Parameters:
      name - the property name
      Returns:
      the value as a boolean, or false if not found
    • getBoolean

      public boolean getBoolean(String name, boolean def)
      Description copied from interface: Configuration
      Returns the value of a configuration property as a boolean, or a default.
      Specified by:
      getBoolean in interface Configuration
      Parameters:
      name - the property name
      def - default if not found
      Returns:
      the value as a boolean
    • load

      public void load(String filename) throws IOException
      Loads a Java .properties file into this configuration.
      Parameters:
      filename - path to the properties file
      Throws:
      IOException - if the file cannot be read
    • put

      public void put(String name, Object value)
      Description copied from interface: Configuration
      Stores a property value.
      Specified by:
      put in interface Configuration
      Parameters:
      name - the property name
      value - the value (typically a String or String[])
    • keySet

      public Set<String> keySet()
      Description copied from interface: Configuration
      Returns the set of all property names in this configuration.
      Specified by:
      keySet in interface Configuration
      Returns:
      the property name set
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object