com.enterprisedt.net.ftp.async
Class AsyncResult

java.lang.Object
  extended by com.enterprisedt.net.ftp.async.AsyncResult
Direct Known Subclasses:
ChangeDirectoryResult, ConnectResult, CreateDirectoryResult, DeleteDirectoryResult, DeleteMultipleFilesResult, DirectoryListCallbackResult, DirectoryListResult, DirectoryNameListResult, DisconnectResult, ExecuteCommandResult, GetSystemTypeResult, PermissionsResult, RemoteTransferResult, RenameResult

public abstract class AsyncResult
extends java.lang.Object

Base class for all result classes.

Version:
$Revision: 1.21 $
Author:
Bruce Blackshaw

Constructor Summary
AsyncResult()
           
 
Method Summary
 boolean cancelTask()
          Cancel the asynchronous task that this result is for.
 boolean endAsyncCalled()
          Has endAsync() been called?
protected  void endAsyncInternal()
          Internal method that returns when the async method is completed.
 AsyncFileTransferClient getClient()
          Get a reference to the asynchronous client
 com.enterprisedt.net.ftp.async.internal.SecureConnectionContext getLocalContext()
          Get a reference to the local connection context.
 java.lang.Object getTag()
          Get the tag object that has been saved in the result
 com.enterprisedt.net.ftp.async.internal.Task getTask()
           
 java.lang.String getTaskDescription()
          Get a description of the task this result is for
 int getTaskId()
          Get the task id
 java.lang.Throwable getThrowable()
          If endAsync() is not called, the thrown exception (if indeed an exception has been thrown) can be accessed via this method.
 boolean isCompleted()
          Has the asynchronous operation completed? This can be used to poll for completion.
 boolean isSuccessful()
          Was the operation successful, i.e.
 void notifyComplete()
          Notifies waiting threads that the operation is complete
 void setAsIfCompleted()
          Calls everything needed to pretend this is the result of a task that has completed
 void setClient(AsyncFileTransferClient asyncClient)
          Set the async client
protected  void setEndAsyncCalled()
          Set the flag indicating if endAsync() has been called to true.
 void setLocalContext(com.enterprisedt.net.ftp.async.internal.SecureConnectionContext localContext)
          Set the local context
 void setSuccessful(boolean success)
          Set the flag for success (or failure).
 void setTag(java.lang.Object tag)
          Set the tag object
 void setTask(com.enterprisedt.net.ftp.async.internal.Task task)
          Set the task associated with this result
 void setThrowable(java.lang.Throwable throwable)
           
protected  void waitTillComplete()
          Waits until the async operation is completed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncResult

public AsyncResult()
Method Detail

getLocalContext

public com.enterprisedt.net.ftp.async.internal.SecureConnectionContext getLocalContext()
Get a reference to the local connection context. Only valid within the callback, set to null otherwise.

Returns:
reference to local context, or null

setLocalContext

public void setLocalContext(com.enterprisedt.net.ftp.async.internal.SecureConnectionContext localContext)
Set the local context

Parameters:
localContext - local context

getClient

public AsyncFileTransferClient getClient()
Get a reference to the asynchronous client

Returns:

setClient

public void setClient(AsyncFileTransferClient asyncClient)
Set the async client

Parameters:
asyncClient - reference to the client

setTag

public void setTag(java.lang.Object tag)
Set the tag object

Parameters:
tag - tag to save in result

getTag

public java.lang.Object getTag()
Get the tag object that has been saved in the result

Returns:
tag object

getTaskDescription

public java.lang.String getTaskDescription()
Get a description of the task this result is for

Returns:
task description

isSuccessful

public boolean isSuccessful()
Was the operation successful, i.e. did it complete without any exceptions being thrown?

Returns:
true for successful, false otherwise

setSuccessful

public void setSuccessful(boolean success)
Set the flag for success (or failure).

Parameters:
success - true if operation succeeded, false otherwise

setTask

public void setTask(com.enterprisedt.net.ftp.async.internal.Task task)
Set the task associated with this result

Parameters:
task - associated task

getTask

public com.enterprisedt.net.ftp.async.internal.Task getTask()

cancelTask

public boolean cancelTask()
                   throws FTPException
Cancel the asynchronous task that this result is for.

Returns:
Throws:
FTPException

getTaskId

public int getTaskId()
Get the task id

Returns:
-1 if unknown or the task id

getThrowable

public java.lang.Throwable getThrowable()
If endAsync() is not called, the thrown exception (if indeed an exception has been thrown) can be accessed via this method.

Returns:
thrown exception or null if no exception thrown

endAsyncCalled

public boolean endAsyncCalled()
Has endAsync() been called?

Returns:
true if called, false otherwise

setEndAsyncCalled

protected void setEndAsyncCalled()
Set the flag indicating if endAsync() has been called to true.


isCompleted

public boolean isCompleted()
Has the asynchronous operation completed? This can be used to poll for completion.

Returns:
true if the operation has completed, false if not.

setThrowable

public void setThrowable(java.lang.Throwable throwable)

setAsIfCompleted

public void setAsIfCompleted()
Calls everything needed to pretend this is the result of a task that has completed


waitTillComplete

protected void waitTillComplete()
Waits until the async operation is completed.


endAsyncInternal

protected void endAsyncInternal()
                         throws FTPException,
                                java.io.IOException
Internal method that returns when the async method is completed.

Throws:
FTPException
java.io.IOException

notifyComplete

public void notifyComplete()
Notifies waiting threads that the operation is complete



Copyright © 2001-2009 Enterprise Distributed Technologies Ltd. All Rights Reserved.