Class SubConfiguration

java.lang.Object
org.jpos.core.SubConfiguration
All Implemented Interfaces:
Configuration

public class SubConfiguration extends Object implements Configuration
SubConfiguration objects lets childs objects access attributes in its parent object with a given prefix, for example "child.". Child objects can access properties with their prefix removed.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Configuration
    Parent Configuration
    protected String
    prefix identifying the child parameters
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new empty SubConfiguration object
    Creates a new SubConfiguration from its parent's Configuration and the a given prefix.
  • Method Summary

    Modifier and Type
    Method
    Description
    get(String propertyName)
    Returns the value of a configuration property.
    get(String propertyName, String defaultValue)
    Returns the value of a configuration property, or a default.
    getAll(String propertyName)
    Returns all property values with the given name.
    boolean
    getBoolean(String propertyName)
    Returns the value of a configuration property as a boolean.
    boolean
    getBoolean(String propertyName, boolean defaultValue)
    Returns the value of a configuration property as a boolean, or a default.
    boolean[]
    getBooleans(String propertyName)
    Returns all values of a configuration property as a boolean array.
    double
    getDouble(String propertyName)
    Returns the value of a configuration property as a double.
    double
    getDouble(String propertyName, double defaultValue)
    Returns the value of a configuration property as a double, or a default.
    double[]
    getDoubles(String propertyName)
    Returns all values of a configuration property as a double array.
    int
    getInt(String propertyName)
    Returns the value of a configuration property as an int.
    int
    getInt(String propertyName, int defaultValue)
    Returns the value of a configuration property as an int, or a default.
    int[]
    getInts(String propertyName)
    Returns all values of a configuration property as an int array.
    long
    getLong(String propertyName)
    Returns the value of a configuration property as a long.
    long
    getLong(String propertyName, long defaultValue)
    Returns the value of a configuration property as a long, or a default.
    long[]
    getLongs(String propertyName)
    Returns all values of a configuration property as a long array.
    getObject(String propertyName)
    Creates a new object, it takes the class from the value of the property propertyName
    Returns the set of all property names in this configuration.
    void
    put(String name, Object value)
    Stores a property value.
    void
    Sets the container configuration.
    void
    setPrefix(String newPrefix)
    Sets the prefix that identifies the parameters of the child object inside the parent configuration.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SubConfiguration

      Creates a new empty SubConfiguration object
    • SubConfiguration

      public SubConfiguration(Configuration cfg, String prefix)
      Creates a new SubConfiguration from its parent's Configuration and the a given prefix.
      Parameters:
      cfg - Parent's Configuration
      prefix - prefix identifying child parameters.
  • Method Details

    • setConfiguration

      public void setConfiguration(Configuration newCfg)
      Sets the container configuration.
      Parameters:
      newCfg - New container configuration.
    • setPrefix

      public void setPrefix(String newPrefix)
      Sets the prefix that identifies the parameters of the child object inside the parent configuration.
      Parameters:
      newPrefix - New prefix
    • get

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

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

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

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

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

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

      public String get(String propertyName, String defaultValue)
      Description copied from interface: Configuration
      Returns the value of a configuration property, or a default.
      Specified by:
      get in interface Configuration
      Parameters:
      propertyName - the property name
      defaultValue - value to return if not found
      Returns:
      the property value or defaultValue
    • getBoolean

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

      public boolean getBoolean(String propertyName, boolean defaultValue)
      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:
      propertyName - the property name
      defaultValue - default if not found
      Returns:
      the value as a boolean
    • getDouble

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

      public double getDouble(String propertyName, double defaultValue)
      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:
      propertyName - the property name
      defaultValue - default if not found
      Returns:
      the value as a double
    • getLong

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

      public long getLong(String propertyName, long defaultValue)
      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:
      propertyName - the property name
      defaultValue - default if not found
      Returns:
      the value as a long
    • getInt

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

      public int getInt(String propertyName, int defaultValue)
      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:
      propertyName - the property name
      defaultValue - default if not found
      Returns:
      the value as an int
    • 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[])
    • getObject

      public Object getObject(String propertyName) throws ConfigurationException
      Creates a new object, it takes the class from the value of the property propertyName
      Parameters:
      propertyName - Property whose value is the class name of the object being created.
      Returns:
      the instantiated (and optionally configured) object
      Throws:
      ConfigurationException - if the class cannot be resolved or instantiated
    • 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