# Module Platform

## Function Overview

adapt | Adapt object to target type. Try to get an adapter for an object.
executeCommand | 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.
getService | Get a platform service.
getSystemProperty | Get a system property value
readPreferences | 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.
runProcess | Run an external process. The process is started in the background and a {@link Future} object is returned. Query the result for finished state, output and error streams of the executed process.
writePreferences | Set a preferences value. Valid types for value are: Boolean, Integer, Double, Float, Long, byte[], and String.

## Functions

### adapt

java.lang.Object adapt(java.lang.Object source, java.lang.Class target)

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

Parameter | Type | Description
--- | --- | ---
source | java.lang.Object | object to adapt
target | java.lang.Class | target class to adapt to

java.lang.Object ... adapted object or `null`

### getService

java.lang.Object getService(java.lang.Class type)

Get a platform service.

Parameter | Type | Description
--- | --- | ---
type | java.lang.Class | service type

java.lang.Object ... service instance or `null`

### executeCommand

void executeCommand(java.lang.String commandId, java.util.Map parameters)

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.

Parameter | Type | Description
--- | --- | ---
commandId | java.lang.String | full id of the command to execute
parameters | java.util.Map | command parameters

### getSystemProperty

java.lang.String getSystemProperty(java.lang.String key)

Get a system property value

Parameter | Type | Description
--- | --- | ---
key | java.lang.String | key to query

java.lang.String ... system property for key

### runProcess

org.eclipse.ease.modules.platform.Future runProcess(java.lang.String name, java.lang.String args)

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

Parameter | Type | Description
--- | --- | ---
name | java.lang.String | program to run (with full path if necessary)
args | java.lang.String | program arguments

org.eclipse.ease.modules.platform.Future ... {@link Future} object tracking the program

### readPreferences

java.lang.Object readPreferences(java.lang.String node, java.lang.String key, java.lang.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.

Parameter | Type | Description
--- | --- | ---
node | java.lang.String | node to read from
key | java.lang.String | key name to read from
defaultValue | java.lang.Object | default value to use, if value is not set

java.lang.Object ...

### writePreferences

void writePreferences(java.lang.String node, java.lang.String key, java.lang.Object value)

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

Parameter | Type | Description
--- | --- | ---
node | java.lang.String | node to write to
key | java.lang.String | key to store to
value | java.lang.Object | value to store