Package com.enterprisedt.net.ftp.async
Class AsyncResult
java.lang.Object
com.enterprisedt.net.ftp.async.AsyncResult
- Direct Known Subclasses:
ChangeDirectoryResult,ConnectResult,CreateDirectoryResult,DeleteDirectoryResult,DeleteMultipleFilesResult,DirectoryListCallbackResult,DirectoryListResult,DirectoryNameListResult,DisconnectResult,ExecuteCommandResult,GetSystemTypeResult,PermissionsResult,RemoteTransferResult,RenameResult
Base class for all result classes.
- Version:
- $Revision$
- Author:
- Bruce Blackshaw
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCancel the asynchronous task that this result is for.booleanHas endAsync() been called?protected voidInternal method that returns when the async method is completed.Get a reference to the asynchronous clientcom.enterprisedt.net.ftp.async.internal.SecureConnectionContextGet a reference to the local connection context.getTag()Get the tag object that has been saved in the resultcom.enterprisedt.net.ftp.async.internal.TaskgetTask()Get a description of the task this result is forintGet the task idIf endAsync() is not called, the thrown exception (if indeed an exception has been thrown) can be accessed via this method.booleanHas the asynchronous operation completed? This can be used to poll for completion.booleanWas the operation successful, i.e.voidNotifies waiting threads that the operation is completevoidCalls everything needed to pretend this is the result of a task that has completedvoidsetClient(AsyncFileTransferClient asyncClient) Set the async clientprotected voidSet the flag indicating if endAsync() has been called to true.voidsetLocalContext(com.enterprisedt.net.ftp.async.internal.SecureConnectionContext localContext) Set the local contextvoidsetSuccessful(boolean success) Set the flag for success (or failure).voidSet the tag objectvoidsetTask(com.enterprisedt.net.ftp.async.internal.Task task) Set the task associated with this resultvoidsetThrowable(Throwable throwable) protected voidWaits until the async operation is completed.
-
Constructor Details
-
AsyncResult
public AsyncResult()
-
-
Method Details
-
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
Get a reference to the asynchronous client- Returns:
-
setClient
Set the async client- Parameters:
asyncClient- reference to the client
-
setTag
Set the tag object- Parameters:
tag- tag to save in result
-
getTag
Get the tag object that has been saved in the result- Returns:
- tag object
-
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
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
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
-
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
Internal method that returns when the async method is completed.- Throws:
FTPExceptionIOException
-
notifyComplete
public void notifyComplete()Notifies waiting threads that the operation is complete
-