com.gridsystems.utils
Class SystemUtils

java.lang.Object
  extended by com.gridsystems.utils.SystemUtils

public final class SystemUtils
extends java.lang.Object

General Utilities for several modules.

Version:
1.0
Author:
Xmas

Field Summary
static java.lang.String AIX_POWERPC
          AIX PowerPC.
static java.lang.String HPUX_IA64
          HPUX IA64.
static java.lang.String HPUX_PA
          HPUX PARISC.
static java.lang.String LINUX_AMD64
          Linux AMD64.
static java.lang.String LINUX_I686
          Linux i686.
static java.lang.String LINUX_IA64
          Linux IA64.
static java.lang.String MACOSX_I386
          MacOSX Intel.
static java.lang.String MACOSX_POWERPC
          MacOSX PowerPC.
static java.lang.String SUNOS_I386
          SunOS i386.
static java.lang.String SUNOS_SPARC
          SunOS sparc.
static java.lang.String WINDOWS_IA64
          Windows IA64.
static java.lang.String WINDOWS_X86
          Windows x86.
 
Method Summary
static java.lang.Integer execAndSaveOutput(java.lang.String[] command, java.lang.String[] envp, java.io.File baseDir, java.io.File outputFile)
          Executes the given command and saves its output into a file.
static java.lang.Integer execAndSaveOutput(java.lang.String[] command, java.lang.String[] envp, java.io.File baseDir, java.io.OutputStream output)
          Executes the given command and saves its output into a file.
static java.lang.Integer execAndSaveOutput(java.lang.String command, java.lang.String[] envp, java.io.File baseDir, java.io.File outputFile)
          Executes the given command and saves its output into a file.
static java.lang.Integer execAndSaveOutput(java.lang.String command, java.lang.String[] envp, java.io.File baseDir, java.io.OutputStream output)
          Executes the given command and saves its output into a file.
static java.lang.Integer execPiped(java.lang.String[] command, java.lang.String[] envp, java.io.File baseDir)
          Executes the given command piping its input and output with System.out and System.in.
static java.lang.Integer execPiped(java.lang.String command, java.lang.String[] envp, java.io.File baseDir)
          Executes the given command piping its input and output with System.out and System.in.
static java.io.File extractDynamicLibrary(java.lang.String dynamiclibraryname, java.lang.Class<?> pathclass)
          Deprecated. Use JNIUtils.extractDynamicLibrary method.
static java.io.File extractDynamicLibrary(java.lang.String dynamiclibraryname, java.lang.String path)
          Deprecated. Use JNIUtils.extractDynamicLibrary method.
protected static com.gridsystems.utils.SystemUtils.OsMapEntry getEntry(java.lang.String osName)
          Gets a GridSystems platform for the specified properties.
static java.util.Properties getEnvironment()
          Retrieves the environment variables list from the system.
static java.lang.String getOsName()
          Gets the gridSystems platform name of this machine.
static java.lang.String getOsName(java.lang.String osName, java.lang.String osArch)
          Gets the GridSystems platform name for a machine with the passed properties.
static java.lang.String getOSVersion()
           
static java.lang.String getSimpleArchName()
          Gets the local architecture name.
static java.lang.String getSimpleOsName()
          Gets the local OS name without the CPU architecture.
static java.lang.String getSimpleOsName(java.lang.String osName)
          Extracts the simple OS name from the specified platform id.
static java.lang.String getTempDir()
           
static boolean isUnix()
          Return true if this OS is not windows.
static boolean isWindows()
          Return true if this OS is windows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WINDOWS_X86

public static final java.lang.String WINDOWS_X86
Windows x86.

See Also:
Constant Field Values

WINDOWS_IA64

public static final java.lang.String WINDOWS_IA64
Windows IA64.

See Also:
Constant Field Values

SUNOS_SPARC

public static final java.lang.String SUNOS_SPARC
SunOS sparc.

See Also:
Constant Field Values

SUNOS_I386

public static final java.lang.String SUNOS_I386
SunOS i386.

See Also:
Constant Field Values

LINUX_I686

public static final java.lang.String LINUX_I686
Linux i686.

See Also:
Constant Field Values

LINUX_IA64

public static final java.lang.String LINUX_IA64
Linux IA64.

See Also:
Constant Field Values

LINUX_AMD64

public static final java.lang.String LINUX_AMD64
Linux AMD64.

See Also:
Constant Field Values

HPUX_PA

public static final java.lang.String HPUX_PA
HPUX PARISC.

See Also:
Constant Field Values

HPUX_IA64

public static final java.lang.String HPUX_IA64
HPUX IA64.

See Also:
Constant Field Values

AIX_POWERPC

public static final java.lang.String AIX_POWERPC
AIX PowerPC.

See Also:
Constant Field Values

MACOSX_POWERPC

public static final java.lang.String MACOSX_POWERPC
MacOSX PowerPC.

See Also:
Constant Field Values

MACOSX_I386

public static final java.lang.String MACOSX_I386
MacOSX Intel.

See Also:
Constant Field Values
Method Detail

isWindows

public static boolean isWindows()
Return true if this OS is windows.

Returns:
true if this operating system is Windows

isUnix

public static boolean isUnix()
Return true if this OS is not windows.

Returns:
true if this operating system is not Windows

getOsName

public static java.lang.String getOsName()
Gets the gridSystems platform name of this machine.

Returns:
A "normalized" name for this operating system

getSimpleOsName

public static java.lang.String getSimpleOsName()
Gets the local OS name without the CPU architecture.

Returns:
The OS Name

getSimpleArchName

public static java.lang.String getSimpleArchName()
Gets the local architecture name.

Returns:
The Architecture name

getSimpleOsName

public static java.lang.String getSimpleOsName(java.lang.String osName)
Extracts the simple OS name from the specified platform id.

Parameters:
osName - The platform id
Returns:
The stripped OS name

getOsName

public static java.lang.String getOsName(java.lang.String osName,
                                         java.lang.String osArch)
Gets the GridSystems platform name for a machine with the passed properties.

Parameters:
osName - A value for the "os.name" system property
osArch - A value for the "os.arch" system property
Returns:
A platform name

getEntry

protected static com.gridsystems.utils.SystemUtils.OsMapEntry getEntry(java.lang.String osName)
Gets a GridSystems platform for the specified properties.

Parameters:
osName - A value for the "os.name" system property
Returns:
A platform entry, or null

getOSVersion

public static java.lang.String getOSVersion()
Returns:
Gets OS version.

getEnvironment

public static java.util.Properties getEnvironment()
Retrieves the environment variables list from the system.

Returns:
The environment or an empty instance if an error occurs

extractDynamicLibrary

public static java.io.File extractDynamicLibrary(java.lang.String dynamiclibraryname,
                                                 java.lang.Class<?> pathclass)
                                          throws java.lang.Exception
Deprecated. Use JNIUtils.extractDynamicLibrary method.

Extracts a Dynamic library of a jar file and load into memory.

Parameters:
dynamiclibraryname - the DL name
pathclass - the path class
Returns:
Path to file extracted.
Throws:
java.lang.Exception - if error

extractDynamicLibrary

public static java.io.File extractDynamicLibrary(java.lang.String dynamiclibraryname,
                                                 java.lang.String path)
                                          throws java.lang.Exception
Deprecated. Use JNIUtils.extractDynamicLibrary method.

Extracts a Dynamic library of a jar file and loads it into memory.

Parameters:
dynamiclibraryname - the DL name
path - the path
Returns:
Path to file extracted.
Throws:
java.lang.Exception - if error

getTempDir

public static java.lang.String getTempDir()
Returns:
the temporal system directory

execAndSaveOutput

public static java.lang.Integer execAndSaveOutput(java.lang.String command,
                                                  java.lang.String[] envp,
                                                  java.io.File baseDir,
                                                  java.io.OutputStream output)
Executes the given command and saves its output into a file.

Parameters:
command - the command to execute
envp - the environment
baseDir - the base directory
output - Where store StdOut and StdErr of executable
Returns:
null, if execution has failed, otherwise return Integer with exit code

execAndSaveOutput

public static java.lang.Integer execAndSaveOutput(java.lang.String[] command,
                                                  java.lang.String[] envp,
                                                  java.io.File baseDir,
                                                  java.io.OutputStream output)
Executes the given command and saves its output into a file.

Parameters:
command - the command to execute
envp - the environment
baseDir - the base directory
output - Where store StdOut and StdErr of executable
Returns:
null, if execution has failed, otherwise return Integer with exit code

execPiped

public static java.lang.Integer execPiped(java.lang.String command,
                                          java.lang.String[] envp,
                                          java.io.File baseDir)
Executes the given command piping its input and output with System.out and System.in.

Parameters:
command - the command to execute
envp - the environment
baseDir - the base directory
Returns:
null, if execution has failed, otherwise return Integer with exit code

execAndSaveOutput

public static java.lang.Integer execAndSaveOutput(java.lang.String[] command,
                                                  java.lang.String[] envp,
                                                  java.io.File baseDir,
                                                  java.io.File outputFile)
Executes the given command and saves its output into a file.

Parameters:
command - the command to execute
envp - the environment
baseDir - the base directory
outputFile - the output file
Returns:
null, if execution has failed, otherwise return Integer with exit code

execAndSaveOutput

public static java.lang.Integer execAndSaveOutput(java.lang.String command,
                                                  java.lang.String[] envp,
                                                  java.io.File baseDir,
                                                  java.io.File outputFile)
Executes the given command and saves its output into a file.

Parameters:
command - the command to execute
envp - the environment
baseDir - the base directory
outputFile - the output file
Returns:
null, if execution has failed, otherwise return Integer with exit code

execPiped

public static java.lang.Integer execPiped(java.lang.String[] command,
                                          java.lang.String[] envp,
                                          java.io.File baseDir)
Executes the given command piping its input and output with System.out and System.in.

Parameters:
command - the command to execute
envp - the environment
baseDir - the base directory
Returns:
null, if execution has failed, otherwise return Integer with exit code


Copyright © 2007-2008 Grid Systems, S.A.. All Rights Reserved.