Package com.helger.base.system
Class SystemProperties
java.lang.Object
com.helger.base.system.SystemProperties
- All Implemented Interfaces:
IHasConditionalLogger
This class wraps all the Java system properties like version number etc.
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe global Java class version as a double value. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClear the cache with the property names, for which warnings were emitted that keys don't exist.static booleancontainsPropertyName(String sPropertyName) Check if a system property with the given name exists.static @NonNull String[]Get a set of system property names which are relevant for network debugging/proxy handling.static @NonNull NonBlockingPropertiesstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable StringgetPropertyValue(@Nullable String sKey) Get the value of the system property with the given key.static @Nullable StringgetPropertyValueOrNull(@Nullable String sKey) Get the value of the system property with the given key without issuing a warning if the property is not set.static @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic @Nullable Stringstatic booleanstatic @Nullable StringremovePropertyValue(@NonNull String sKey) Remove a system property valuestatic @NonNull EChangesetPropertyValue(@NonNull String sKey, boolean bValue) Set a system property value.static @NonNull EChangesetPropertyValue(@NonNull String sKey, int nValue) Set a system property value .static @NonNull EChangesetPropertyValue(@NonNull String sKey, long nValue) Set a system property valuestatic @NonNull EChangesetPropertyValue(@NonNull String sKey, @Nullable String sValue) Set a system property valuestatic booleansetSilentMode(boolean bSilentMode) Enable or disable certain regular log messages.
-
Field Details
-
JAVA_CLASS_VERSION
public static final double JAVA_CLASS_VERSIONThe global Java class version as a double value.
-
-
Method Details
-
isSilentMode
public static boolean isSilentMode()- Returns:
trueif logging is disabled,falseif it is enabled.
-
setSilentMode
public static boolean setSilentMode(boolean bSilentMode) Enable or disable certain regular log messages.- Parameters:
bSilentMode-trueto disable logging,falseto enable logging- Returns:
- The previous value of the silent mode.
-
getPropertyValueOrNull
Get the value of the system property with the given key without issuing a warning if the property is not set.- Parameters:
sKey- The key of the system property. May benull.- Returns:
nullif the key isnullor if the property is not set.
-
getPropertyValue
Get the value of the system property with the given key. If the property is not set, a warning is logged once per property name.- Parameters:
sKey- The key of the system property. May benull.- Returns:
nullif the key isnullor if the property is not set.
-
clearWarnedPropertyNames
public static void clearWarnedPropertyNames()Clear the cache with the property names, for which warnings were emitted that keys don't exist. -
getAllWarnedPropertyNames
- Returns:
- A copy of the set with all property names for which warnings were emitted.
-
setPropertyValue
Set a system property value.- Parameters:
sKey- The key of the system property. May not benull.bValue- The value of the system property.- Returns:
EChange
-
setPropertyValue
Set a system property value .- Parameters:
sKey- The key of the system property. May not benull.nValue- The value of the system property.- Returns:
EChange- Since:
- 8.5.7
-
setPropertyValue
Set a system property value- Parameters:
sKey- The key of the system property. May not benull.nValue- The value of the system property.- Returns:
EChange- Since:
- 8.5.7
-
setPropertyValue
Set a system property value- Parameters:
sKey- The key of the system property. May not benull.sValue- The value of the system property. If the value isnullthe property is removed.- Returns:
EChange
-
removePropertyValue
Remove a system property value- Parameters:
sKey- The key of the system property to be removed. May not benull.- Returns:
- the previous string value of the system property, or
nullif there was no property with that key.
-
getJavaVersion
- Returns:
- System property value
java.version
-
getJavaVendor
- Returns:
- System property value
java.vendor
-
getJavaVendorURL
- Returns:
- System property value
java.vendor.url
-
getJavaHome
- Returns:
- System property value
java.home
-
getJavaClassVersion
- Returns:
- System property value
java.class.version
-
getJavaClassPath
- Returns:
- System property value
java.class.path
-
getJavaLibraryPath
- Returns:
- System property value
java.library.path
-
getOsName
- Returns:
- System property value
os.name
-
getOsArch
- Returns:
- System property value
os.arch
-
getOsVersion
- Returns:
- System property value
os.version
-
getFileSeparator
- Returns:
- System property value
file.separator
-
getPathSeparator
- Returns:
- System property value
path.separator
-
getLineSeparator
- Returns:
- System property value
line.separator
-
getUserName
- Returns:
- System property value
user.name
-
getUserHome
- Returns:
- System property value
user.home
-
getUserDir
- Returns:
- System property value
user.dir
-
getJavaVmName
- Returns:
- System property value
java.vm.name
-
getJavaVmSpecificationVersion
- Returns:
- System property value
java.vm.specification.version
-
getJavaVmSpecificationVendor
- Returns:
- System property value
java.vm.specification.vendor
-
getJavaVmSpecificationUrl
- Returns:
- System property value
java.vm.specification.url
-
getJavaVmVersion
- Returns:
- System property value
java.vm.version
-
getJavaVmVendor
- Returns:
- System property value
java.vm.vendor
-
getJavaVmUrl
- Returns:
- System property value
java.vm.url
-
getJavaSpecificationVersion
- Returns:
- System property value
java.specification.version
-
getJavaSpecificationVendor
- Returns:
- System property value
java.specification.vendor
-
getJavaSpecificationUrl
- Returns:
- System property value
java.specification.url
-
getTmpDir
@DevelopersNote("This property is not part of the language but part of the Sun SDK") public static @Nullable String getTmpDir()- Returns:
- System property value
java.io.tmpdir
-
getJavaRuntimeVersion
- Returns:
- System property value
java.runtime.version
-
getJavaRuntimeName
- Returns:
- System property value
java.runtime.version
-
getAllProperties
- Returns:
- A map with all system properties where the key is the system property name and the value is the system property value.
-
getAllPropertyNames
- Returns:
- A set with all defined property names. Never
null.
-
containsPropertyName
Check if a system property with the given name exists.- Parameters:
sPropertyName- The name of the property.- Returns:
trueif such a system property is present,falseotherwise
-
getAllJavaNetSystemProperties
Get a set of system property names which are relevant for network debugging/proxy handling. This method is meant to be used for reading the appropriate settings from a configuration file.- Returns:
- An array with all system property names which are relevant for debugging/proxy
handling. Never
nulland never empty. Each call returns a new array.
-