## org.eclipse.datatools.sqltools.result.internal.model
Class ResultInstance

    java.lang.Object
      org.eclipse.datatools.sqltools.result.internal.model.ResultInstance

All Implemented Interfaces:
  java.io.Serializable, IResultInstance

    public class ResultInstance

extends java.lang.Object
implements IResultInstance

A standard implementation of `IResultInstance`

Author:
  Dafan Yang
See Also:
  Serialized Form

Constructor Summary
`ResultInstance(IResultManager resultmanager, OperationCommand command, java.lang.Runnable terminateHandler)`
`ResultInstance(IResultManager resultmanager, OperationCommand command, java.lang.Runnable terminateHandler, IResultInstance parentResult)`

Method Summary
`int` `calculateStatus()` Calculates the status of this result instance based on the status of its sub-results
`void` `createSubResult(OperationCommand cmd, java.lang.Runnable terminateHandler)` Creates a sub results
`void` `dispose()` Disposes resources after the instance terminated.
`long` `getElapsedTime()`
`java.util.Date` `getExecuteDate()` Returns the date-time this result instance was created
`java.lang.String` `getExecuteTime()` Returns the time in string this result instance was created
`java.lang.Throwable[]` `getFailThrowables()` Returns the exceptions thrown when generating the result instance
`java.lang.String` `getFileName()`
`int` `getFrequency()` Returns the execution frequency
`ResultItem` `getItem(int index)` Returns the result item at given index (base on 0)
`int` `getItemCount()` Returns number of result items.
`OperationCommand` `getOperationCommand()` Returns the operation command that produces this result instance.
`java.util.List` `getParameters()` Returns the parameters
`IResultInstance` `getParentResult()` Returns the parent result of this result
`java.util.List` `getResults()`
`int` `getStatus()` Returns the current status.
`java.util.List` `getSubResults()` Returns the sub-results of this result
`boolean` `hasTerminateHandler()` Checks if there is a terminate handler
`void` `increaseFrequency()` Inceases the execution frequency by 1, will only be called when this instance is re-executing
`boolean` `isFinished()` Checks if this result is finished
`boolean` `isMayHaveSubResults()` Return the current flag value which indicates that this IResultInstance object may have sub results.
`boolean` `isParentResult()` Checks if the result instance is a parent result
`void` `morePlainMessage(java.lang.String msg)` Appends a plain message.
`void` `moreResultItem(ResultItem item)` Appends a new result item.
`void` `moreResultSet(IResultSetObject resultset)` Appends a new result set.
`void` `moreResultSet(java.sql.ResultSet resultset)` Appends a new result set.
`void` `moreStatusMessage(java.lang.String msg)` Appends a status message, which will be displayed on 'Status' tab when using multiple tabs display mode
`void` `moreThrowable(java.lang.Throwable th)` Appends an exception
`void` `moreUpdateCount(int updateCount)` Appends a new update count.
`void` `reclaimedTransientThings()` When the detail information of this result instance is not needed, this method should be invoked to wait for reclaiming the detail information.
`void` `resetInstance()` Clears all the result items and parameters
`void` `setElapsedTime(long time)`
`void` `setMayHaveSubResults(boolean mayHaveSubResults)` Set new value to the flag which indicates that this IResultInstance object may have sub results.
`void` `showParameters(java.util.List params)` Shows the given parameters on SQL Results View
`void` `terminate()` Terminates the instance.
`void` `updateStatus(int status)` Updates the status of this result instance

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ResultInstance

    public ResultInstance(IResultManager resultmanager,
                          OperationCommand command,
                          java.lang.Runnable terminateHandler)

### ResultInstance

    public ResultInstance(IResultManager resultmanager,
                          OperationCommand command,
                          java.lang.Runnable terminateHandler,
                          IResultInstance parentResult)

Method Detail

### morePlainMessage

    public void morePlainMessage(java.lang.String msg)

  Description copied from interface: `IResultInstance`
  Appends a plain message. For example, through "print" in the SQL code.

  Specified by:
    `morePlainMessage` in interface `IResultInstance`
  Parameters:
    `msg` - the plain message

### moreStatusMessage

    public void moreStatusMessage(java.lang.String msg)

  Description copied from interface: `IResultInstance`
  Appends a status message, which will be displayed on 'Status' tab when using multiple tabs display mode

  Specified by:
    `moreStatusMessage` in interface `IResultInstance`
  Parameters:
    `msg` - the status message

### moreUpdateCount

    public void moreUpdateCount(int updateCount)

  Description copied from interface: `IResultInstance`
  Appends a new update count.

  Specified by:
    `moreUpdateCount` in interface `IResultInstance`
  Parameters:
    `updateCount` - the update count

### moreResultSet

    public void moreResultSet(java.sql.ResultSet resultset)
                       throws java.sql.SQLException

  Description copied from interface: `IResultInstance`
  Appends a new result set.

  Specified by:
    `moreResultSet` in interface `IResultInstance`
  Parameters:
    `resultset` - instance of JDBC `ResultSet`
  Throws:
    `java.sql.SQLException` - - if a database access error occurs

### moreResultItem

    public void moreResultItem(ResultItem item)

  Description copied from interface: `IResultInstance`
  Appends a new result item.

  Specified by:
    `moreResultItem` in interface `IResultInstance`
  Parameters:
    `item` - the result item

### getOperationCommand

    public OperationCommand getOperationCommand()

  Description copied from interface: `IResultInstance`
  Returns the operation command that produces this result instance.

  Specified by:
    `getOperationCommand` in interface `IResultInstance`
  Returns:
    the operation command

### getStatus

    public int getStatus()

  Description copied from interface: `IResultInstance`
  Returns the current status.

  Specified by:
    `getStatus` in interface `IResultInstance`
  Returns:
    the current status of this result
  See Also:
    `OperationCommand.STATUS_RUNNING`, `OperationCommand.STATUS_SUCCEEDED`, `OperationCommand.STATUS_FAILED`, `OperationCommand.STATUS_TERMINATED`, `OperationCommand.STATUS_STARTED`, `OperationCommand.STATUS_CRITICAL_ERROR`, `OperationCommand.STATUS_WARNING`

### isFinished

    public boolean isFinished()

  Description copied from interface: `IResultInstance`
  Checks if this result is finished

  Specified by:
    `isFinished` in interface `IResultInstance`
  Returns:
    `true` if this instance finishs

### getItem

    public ResultItem getItem(int index)

  Description copied from interface: `IResultInstance`
  Returns the result item at given index (base on 0)

  Specified by:
    `getItem` in interface `IResultInstance`
  Parameters:
    `index` - the index
  Returns:
    the result item

### getItemCount

    public int getItemCount()

  Description copied from interface: `IResultInstance`
  Returns number of result items. Including result sets, messages, update counts.

  Specified by:
    `getItemCount` in interface `IResultInstance`
  Returns:
    result item count

### terminate

    public void terminate()

  Description copied from interface: `IResultInstance`
  Terminates the instance.

  Specified by:
    `terminate` in interface `IResultInstance`

### dispose

    public void dispose()

  Description copied from interface: `IResultInstance`
  Disposes resources after the instance terminated.

  Specified by:
    `dispose` in interface `IResultInstance`

### getExecuteTime

    public java.lang.String getExecuteTime()

  Description copied from interface: `IResultInstance`
  Returns the time in string this result instance was created

  Specified by:
    `getExecuteTime` in interface `IResultInstance`
  Returns:
    the execution time

### getExecuteDate

    public java.util.Date getExecuteDate()

  Description copied from interface: `IResultInstance`
  Returns the date-time this result instance was created

  Specified by:
    `getExecuteDate` in interface `IResultInstance`
  Returns:
    the execution date-time

### updateStatus

    public void updateStatus(int status)

  Description copied from interface: `IResultInstance`
  Updates the status of this result instance

  Specified by:
    `updateStatus` in interface `IResultInstance`
  Parameters:
    `status` - the new status
  See Also:
    `OperationCommand.STATUS_STARTED`, `OperationCommand.STATUS_RUNNING`, `OperationCommand.STATUS_SUCCEEDED`, `OperationCommand.STATUS_FAILED`, `OperationCommand.STATUS_TERMINATED`, `OperationCommand.STATUS_WARNING`, `OperationCommand.STATUS_CRITICAL_ERROR`

### resetInstance

    public void resetInstance()

  Description copied from interface: `IResultInstance`
  Clears all the result items and parameters

  Specified by:
    `resetInstance` in interface `IResultInstance`

### moreResultSet

    public void moreResultSet(IResultSetObject resultset)

  Description copied from interface: `IResultInstance`
  Appends a new result set.

  Specified by:
    `moreResultSet` in interface `IResultInstance`
  Parameters:
    `resultset` - the `IResultSetObject` instance

### showParameters

    public void showParameters(java.util.List params)

  Description copied from interface: `IResultInstance`
  Shows the given parameters on SQL Results View

  Specified by:
    `showParameters` in interface `IResultInstance`
  Parameters:
    `params` - the `Parameter` instances list
  See Also:
    `Parameter`

### hasTerminateHandler

    public boolean hasTerminateHandler()

  Description copied from interface: `IResultInstance`
  Checks if there is a terminate handler

  Specified by:
    `hasTerminateHandler` in interface `IResultInstance`
  Returns:
    `true` if there is a terminate handler

### getParameters

    public java.util.List getParameters()

  Description copied from interface: `IResultInstance`
  Returns the parameters

  Specified by:
    `getParameters` in interface `IResultInstance`
  Returns:
    the `Parameter` instances list

### getFrequency

    public int getFrequency()

  Description copied from interface: `IResultInstance`
  Returns the execution frequency

  Specified by:
    `getFrequency` in interface `IResultInstance`
  Returns:
    the execution frequency

### increaseFrequency

    public void increaseFrequency()

  Description copied from interface: `IResultInstance`
  Inceases the execution frequency by 1, will only be called when this instance is re-executing

  Specified by:
    `increaseFrequency` in interface `IResultInstance`

### getFailThrowables

    public java.lang.Throwable[] getFailThrowables()

  Description copied from interface: `IResultInstance`
  Returns the exceptions thrown when generating the result instance

  Specified by:
    `getFailThrowables` in interface `IResultInstance`
  Returns:
    the exceptions thrown

### moreThrowable

    public void moreThrowable(java.lang.Throwable th)

  Description copied from interface: `IResultInstance`
  Appends an exception

  Specified by:
    `moreThrowable` in interface `IResultInstance`
  Parameters:
    `th` - the exception

### createSubResult

    public void createSubResult(OperationCommand cmd,
                                java.lang.Runnable terminateHandler)

  Description copied from interface: `IResultInstance`
  Creates a sub results

  Specified by:
    `createSubResult` in interface `IResultInstance`
  Parameters:
    `cmd` - the operation request object of the new result
    `terminateHandler` - the terminate handler

### getSubResults

    public java.util.List getSubResults()

  Description copied from interface: `IResultInstance`
  Returns the sub-results of this result

  Specified by:
    `getSubResults` in interface `IResultInstance`
  Returns:
    the sub-results

### getParentResult

    public IResultInstance getParentResult()

  Description copied from interface: `IResultInstance`
  Returns the parent result of this result

  Specified by:
    `getParentResult` in interface `IResultInstance`
  Returns:
    the parent result

### isParentResult

    public boolean isParentResult()

  Description copied from interface: `IResultInstance`
  Checks if the result instance is a parent result

  Specified by:
    `isParentResult` in interface `IResultInstance`
  Returns:
    `true` if it is a parent result, `false` if it is a sub-result

### calculateStatus

    public int calculateStatus()

  Description copied from interface: `IResultInstance`
  Calculates the status of this result instance based on the status of its sub-results

  Specified by:
    `calculateStatus` in interface `IResultInstance`
  Returns:
    the status of this result instance

### isMayHaveSubResults

    public boolean isMayHaveSubResults()

  Description copied from interface: `IResultInstance`
  Return the current flag value which indicates that this IResultInstance object may have sub results.

  Specified by:
    `isMayHaveSubResults` in interface `IResultInstance`
  Returns:
    the current flag value

### setMayHaveSubResults

    public void setMayHaveSubResults(boolean mayHaveSubResults)

  Description copied from interface: `IResultInstance`
  Set new value to the flag which indicates that this IResultInstance object may have sub results.

  Specified by:
    `setMayHaveSubResults` in interface `IResultInstance`
  Parameters:
    `mayHaveSubResults` - the new flag value

### getFileName

    public java.lang.String getFileName()

### getElapsedTime

    public long getElapsedTime()

### setElapsedTime

    public void setElapsedTime(long time)

### getResults

    public java.util.List getResults()

### reclaimedTransientThings

    public void reclaimedTransientThings()

  When the detail information of this result instance is not needed, this method should be invoked to wait for reclaiming the detail information.