Package fr.gouv.vitam.common
Class SystemPropertyUtil
java.lang.Object
fr.gouv.vitam.common.SystemPropertyUtil
A collection of utility methods to retrieve and parse the values of the Java system properties.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Inspired from http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/ SystemUtils.html -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Remove the key of the Java system property with the specifiedkey
.static boolean
Returnstrue
if and only if the system property with the specifiedkey
exists.static void
debug
(PrintStream out) Print to System.out the content of the propertiesstatic String
Returns the value of the Java system property with the specifiedkey
, while falling back tonull
if the property access fails.static boolean
Returns the value of the Java system property with the specifiedkey
, while falling back to the specified default value if the property access fails.static int
Returns the value of the Java system property with the specifiedkey
, while falling back to the specified default value if the property access fails.static long
Returns the value of the Java system property with the specifiedkey
, 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 specifiedkey
, while falling back to the specified default value if the property access fails.static boolean
Returns the value of the Java system property with the specifiedkey
, while falling back to the specified default value if the property access fails.static int
Returns the value of the Java system property with the specifiedkey
, while falling back to the specified default value if the property access fails.static long
Returns the value of the Java system property with the specifiedkey
, 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 specifiedkey
, while falling back to the specified default value if the property access fails.static String
getNoCheck
(String key) Returns the value of the Java system property with the specifiedkey
, while falling back tonull
if the property access fails.static SystemPropertyUtil.Platform
getOS()
static boolean
isMac()
static boolean
static boolean
isUnix()
static boolean
static void
refresh()
Re-retrieves all system properties so that any post-launch properties updates are retrieved.static boolean
Set the value of the Java system property with the specifiedkey
to the specified default value.static int
Set the value of the Java system property with the specifiedkey
to the specified default value.static long
Set the value of the Java system property with the specifiedkey
to the specified default value.static String
Set the value of the Java system property with the specifiedkey
to the specified default value.
-
Field Details
-
FILE_ENCODING
Default File encoding field- See Also:
-
-
Method Details
-
refresh
public static void refresh()Re-retrieves all system properties so that any post-launch properties updates are retrieved. -
contains
Returnstrue
if and only if the system property with the specifiedkey
exists.- Parameters:
key
- as String to verify- Returns:
- True if the key is contained
- Throws:
IllegalArgumentException
- key null
-
get
Returns the value of the Java system property with the specifiedkey
, while falling back tonull
if the property access fails.- Parameters:
key
- of system property to get- Returns:
- the property value or
null
- Throws:
IllegalArgumentException
- key null
-
getNoCheck
Returns the value of the Java system property with the specifiedkey
, while falling back tonull
if the property access fails.- Parameters:
key
- of system property to get- Returns:
- the property value or
null
- Throws:
IllegalArgumentException
- key null
-
get
Returns the value of the Java system property with the specifiedkey
, while falling back to the specified default value if the property access fails.- Parameters:
key
- of system propertydef
- 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
Returns the value of the Java system property with the specifiedkey
, while falling back to the specified default value if the property access fails.- Parameters:
key
- of system propertydef
- 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
Returns the value of the Java system property with the specifiedkey
, while falling back to the specified default value if the property access fails.- Parameters:
key
- the system propertydef
- 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
Returns the value of the Java system property with the specifiedkey
, while falling back to the specified default value if the property access fails.- Parameters:
key
- of system propertydef
- 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
Returns the value of the Java system property with the specifiedkey
, while falling back to the specified default value if the property access fails.- Parameters:
key
- of system propertydef
- 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
Returns the value of the Java system property with the specifiedkey
, while falling back to the specified default value if the property access fails.- Parameters:
key
- of system propertydef
- 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
Returns the value of the Java system property with the specifiedkey
, while falling back to the specified default value if the property access fails.- Parameters:
key
- of system propertydef
- 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
Returns the value of the Java system property with the specifiedkey
, while falling back to the specified default value if the property access fails.- Parameters:
key
- of system propertydef
- 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
Set the value of the Java system property with the specifiedkey
to the specified default value.- Parameters:
key
- of system propertydef
- the default value- Returns:
- the ancient value.
- Throws:
IllegalArgumentException
- key or def null
-
set
Set the value of the Java system property with the specifiedkey
to the specified default value.- Parameters:
key
- of system propertydef
- the default value- Returns:
- the ancient value.
- Throws:
IllegalArgumentException
- key null
-
set
Set the value of the Java system property with the specifiedkey
to the specified default value.- Parameters:
key
- of system propertydef
- the default value- Returns:
- the ancient value.
- Throws:
IllegalArgumentException
- key null
-
set
Set the value of the Java system property with the specifiedkey
to the specified default value.- Parameters:
key
- of system propertydef
- the default value- Returns:
- the ancient value.
- Throws:
IllegalArgumentException
- key null
-
clear
Remove the key of the Java system property with the specifiedkey
.- Parameters:
key
- of system property- Throws:
IllegalArgumentException
- key null
-
debug
Print to System.out the content of the properties- Parameters:
out
- the output stream to be used- Throws:
IllegalArgumentException
- out null
-
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
-