Class ConfigurationUtils

java.lang.Object
org.jmxtrans.agent.util.ConfigurationUtils

public class ConfigurationUtils
extends java.lang.Object
Author:
Cyrille Le Clerc
  • Method Summary

    Modifier and Type Method Description
    static boolean getBoolean​(java.util.Map<java.lang.String,​java.lang.String> settings, java.lang.String name, boolean defaultValue)
    Convert value of this setting to a Java boolean (via Boolean.parseBoolean(String)).
    static int getInt​(java.util.Map<java.lang.String,​java.lang.String> settings, java.lang.String name)
    Convert value of this setting to a Java int.
    static int getInt​(java.util.Map<java.lang.String,​java.lang.String> settings, java.lang.String name, int defaultValue)
    Convert value of this setting to a Java int.
    static long getLong​(java.util.Map<java.lang.String,​java.lang.String> settings, java.lang.String name, long defaultValue)
    Convert value of this setting to a Java long.
    static java.lang.String getString​(java.util.Map<java.lang.String,​java.lang.String> settings, java.lang.String name)
    Convert value of this setting to a Java int.
    static java.lang.String getString​(java.util.Map<java.lang.String,​java.lang.String> settings, java.lang.String name, java.lang.String defaultValue)
    Return the value of the given property.

    Methods inherited from class java.lang.Object

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

    • getInt

      public static int getInt​(java.util.Map<java.lang.String,​java.lang.String> settings, java.lang.String name) throws java.lang.IllegalArgumentException
      Convert value of this setting to a Java int. If the setting is not found or is not an int, an exception is thrown.
      Parameters:
      name - name of the setting / property
      Returns:
      int value of the setting / property
      Throws:
      java.lang.IllegalArgumentException - if setting is not found or is not an integer.
    • getInt

      public static int getInt​(java.util.Map<java.lang.String,​java.lang.String> settings, java.lang.String name, int defaultValue) throws java.lang.IllegalArgumentException
      Convert value of this setting to a Java int. If the property is not found, the defaultValue is returned. If the property is not an int, an exception is thrown.
      Parameters:
      name - name of the property
      defaultValue - default value if the property is not defined.
      Returns:
      int value of the property or defaultValue if the property is not defined.
      Throws:
      java.lang.IllegalArgumentException - if setting is not is not an integer.
    • getLong

      public static long getLong​(java.util.Map<java.lang.String,​java.lang.String> settings, java.lang.String name, long defaultValue) throws java.lang.IllegalArgumentException
      Convert value of this setting to a Java long. If the property is not found, the defaultValue is returned. If the property is not a long, an exception is thrown.
      Parameters:
      name - name of the property
      defaultValue - default value if the property is not defined.
      Returns:
      int value of the property or defaultValue if the property is not defined.
      Throws:
      java.lang.IllegalArgumentException - if setting is not is not a long.
    • getBoolean

      public static boolean getBoolean​(java.util.Map<java.lang.String,​java.lang.String> settings, java.lang.String name, boolean defaultValue)
      Convert value of this setting to a Java boolean (via Boolean.parseBoolean(String)). If the property is not found, the defaultValue is returned.
      Parameters:
      name - name of the property
      defaultValue - default value if the property is not defined.
      Returns:
      int value of the property or defaultValue if the property is not defined.
    • getString

      public static java.lang.String getString​(java.util.Map<java.lang.String,​java.lang.String> settings, java.lang.String name) throws java.lang.IllegalArgumentException
      Convert value of this setting to a Java int. If the setting is not found, an exception is thrown.
      Parameters:
      name - name of the property
      Returns:
      value of the property
      Throws:
      java.lang.IllegalArgumentException - if setting is not found.
    • getString

      public static java.lang.String getString​(java.util.Map<java.lang.String,​java.lang.String> settings, java.lang.String name, java.lang.String defaultValue)
      Return the value of the given property. If the property is not found, the defaultValue is returned.
      Parameters:
      name - name of the property
      defaultValue - default value if the property is not defined.
      Returns:
      value of the property or defaultValue if the property is not defined.