Ontimize 5.2072EN

com.ontimize.gui
Class OperationThread

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.ontimize.gui.OperationThread
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
ExtendedOperationThread, UploadFileThread

public class OperationThread
extends java.lang.Thread

Basic Thread implementation that performs an operation and stores the result into an EntityResult class.
The operation must be performed in the Thread.run() method, and the result must be stored in an OperationThread variable called res.
The run method must set the right operation status, such as hasFinished, hasStarted, cancelled , etc. An implementation example could be
public void run() {
hasStarted=true;
// Perform operation. The finish check is done with isAlive() hasFinished=true;
}


Field Summary
protected  boolean cancelled
           
 java.lang.String description
           
protected  boolean hasFinished
           
protected  boolean hasStarted
           
static java.lang.String OPERATION_CANCELLED
           
protected  java.lang.Object res
           
protected  java.lang.String status
           
protected  java.lang.Thread t
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
OperationThread()
          Constructor.
OperationThread(java.lang.String description)
          Sets a description to the thread
 
Method Summary
 void cancel()
          Sets the thread status as canceled.
 java.lang.String getDescription()
          Returns the thread description
 java.lang.Object getResult()
          Returns the thread result.
 java.lang.String getStatus()
          Returns the thread status, which is a message referent to the thread situation.
 boolean hasFinished()
          Checks whether the thread has finished.
 boolean hasStarted()
          Checks whether the thread has started.
 boolean isCancelled()
          Checks whether the thread has been canceled or not
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

res

protected java.lang.Object res

cancelled

protected boolean cancelled

t

protected java.lang.Thread t

hasFinished

protected boolean hasFinished

hasStarted

protected boolean hasStarted

status

protected java.lang.String status

OPERATION_CANCELLED

public static java.lang.String OPERATION_CANCELLED

description

public java.lang.String description
Constructor Detail

OperationThread

public OperationThread()
Constructor.


OperationThread

public OperationThread(java.lang.String description)
Sets a description to the thread

Parameters:
description - the thread description
Method Detail

getDescription

public java.lang.String getDescription()
Returns the thread description

Returns:
the thread description

isCancelled

public boolean isCancelled()
Checks whether the thread has been canceled or not

Returns:
true if the thread was canceled, false otherwise

cancel

public void cancel()
Sets the thread status as canceled. If stopping safely the thread can be done, it must be done in this method. The EntityResult configured for this thread is set as a new EntityResult with operation wrong and the message OPERATION_CANCELLED.


hasFinished

public boolean hasFinished()
Checks whether the thread has finished.

Returns:
true if the thread is finished, false if the thread is still running

hasStarted

public boolean hasStarted()
Checks whether the thread has started.

Returns:
rue if the thread has started, false otherwise

getResult

public java.lang.Object getResult()
Returns the thread result. The result by default is stored in a EntityResult object.

Returns:
the thread result

getStatus

public java.lang.String getStatus()
Returns the thread status, which is a message referent to the thread situation.

Returns:

Ontimize