public class SystemUtils extends Object
All functions have been implemented with extreme caution in order to provide a maximum performance.
Modifier and Type | Class and Description |
---|---|
static class |
SystemUtils.ImageSelection
This class is used to hold an image while on the clipboard.
|
Modifier and Type | Field and Description |
---|---|
static String |
AUXDATA_DIR_NAME
Name of SNAP's auxdata directory.
|
static Logger |
LOG
The SNAP system logger.
|
static String |
LS |
static String |
SNAP_CACHE_DIR_PROPERTY_NAME |
static String |
SNAP_PARALLELISM_PROPERTY_NAME |
Constructor and Description |
---|
SystemUtils() |
Modifier and Type | Method and Description |
---|---|
static 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 |
createHumanReadableExceptionMessage(Exception e)
Creates a (more) human readable exception message text for the given exception.
|
static String |
getApplicationContextId()
Gets the application context ID uses as prefix in a number of application configuration settings.
|
static File |
getApplicationDataDir()
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 |
getApplicationHomeDir()
Gets the application's home directory as set by the system property "${snap.context}.home".
|
static String |
getApplicationHomepageUrl()
Gets the application home page URL as set by the system property "${ceres.context}.homepage.url".
|
static String |
getApplicationName()
Gets the application name used in logger output and information messages.
|
static String |
getApplicationRemoteVersionUrl() |
static Path |
getAuxDataPath()
Gets the auxdata directory which stores dems, orbits, rgb profiles, etc.
|
static File |
getCacheDir()
Gets the SNAP cache directory .
|
static String |
getClassFileName(Class aClass)
Retrieves the file name of a class.
|
static File[] |
getClassPathFiles()
Gets all files (class directory & JAR file pathes) given in the current class path of the Java runtime which
loaded this class.
|
static File |
getCurrentWorkingDir()
Gets the current working directory, or the directory pointed to by '.' if the actual working directory cannot be
determined.
|
static File |
getDefaultCacheDir()
Gets the default SNAP cache directory.
|
static File |
getUserHomeDir()
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 |
getUserName()
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 BEAM.
|
static void |
initGeoTools() |
static void |
initJAI(Class<?> cls) |
static void |
initJAI(ClassLoader cl) |
static ModuleMetadata |
loadModuleMetadata(Class<?> aClass)
Tries to load the metadata from
META-INF/MANIFEST.MF contained in the module jar
of the specified class. |
static <S> Iterable<S> |
loadServices(Class<S> serviceType)
Loads services from all
META-INF/services/ resources. |
static <S> Iterable<S> |
loadServices(Class<S> serviceType,
ClassLoader classLoader)
Loads services from all
META-INF/services/ resources. |
public static final String SNAP_PARALLELISM_PROPERTY_NAME
public static final String SNAP_CACHE_DIR_PROPERTY_NAME
public static final Logger LOG
public static final String LS
public static final String AUXDATA_DIR_NAME
public static String getUserName()
"unknown"
if the the user's name cannot be determined.null
public static File getUserHomeDir()
null
public static String getApplicationHomepageUrl()
public static File getApplicationDataDir()
public static Path getAuxDataPath()
public static File getCacheDir()
The SNAP cache directory can be configured using the snap.cachedir
configuration property
(or Java system property).
public static File getDefaultCacheDir()
getCacheDir()
public static File getApplicationDataDir(boolean force)
force
- if true, the directory will be created if it didn't exist beforepublic static String getApplicationContextId()
public static String getApplicationName()
getApplicationContextId()
public static File getCurrentWorkingDir()
null
public static File[] getClassPathFiles()
The files pathes returned are either relative or absolute, just as they where defined for the runtime's class path.
null
public static File getApplicationHomeDir()
null
public static String getClassFileName(Class aClass)
"Date.class"
is returned for the
class java.util.Date
.aClass
- The class.IllegalArgumentException
- if the given parameter is null
.public static String convertToLocalPath(String urlPath)
urlPath
- an URL path or any other string containing the forward slash '/' as directory separator.IllegalArgumentException
- if the given parameter is null
.public static String createHumanReadableExceptionMessage(Exception e)
Currently the only modifications are
1. the first letter is turned into upper case
2. the message is
suffixed with a dot ('.') character.
e
- the exceptionnull
if e
was null.public static void copyToClipboard(String text)
text
- the text to copypublic static void copyToClipboard(Image image)
image
- the image to copypublic static <S> Iterable<S> loadServices(Class<S> serviceType)
META-INF/services/
resources.serviceType
- the type of the service to be loaded.serviceType
found.public static <S> Iterable<S> loadServices(Class<S> serviceType, ClassLoader classLoader)
META-INF/services/
resources.serviceType
- the type of the service to be loaded.classLoader
- the class loader.serviceType
found.public static void init3rdPartyLibs(Class<?> cls)
cls
- The most useful class loader.public static void initGeoTools()
public static void initJAI(Class<?> cls)
public static void initJAI(ClassLoader cl)
public static String getApplicationRemoteVersionUrl()
public static ModuleMetadata loadModuleMetadata(Class<?> aClass)
META-INF/MANIFEST.MF
contained in the module jar
of the specified class.aClass
- The module jar which contains this specified class will be used to look-up the
META-INF/MANIFEST.MF
null
if a META-INF/MANIFEST.MF
could not be found.Copyright © 2014–2016 European Space Agency (ESA). All rights reserved.