Class SystemUtil


  • public class SystemUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      SystemUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean getBooleanSafe​(java.lang.String name)
      Retrieves a Boolean System property, or returns false if: the property isn't found the property name is null or empty if a security manager exists and its checkPropertyAccess method doesn't allow access to the specified system property.
      static java.lang.Integer getIntegerSafe​(java.lang.String name, java.lang.Integer def)
      Retrieves an Integer System property
      static java.lang.String getSystemPropertySafe​(java.lang.String name)
      Retrieves a System property, or null if: the property isn't found the property name is null or empty if a security manager exists and its checkPropertyAccess method doesn't allow access to the specified system property.
      static java.lang.String getSystemPropertySafe​(java.lang.String name, java.lang.String defaultValue)
      Retrieves a System property, or returns some default value if: the property isn't found the property name is null or empty if a security manager exists and its checkPropertyAccess method doesn't allow access to the specified system property.
      static java.lang.String setSystemPropertyFrom​(java.lang.String nameValue)
      Sets a system property from a name=value String.
      static java.lang.String setSystemPropertyFromSafe​(java.lang.String nameValue)
      Sets a system property from a name=value String.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SystemUtil

        public SystemUtil()
    • Method Detail

      • setSystemPropertyFrom

        public static java.lang.String setSystemPropertyFrom​(java.lang.String nameValue)
        Sets a system property from a name=value String. If no '=' is found, the property is assumed to be a Boolean flag with value true.
        Parameters:
        nameValue - the non-null name=value String
        Returns:
        the found name
        Throws:
        java.lang.IllegalArgumentException - if nameValue is null
      • setSystemPropertyFromSafe

        public static java.lang.String setSystemPropertyFromSafe​(java.lang.String nameValue)
        Sets a system property from a name=value String. If no '=' is found, the property is assumed to be a Boolean flag with value true. Does nothing if a Security manager is in place which doesn't allow the operation.
        Parameters:
        nameValue - the non-null name=value String
        Returns:
        the found property name or null if the operation wasn't successful
        Throws:
        java.lang.IllegalArgumentException - if nameValue is null
      • getSystemPropertySafe

        public static java.lang.String getSystemPropertySafe​(java.lang.String name,
                                                             java.lang.String defaultValue)
        Retrieves a System property, or returns some default value if:
        • the property isn't found
        • the property name is null or empty
        • if a security manager exists and its checkPropertyAccess method doesn't allow access to the specified system property.
        Parameters:
        name - the name of the system property.
        defaultValue - a default value.
        Returns:
        value of the system property or the default value
      • getSystemPropertySafe

        public static java.lang.String getSystemPropertySafe​(java.lang.String name)
        Retrieves a System property, or null if:
        • the property isn't found
        • the property name is null or empty
        • if a security manager exists and its checkPropertyAccess method doesn't allow access to the specified system property.
        Parameters:
        name - the name of the system property.
        Returns:
        value of the system property or null
      • getBooleanSafe

        public static boolean getBooleanSafe​(java.lang.String name)
        Retrieves a Boolean System property, or returns false if:
        • the property isn't found
        • the property name is null or empty
        • if a security manager exists and its checkPropertyAccess method doesn't allow access to the specified system property.
        Parameters:
        name - the name of the system property.
        Returns:
        value of the Boolean system property or false
      • getIntegerSafe

        public static java.lang.Integer getIntegerSafe​(java.lang.String name,
                                                       java.lang.Integer def)
        Retrieves an Integer System property
        Parameters:
        name - the name of the system property.
        def - the default value
        Returns:
        value of the Integer system property or false