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 classThis class is used to hold an image while on the clipboard. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertToLocalPath(String urlPath) Replace the separator character '/' with the system-dependent path-separator character.static voidcopyToClipboard(Image image) Copies the given image to the system clipboard.static voidcopyToClipboard(String text) Copies the given text to the system clipboard.static StringCreates a (more) human readable exception message text for the given exception.static voidEmpty all tiles from cache and garbage collectstatic StringGets the application context ID uses as prefix in a number of application configuration settings.static FileGets the current user's application data directory.static FilegetApplicationDataDir(boolean force) Optionally creates and returns the current user's application data directory.static FileGets the application's home directory as set by the system property "${snap.context}.home".static StringGets the application home page URL as set by the system property "${ceres.context}.homepage.url".static StringGets the application name used in logger output and information messages.static Stringstatic PathGets the auxdata directory which stores dems, orbits, rgb profiles, etc.static FileGets the SNAP cache directory .static StringgetClassFileName(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 FileGets the current working directory, or the directory pointed to by '.' if the actual working directory cannot be determined.static FileGets the default SNAP cache directory.static doublestatic StringReturns the version string.static FileGets the current user's home directory, or the directory pointed to by '.' if the user's actual home directory cannot be determined.static StringGets the current user's name, or the string"unknown"if the the user's name cannot be determined.static voidinit3rdPartyLibs(Class<?> cls) Initialize third party libraries of SNAP.static voidInitialize third party libraries of SNAP.static voidstatic voidstatic voidinitJAI(ClassLoader cl) static ModuleMetadataloadModuleMetadata(Class<?> aClass) Tries to load the metadata fromMETA-INF/MANIFEST.MFcontained 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 voidtell 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.cachedirconfiguration 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
nullifewas 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
serviceTypefound.
-
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
serviceTypefound.
-
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.MFcontained 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
nullif aMETA-INF/MANIFEST.MFcould 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
-