org.esa.beam.util
Class SystemUtils

java.lang.Object
  extended by org.esa.beam.util.SystemUtils

public class SystemUtils
extends Object

A collection of (BEAM-) system level functions.

All functions have been implemented with extreme caution in order to provide a maximum performance.

Version:
$Revision$ $Date$
Author:
Norman Fomferra, Sabine Embacher

Nested Class Summary
static class SystemUtils.ImageSelection
          This class is used to hold an image while on the clipboard.
 
Field Summary
static String AUXDATA_DIR_NAME
          Name of BEAM's auxdata directory.
static String BEAM_HOME_PAGE
          Deprecated. since 4.10, use getApplicationHomepageUrl() instead
static String BEAM_HOME_PROPERTY_NAME
          Deprecated. since 4.10, use getApplicationHomePropertyName() instead
static String BEAM_PARALLELISM_PROPERTY_NAME
           
static String BEAM_PLUGIN_PATH_PROPERTY_NAME
          Deprecated. since 4.10, not in use.
static String CACHE_DIR_NAME
           
static String EXTENSION_DIR_NAME
          Name of BEAM's extensions directory.
static String LAX_INSTALL_DIR_PROPERTY_NAME
           
static int LL_DEBUG
           
static int LL_ERROR
           
static int LL_INFO
           
static int LL_WARNING
           
static String LLS_DEBUG
           
static String LLS_ERROR
           
static String LLS_INFO
           
static String LLS_WARNING
           
static String LS
          SYSTEM_DEPENDENT_LINE_SEPARATOR
 
Constructor Summary
SystemUtils()
           
 
Method Summary
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 "${ceres.context}.home".
static File getApplicationHomeDir(URL url)
          Extracts an application's home directory from the given URL.
static String getApplicationHomepageUrl()
          Gets the application home page URL as set by the system property "${ceres.context}.homepage.url".
static String getApplicationHomePropertyName()
           
static String getApplicationName()
          Gets the application name used in logger output and information messages.
static String getApplicationRemoteVersionUrl()
           
static File getBeamHomeDir()
          Deprecated. since BEAM 4.10, use getApplicationHomeDir() instead
static String getBuildNumber()
           
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 getDefaultBeamCacheDir()
          Gets the default BEAM cache directory.
static int getLogLevel(String logLevelStr)
           
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(ClassLoader cl)
          Initialize third party libraries of BEAM.
static boolean isRunningOnMacOS()
           
static Class<?> loadHdf4Lib(Class<?> callerClass)
          Deprecated. since BEAM 4.10 only used by org.esa.beam.dataio.modis.ModisProductReaderPlugIn - moved there as private method
static Class<?> loadHdf5Lib(Class<?> callerClass)
          Deprecated. since BEAM 4.10 only used by org.esa.beam.dataio.hdf5.HDF5ProductWriterPlugin - moved there as private method
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEAM_HOME_PAGE

@Deprecated
public static final String BEAM_HOME_PAGE
Deprecated. since 4.10, use getApplicationHomepageUrl() instead
The URL string to the BEAM home page.


BEAM_HOME_PROPERTY_NAME

@Deprecated
public static final String BEAM_HOME_PROPERTY_NAME
Deprecated. since 4.10, use getApplicationHomePropertyName() instead
The name of the system property that specifies the application home (= installation) directory.


BEAM_PLUGIN_PATH_PROPERTY_NAME

@Deprecated
public static final String BEAM_PLUGIN_PATH_PROPERTY_NAME
Deprecated. since 4.10, not in use.
See Also:
Constant Field Values

BEAM_PARALLELISM_PROPERTY_NAME

public static final String BEAM_PARALLELISM_PROPERTY_NAME
See Also:
Constant Field Values

LAX_INSTALL_DIR_PROPERTY_NAME

public static final String LAX_INSTALL_DIR_PROPERTY_NAME
See Also:
Constant Field Values

LS

public static final String LS
SYSTEM_DEPENDENT_LINE_SEPARATOR


LL_DEBUG

public static final int LL_DEBUG
See Also:
Constant Field Values

LL_INFO

public static final int LL_INFO
See Also:
Constant Field Values

LL_WARNING

public static final int LL_WARNING
See Also:
Constant Field Values

LL_ERROR

public static final int LL_ERROR
See Also:
Constant Field Values

LLS_DEBUG

public static final String LLS_DEBUG
See Also:
Constant Field Values

LLS_INFO

public static final String LLS_INFO
See Also:
Constant Field Values

LLS_WARNING

public static final String LLS_WARNING
See Also:
Constant Field Values

LLS_ERROR

public static final String LLS_ERROR
See Also:
Constant Field Values

EXTENSION_DIR_NAME

public static final String EXTENSION_DIR_NAME
Name of BEAM's extensions directory.

See Also:
Constant Field Values

AUXDATA_DIR_NAME

public static final String AUXDATA_DIR_NAME
Name of BEAM's auxdata directory.

See Also:
Constant Field Values

CACHE_DIR_NAME

public static final String CACHE_DIR_NAME
See Also:
Constant Field Values
Constructor Detail

SystemUtils

public SystemUtils()
Method Detail

getUserName

public static String 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

public 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.

Returns:
the current working directory, never null

getApplicationHomepageUrl

public static String getApplicationHomepageUrl()
Gets the application home page URL as set by the system property "${ceres.context}.homepage.url". Default is "http://www.brockmann-consult.de/beam/".

Returns:
the current user's application data directory
Since:
BEAM 4.10

getApplicationDataDir

public static File getApplicationDataDir()
Gets the current user's application data directory.

Returns:
the current user's application data directory
Since:
BEAM 4.2

getApplicationDataDir

public static File getApplicationDataDir(boolean force)
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

public static String 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 "ceres.context". If this property is not set, the string "beam" is used.

Returns:
The application context ID.
Since:
BEAM 4.10

getApplicationName

public static String 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 "BEAM" is used.

Returns:
The application name.
Since:
BEAM 4.10
See Also:
getApplicationContextId()

getCurrentWorkingDir

public static File 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

public 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.

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

public static File getApplicationHomeDir()
Gets the application's home directory as set by the system property "${ceres.context}.home". If not set, the method determines the home directory by retrieving the URL of this class using the method getApplicationHomeDir(java.net.URL).

Returns:
an assumption of an application's home directory, never null

getApplicationHomePropertyName

public static String getApplicationHomePropertyName()

getApplicationHomeDir

public static File getApplicationHomeDir(URL url)
Extracts an application's home directory from the given URL.

The URL is than scanned for the last occurence of the string "/modules/". If this succeeds the method returns the absolute (parent) path to the directory which contains modules, which is then assumed to be the requested home directory.

Parameters:
url - the URL
Returns:
an assumption of an application's home directory, never null
Throws:
IllegalArgumentException - if the given url is null.

getClassFileName

public static String getClassFileName(Class aClass)
Retrieves the file name of a class. For example, the string "Date.class" is returned for the class java.util.Date.

Parameters:
aClass - The class.
Returns:
the file name of the given class
Throws:
IllegalArgumentException - if the given parameter is null.

getBeamHomeDir

@Deprecated
public static File getBeamHomeDir()
Deprecated. since BEAM 4.10, use getApplicationHomeDir() instead

Gets the BEAM Java home directory. The method evaluates the system property org.esa.beam.home. If it is given, it is returned, otherwise getApplicationHomeDir() is returned.

Returns:
the BEAM home directory

getDefaultBeamCacheDir

public static File getDefaultBeamCacheDir()
Gets the default BEAM cache directory. This is the directory where BEAM stores temporary data.

Returns:
the default cache directory

convertToLocalPath

public static String convertToLocalPath(String urlPath)
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 is null.

createHumanReadableExceptionMessage

public static String createHumanReadableExceptionMessage(Exception e)
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 if e was null.

copyToClipboard

public static void copyToClipboard(String text)
Copies the given text to the system clipboard.

Parameters:
text - the text to copy

copyToClipboard

public static void copyToClipboard(Image image)
Copies the given image to the system clipboard.

Parameters:
image - the image to copy

isRunningOnMacOS

public static boolean isRunningOnMacOS()

loadServices

public static <S> Iterable<S> loadServices(Class<S> serviceType)
Loads services from all META-INF/services/ resources.

Parameters:
serviceType - the type of the service to be loaded.
Returns:
the services of type serviceType found.

loadServices

public static <S> Iterable<S> loadServices(Class<S> serviceType,
                                           ClassLoader classLoader)
Loads services from all META-INF/services/ resources.

Parameters:
serviceType - the type of the service to be loaded.
classLoader - the class loader.
Returns:
the services of type serviceType found.

getBuildNumber

public static String getBuildNumber()

getLogLevel

public static int getLogLevel(String logLevelStr)

loadHdf4Lib

@Deprecated
public static Class<?> loadHdf4Lib(Class<?> callerClass)
Deprecated. since BEAM 4.10 only used by org.esa.beam.dataio.modis.ModisProductReaderPlugIn - moved there as private method


loadHdf5Lib

@Deprecated
public static Class<?> loadHdf5Lib(Class<?> callerClass)
Deprecated. since BEAM 4.10 only used by org.esa.beam.dataio.hdf5.HDF5ProductWriterPlugin - moved there as private method


init3rdPartyLibs

public static void init3rdPartyLibs(ClassLoader cl)
Initialize third party libraries of BEAM.

Parameters:
cl - The most useful class loader.
Since:
BEAM 4.8

getApplicationRemoteVersionUrl

public static String getApplicationRemoteVersionUrl()


Copyright © 2002-2013 Brockmann Consult GmbH. All Rights Reserved.