org.eclipse.ease

## Class Script

- java.lang.Object
- - org.eclipse.ease.Script

    public class Script
    extends Object

Scriptable object. Consists of scriptable data and a result container.

### Constructor Summary

Constructors
Constructor and Description
`Script(Object command)` Constructor.
`Script(String title, Object command)` Constructor.

### Method Summary

Methods
`boolean` `equals(Object obj)`
`String` `getCode()` Get the scriptable data as `String`.
`InputStream` `getCodeStream()` Get the scriptable data as `InputStream`.
`Object` `getCommand()` Returns the command object of this script.
`Object` `getFile()` Returns the file instance, if the current command is backed by a file.
`ScriptResult` `getResult()` Get execution result.
`String` `getTitle()` Get the title of this script.
`int` `hashCode()`
`boolean` `isDynamic()` Check if this script is defined by dynamically generated code.
`void` `setException(Throwable e)` Set an execution exception.
`void` `setResult(Object result)` Set the execution result.
`String` `toString()`

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

`getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### Script

    public Script(String title,
          Object command)

Constructor.

Parameters:
  `title` - name of script object
  `command` - command (sequence) to be executed

#### Script

    public Script(Object command)

Constructor. Using no title for this script

Parameters:
  `command` - command (sequence) to be executed

### Method Detail

#### getCodeStream

    public InputStream getCodeStream()
                              throws Exception

Get the scriptable data as `InputStream`. The caller needs to close the stream when it is not used anymore. Calling this method multiple times will return different streams with the same text content.

Returns:
  scriptable data
Throws:
  `Exception` - when stream cannot be established

#### getCode

    public String getCode()
                   throws Exception

Get the scriptable data as `String`.

Returns:
  scriptable data
Throws:
  `Exception` - when code cannot be read from source

#### getCommand

    public final Object getCommand()

Returns the command object of this script.

Returns:
  command object

#### getResult

    public final ScriptResult getResult()

Get execution result.

Returns:
  execution result.

#### setResult

    public final void setResult(Object result)

Set the execution result.

Parameters:
  `result` - execution result

#### setException

    public final void setException(Throwable e)

Set an execution exception.

Parameters:
  `e` - exception

#### getFile

    public Object getFile()

Returns the file instance, if the current command is backed by a file.

Returns:
  `IFile`, `File` or `null`

#### isDynamic

    public boolean isDynamic()

Check if this script is defined by dynamically generated code. Generated code might be hidden while debugging.

Returns:
  `true` when not a file and not an `URL`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### getTitle

    public String getTitle()

Get the title of this script. Title has to be set by the caller via the constructor. Typically this is used for dynamic code to indicate its purpose.

Returns:
  script title or `null`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### equals

    public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`