Package org.esa.snap.core.util
Class SystemUtils
java.lang.Object
org.esa.snap.core.util.SystemUtils
A collection of SNAP-system level functions.
All functions have been implemented with extreme caution in order to provide a maximum performance.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This class is used to hold an image while on the clipboard. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
convertToLocalPath
(String urlPath) Replace the separator character '/' with the system-dependent path-separator character.static void
copyToClipboard
(Image image) Copies the given image to the system clipboard.static void
copyToClipboard
(String text) Copies the given text to the system clipboard.static String
Creates a (more) human readable exception message text for the given exception.static void
Empty all tiles from cache and garbage collectstatic String
Gets the application context ID uses as prefix in a number of application configuration settings.static File
Gets the current user's application data directory.static File
getApplicationDataDir
(boolean force) Optionally creates and returns the current user's application data directory.static File
Gets the application's home directory as set by the system property "${snap.context}.home".static String
Gets the application home page URL as set by the system property "${ceres.context}.homepage.url".static String
Gets the application name used in logger output and information messages.static String
static Path
Gets the auxdata directory which stores dems, orbits, rgb profiles, etc.static File
Gets the SNAP cache directory .static String
getClassFileName
(Class aClass) Retrieves the file name of a class.static File[]
Gets all files (class directory & JAR file pathes) given in the current class path of the Java runtime which loaded this class.static File
Gets the current working directory, or the directory pointed to by '.' if the actual working directory cannot be determined.static File
Gets the default SNAP cache directory.static double
static String
Returns the version string.static File
Gets the current user's home directory, or the directory pointed to by '.' if the user's actual home directory cannot be determined.static String
Gets the current user's name, or the string"unknown"
if the the user's name cannot be determined.static void
init3rdPartyLibs
(Class<?> cls) Initialize third party libraries of SNAP.static void
Initialize third party libraries of SNAP.static void
static void
static void
initJAI
(ClassLoader cl) static ModuleMetadata
loadModuleMetadata
(Class<?> aClass) Tries to load the metadata fromMETA-INF/MANIFEST.MF
contained in the module jar of the specified class.static <S> Iterable
<S> loadServices
(Class<S> serviceType) Loads services from allMETA-INF/services/
resources.static <S> Iterable
<S> loadServices
(Class<S> serviceType, ClassLoader classLoader) Loads services from allMETA-INF/services/
resources.static void
tell tileCache that some old tiles can be removed
-
Field Details
-
SNAP_PARALLELISM_PROPERTY_NAME
-
SNAP_CACHE_DIR_PROPERTY_NAME
-
LOG
The SNAP system logger. Default name is "org.esa.snap" which may be overridden by system property "snap.logger.name". -
LS
-
AUXDATA_DIR_NAME
Name of SNAP's auxdata directory.- See Also:
-
-
Constructor Details
-
SystemUtils
public SystemUtils()
-
-
Method Details
-
getUserName
Gets the current user's name, or the string"unknown"
if the the user's name cannot be determined.- Returns:
- the current user's name, never
null
-
getUserHomeDir
Gets the current user's home directory, or the directory pointed to by '.' if the user's actual home directory cannot be determined.- Returns:
- the current working directory, never
null
-
getApplicationHomepageUrl
Gets the application home page URL as set by the system property "${ceres.context}.homepage.url". Default is "http://sentinel.esa.int".- Returns:
- the application homepage url
- Since:
- BEAM 4.10
-
getApplicationDataDir
Gets the current user's application data directory.- Returns:
- the current user's application data directory
- Since:
- BEAM 4.2
-
getAuxDataPath
Gets the auxdata directory which stores dems, orbits, rgb profiles, etc.- Returns:
- the auxiliary data directory
- Since:
- SNAP 2.0
-
getCacheDir
Gets the SNAP cache directory . This is the directory where SNAP stores cached invalid input: '&' temporary data.The SNAP cache directory can be configured using the
snap.cachedir
configuration property (or Java system property).- Returns:
- the cache directory
- Since:
- SNAP 2
-
getDefaultCacheDir
Gets the default SNAP cache directory.- Returns:
- the default cache directory
- See Also:
-
getApplicationDataDir
Optionally creates and returns the current user's application data directory.- Parameters:
force
- if true, the directory will be created if it didn't exist before- Returns:
- the current user's application data directory
- Since:
- BEAM 4.2
-
getApplicationContextId
Gets the application context ID uses as prefix in a number of application configuration settings. The context ID is configured using the system property "snap.context". If this property is not set, the string "snap" is used.- Returns:
- The application context ID.
- Since:
- BEAM 4.10
-
getApplicationName
Gets the application name used in logger output and information messages. The context ID is configured using the system property "${ceres.context}.application.name". If this property is not set, the string "SNAP" is used.- Returns:
- The application name.
- Since:
- BEAM 4.10
- See Also:
-
getCurrentWorkingDir
Gets the current working directory, or the directory pointed to by '.' if the actual working directory cannot be determined.- Returns:
- the current working directory, never
null
-
getClassPathFiles
Gets all files (class directory & JAR file pathes) given in the current class path of the Java runtime which loaded this class.The files pathes returned are either relative or absolute, just as they where defined for the runtime's class path.
- Returns:
- all files in the current class path, never
null
-
getApplicationHomeDir
Gets the application's home directory as set by the system property "${snap.context}.home".- Returns:
- an assumption of an application's home directory, never
null
-
getClassFileName
Retrieves the file name of a class. For example, the string"Date.class"
is returned for the classjava.util.Date
.- Parameters:
aClass
- The class.- Returns:
- the file name of the given class
- Throws:
IllegalArgumentException
- if the given parameter isnull
.
-
convertToLocalPath
Replace the separator character '/' with the system-dependent path-separator character.- Parameters:
urlPath
- an URL path or any other string containing the forward slash '/' as directory separator.- Returns:
- a path string with all occurrences of '/'
- Throws:
IllegalArgumentException
- if the given parameter isnull
.
-
createHumanReadableExceptionMessage
Creates a (more) human readable exception message text for the given exception. This method should be used when exception messages are to be presented to the user in a GUI.Currently the only modifications are
1. the first letter is turned into upper case
2. the message is suffixed with a dot ('.') character.- Parameters:
e
- the exception- Returns:
- a modified message text, or
null
ife
was null.
-
copyToClipboard
Copies the given text to the system clipboard.- Parameters:
text
- the text to copy
-
copyToClipboard
Copies the given image to the system clipboard.- Parameters:
image
- the image to copy
-
loadServices
Loads services from allMETA-INF/services/
resources.- Parameters:
serviceType
- the type of the service to be loaded.- Returns:
- the services of type
serviceType
found.
-
loadServices
Loads services from allMETA-INF/services/
resources.- Parameters:
serviceType
- the type of the service to be loaded.classLoader
- the class loader.- Returns:
- the services of type
serviceType
found.
-
init3rdPartyLibs
Initialize third party libraries of SNAP.- Parameters:
cls
- The most useful class.- Since:
- BEAM 4.8
-
init3rdPartyLibsByCl
Initialize third party libraries of SNAP.- Parameters:
cl
- The most useful class loader.- Since:
- SNAP 8.0
-
initGeoTools
public static void initGeoTools() -
initJAI
-
initJAI
-
getApplicationRemoteVersionUrl
-
loadModuleMetadata
Tries to load the metadata fromMETA-INF/MANIFEST.MF
contained in the module jar of the specified class.- Parameters:
aClass
- The module jar which contains this specified class will be used to look-up theMETA-INF/MANIFEST.MF
- Returns:
- the module metadata, or
null
if aMETA-INF/MANIFEST.MF
could not be found.
-
getReleaseVersion
Returns the version string. It'S the version uf the last major release.- Returns:
- the version string
-
freeAllMemory
public static void freeAllMemory()Empty all tiles from cache and garbage collect -
getMemoryUsed
public static double getMemoryUsed() -
tileCacheFreeOldTiles
public static void tileCacheFreeOldTiles()tell tileCache that some old tiles can be removed
-