org.openoffice.ide.eclipse.core.model.utils
Class SystemHelper

java.lang.Object
  extended by org.openoffice.ide.eclipse.core.model.utils.SystemHelper

public class SystemHelper
extends java.lang.Object

Helper class for system variables handling.

Author:
cedricbosdo

Field Summary
static java.lang.String PATH_SEPARATOR
           
 
Constructor Summary
SystemHelper()
           
 
Method Summary
static java.lang.String[] addEnv(java.lang.String[] pEnv, java.lang.String pName, java.lang.String pValue, java.lang.String pSeparator)
          Add an environment variable to an array of existing variables.
static java.lang.String[] addPathEnv(java.lang.String[] pEnv, java.lang.String pName, java.lang.String[] pValue)
          Add an environment variable to an array of existing variables.
static java.io.File getFile(org.eclipse.core.resources.IResource pRes)
          Get a normal Java File from an Eclipse IResource.
static java.io.File getFile(IUnoidlProject pPrj)
          Get a normal Java File from an IUnoidlProject.
static java.lang.String[] getSystemEnvironement()
           
static java.lang.Process runTool(java.lang.String pShellCommand, java.lang.String[] pEnv, java.io.File pExecDir)
          Run a shell command with a given environment and an optional execution directory.
static java.lang.Process runToolWithSysEnv(java.lang.String pShellCommand, java.io.File pExecDir)
          Run a shell command with the system environment and an optional execution directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_SEPARATOR

public static final java.lang.String PATH_SEPARATOR
Constructor Detail

SystemHelper

public SystemHelper()
Method Detail

getFile

public static java.io.File getFile(org.eclipse.core.resources.IResource pRes)
Get a normal Java File from an Eclipse IResource.

Parameters:
pRes - the IResource to convert
Returns:
the equivalent File

getFile

public static java.io.File getFile(IUnoidlProject pPrj)
Get a normal Java File from an IUnoidlProject.

Parameters:
pPrj - IUnoidlProject to convert
Returns:
the equivalent File

addPathEnv

public static java.lang.String[] addPathEnv(java.lang.String[] pEnv,
                                            java.lang.String pName,
                                            java.lang.String[] pValue)
Add an environment variable to an array of existing variables.

Parameters:
pEnv - the array of existing environment variables where to add the new variable
pName - the name of the variable to add
pValue - the value of the variable to add
Returns:
the completed array

addEnv

public static java.lang.String[] addEnv(java.lang.String[] pEnv,
                                        java.lang.String pName,
                                        java.lang.String pValue,
                                        java.lang.String pSeparator)
Add an environment variable to an array of existing variables.

Parameters:
pEnv - the array of existing environment variables where to add the new variable
pName - the name of the variable to add
pValue - the value of the variable to add
pSeparator - the separator to use if there is already a variable with the same name. If null, the old variable will be replaced
Returns:
the completed array

getSystemEnvironement

public static java.lang.String[] getSystemEnvironement()
Returns:
the system environement variables

runToolWithSysEnv

public static java.lang.Process runToolWithSysEnv(java.lang.String pShellCommand,
                                                  java.io.File pExecDir)
                                           throws java.io.IOException
Run a shell command with the system environment and an optional execution directory.

Parameters:
pShellCommand - the command to run
pExecDir - the execution directory or null if none
Returns:
the process for the running command
Throws:
java.io.IOException - if anything wrong happens during the command launch

runTool

public static java.lang.Process runTool(java.lang.String pShellCommand,
                                        java.lang.String[] pEnv,
                                        java.io.File pExecDir)
                                 throws java.io.IOException
Run a shell command with a given environment and an optional execution directory.

Parameters:
pShellCommand - the command to run
pEnv - the environment variables
pExecDir - the execution directory or null if none
Returns:
the process for the running command
Throws:
java.io.IOException - if anything wrong happens during the command launch