Class SystemPropertyUtil

java.lang.Object
fr.gouv.vitam.common.SystemPropertyUtil

public final class SystemPropertyUtil extends Object
A collection of utility methods to retrieve and parse the values of the Java system properties.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Inspired from http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/ SystemUtils.html
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Default File encoding field
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Remove the key of the Java system property with the specified key.
    static boolean
    Returns true if and only if the system property with the specified key exists.
    static void
    Print to System.out the content of the properties
    static String
    get(String key)
    Returns the value of the Java system property with the specified key, while falling back to null if the property access fails.
    static boolean
    get(String key, boolean def)
    Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
    static int
    get(String key, int def)
    Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
    static long
    get(String key, long def)
    Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
    static String
    get(String key, String def)
    Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
    static boolean
    getAndSet(String key, boolean def)
    Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
    static int
    getAndSet(String key, int def)
    Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
    static long
    getAndSet(String key, long def)
    Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
    static String
    getAndSet(String key, String def)
    Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
    static String
    Returns the value of the Java system property with the specified key, while falling back to null if the property access fails.
     
    static boolean
     
    static boolean
     
    static boolean
     
    static boolean
     
    static void
    Re-retrieves all system properties so that any post-launch properties updates are retrieved.
    static boolean
    set(String key, boolean def)
    Set the value of the Java system property with the specified key to the specified default value.
    static int
    set(String key, int def)
    Set the value of the Java system property with the specified key to the specified default value.
    static long
    set(String key, long def)
    Set the value of the Java system property with the specified key to the specified default value.
    static String
    set(String key, String def)
    Set the value of the Java system property with the specified key to the specified default value.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • refresh

      public static void refresh()
      Re-retrieves all system properties so that any post-launch properties updates are retrieved.
    • contains

      public static boolean contains(String key)
      Returns true if and only if the system property with the specified key exists.
      Parameters:
      key - as String to verify
      Returns:
      True if the key is contained
      Throws:
      IllegalArgumentException - key null
    • get

      public static String get(String key)
      Returns the value of the Java system property with the specified key, while falling back to null if the property access fails.
      Parameters:
      key - of system property to get
      Returns:
      the property value or null
      Throws:
      IllegalArgumentException - key null
    • getNoCheck

      public static String getNoCheck(String key)
      Returns the value of the Java system property with the specified key, while falling back to null if the property access fails.
      Parameters:
      key - of system property to get
      Returns:
      the property value or null
      Throws:
      IllegalArgumentException - key null
    • get

      public static String get(String key, String def)
      Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
      Parameters:
      key - of system property
      def - the default value
      Returns:
      the property value. def if there's no such property or if an access to the specified property is not allowed.
      Throws:
      IllegalArgumentException - key null
    • get

      public static boolean get(String key, boolean def)
      Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
      Parameters:
      key - of system property
      def - the default value
      Returns:
      the property value. def if there's no such property or if an access to the specified property is not allowed.
      Throws:
      IllegalArgumentException - key null
    • get

      public static int get(String key, int def)
      Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
      Parameters:
      key - the system property
      def - the default value
      Returns:
      the property value. def if there's no such property or if an access to the specified property is not allowed.
      Throws:
      IllegalArgumentException - key null
    • get

      public static long get(String key, long def)
      Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
      Parameters:
      key - of system property
      def - the default value
      Returns:
      the property value. def if there's no such property or if an access to the specified property is not allowed.
      Throws:
      IllegalArgumentException - key null
    • getAndSet

      public static String getAndSet(String key, String def)
      Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
      Parameters:
      key - of system property
      def - the default value
      Returns:
      the property value. def if there's no such property or if an access to the specified property is not allowed.
      Throws:
      IllegalArgumentException - key or def null
    • getAndSet

      public static boolean getAndSet(String key, boolean def)
      Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
      Parameters:
      key - of system property
      def - the default value
      Returns:
      the property value. def if there's no such property or if an access to the specified property is not allowed.
      Throws:
      IllegalArgumentException - key null
    • getAndSet

      public static int getAndSet(String key, int def)
      Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
      Parameters:
      key - of system property
      def - the default value
      Returns:
      the property value. def if there's no such property or if an access to the specified property is not allowed.
      Throws:
      IllegalArgumentException - key null
    • getAndSet

      public static long getAndSet(String key, long def)
      Returns the value of the Java system property with the specified key, while falling back to the specified default value if the property access fails.
      Parameters:
      key - of system property
      def - the default value
      Returns:
      the property value. def if there's no such property or if an access to the specified property is not allowed.
      Throws:
      IllegalArgumentException - key null
    • set

      public static String set(String key, String def)
      Set the value of the Java system property with the specified key to the specified default value.
      Parameters:
      key - of system property
      def - the default value
      Returns:
      the ancient value.
      Throws:
      IllegalArgumentException - key or def null
    • set

      public static boolean set(String key, boolean def)
      Set the value of the Java system property with the specified key to the specified default value.
      Parameters:
      key - of system property
      def - the default value
      Returns:
      the ancient value.
      Throws:
      IllegalArgumentException - key null
    • set

      public static int set(String key, int def)
      Set the value of the Java system property with the specified key to the specified default value.
      Parameters:
      key - of system property
      def - the default value
      Returns:
      the ancient value.
      Throws:
      IllegalArgumentException - key null
    • set

      public static long set(String key, long def)
      Set the value of the Java system property with the specified key to the specified default value.
      Parameters:
      key - of system property
      def - the default value
      Returns:
      the ancient value.
      Throws:
      IllegalArgumentException - key null
    • clear

      public static void clear(String key)
      Remove the key of the Java system property with the specified key.
      Parameters:
      key - of system property
      Throws:
      IllegalArgumentException - key null
    • debug

      public static void debug(PrintStream out)
      Print to System.out the content of the properties
      Parameters:
      out - the output stream to be used
      Throws:
      IllegalArgumentException - out null
    • getOS

      public static SystemPropertyUtil.Platform getOS()
      Returns:
      the Platform
    • isWindows

      public static boolean isWindows()
      Returns:
      True if Windows
    • isMac

      public static boolean isMac()
      Returns:
      True if Mac
    • isUnix

      public static boolean isUnix()
      Returns:
      True if Unix
    • isSolaris

      public static boolean isSolaris()
      Returns:
      True if Solaris