org.eclipse.ease.modules.platform

## Class PlatformModule

- java.lang.Object
- - org.eclipse.ease.modules.platform.PlatformModule

    public class PlatformModule
    extends Object

### Field Summary

Fields
`static String` `MODULE_ID` Module identifier.

### Constructor Summary

Constructors
Constructor and Description
`PlatformModule()`

### Method Summary

All Methods Static Methods Concrete Methods
`static Object` `adapt(Object source, Class<?> target)` Adapt object to target type.
`static void` `executeCommand(String commandId, Map<String,String> parameters)` Execute a command from the command framework.
`static Object` `getService(Class<?> type)` Get a platform service.
`static String` `getSystemProperty(String key)` Get a system property value
`static Object` `readPreferences(String node, String key, Object defaultValue)` Read a preferences value.
`static Future` `runProcess(String name, String[] args)` Run an external process.
`static void` `writePreferences(String node, String key, Object value)` Set a preferences value.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### MODULE_ID

    public static final String MODULE_ID

Module identifier.

See Also:
  Constant Field Values

### Constructor Detail

#### PlatformModule

    public PlatformModule()

### Method Detail

#### adapt

    public static Object adapt(Object source,
                               Class<?> target)

Adapt object to target type. Try to get an adapter for an object.

Parameters:
  `source` - object to adapt
  `target` - target class to adapt to
Returns:
  adapted object or `null`

#### getService

    public static Object getService(Class<?> type)

Get a platform service.

Parameters:
  `type` - service type
Returns:
  service instance or `null`

#### executeCommand

    public static void executeCommand(String commandId,
                                      @ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null")
                                      Map<String,String> parameters)
                               throws ExecutionException,
                                      NotDefinedException,
                                      NotEnabledException,
                                      NotHandledException

Execute a command from the command framework. As we have no UI available, we do not pass a control to the command. Hence HandlerUtil.getActive... commands will very likely fail.

Parameters:
  `commandId` - full id of the command to execute
  `parameters` - command parameters
Throws:
  `ExecutionException`
  `NotDefinedException`
  `NotEnabledException`
  `NotHandledException`

#### getSystemProperty

    public static String getSystemProperty(String key)

Get a system property value

Parameters:
  `key` - key to query
Returns:
  system property for key

#### runProcess

    public static Future runProcess(String name,
                                    @ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null")
                                    String[] args)

Run an external process. The process is started in the background and a `Future` object is returned. Query the result for finished state, output and error streams of the executed process.

Parameters:
  `name` - program to run (with full path if necessary)
  `args` - program arguments
Returns:
  `Future` object tracking the program

#### readPreferences

    public static Object readPreferences(String node,
                                         String key,
                                         @ScriptParameter(defaultValue="")
                                         Object defaultValue)

Read a preferences value. The defaultValue is optional, but contains type information if used. Provide instances of Boolean, Integer, Double, Float, Long, byte[], or String to get the appropriate return value of same type.

Parameters:
  `node` - node to read from
  `key` - key name to read from
  `defaultValue` - default value to use, if value is not set
Returns:

#### writePreferences

    public static void writePreferences(String node,
                                        String key,
                                        Object value)

Set a preferences value. Valid types for value are: Boolean, Integer, Double, Float, Long, byte[], and String.

Parameters:
  `node` - node to write to
  `key` - key to store to
  `value` - value to store