|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.mucommander.job.FileJob
com.mucommander.job.TransferFileJob
public abstract class TransferFileJob
TransferFileJob is a container for a file task : basically an operation that involves files and bytes.
What makes TransferFileJob different from FileJob (and explains its very inspired name) is that a class implementing TransferFileJob has to be able to give progress information about the file currently being processed.
| Field Summary |
|---|
| Fields inherited from class com.mucommander.job.FileJob |
|---|
APPEND_ACTION, APPEND_TEXT, baseSourceFolder, CANCEL_ACTION, CANCEL_TEXT, currentFile, currentFileIndex, currentFilename, files, FINISHED, INTERRUPTED, mainFrame, nbFiles, NOT_STARTED, PAUSED, progressDialog, RETRY_ACTION, RETRY_TEXT, RUNNING, SKIP_ACTION, SKIP_TEXT |
| Constructor Summary | |
|---|---|
TransferFileJob(ProgressDialog progressDialog,
MainFrame mainFrame,
FileSet files)
Creates a new TransferFileJob. |
|
| Method Summary | |
|---|---|
protected void |
closeCurrentInputStream()
Closes the currently registered source InputStream. |
protected void |
copyFile(AbstractFile sourceFile,
AbstractFile destFile,
boolean append)
Copies the given source file to the specified destination file, optionally resuming the operation. |
ByteCounter |
getCurrentFileByteCounter()
Returns the number of bytes that have been processed in the current file. |
long |
getCurrentFileSize()
Returns the size of the file currently being processed, -1 if this information is not available. |
ByteCounter |
getCurrentFileSkippedByteCounter()
Returns the number of bytes that have been skipped in the current file. |
float |
getFilePercentDone()
Returns the percentage of the current file that has been processed, 0 if the current file's size
is not available (in this case getNbCurrentFileBytesProcessed() returns -1). |
java.lang.String |
getStatusString()
This method is overridden to return a custom string "Checking integrity of CURRENT_FILE" when the current file is being checked for integrity. |
long |
getThroughputLimit()
Returns the current transfer throughput limit, in bytes per second. |
ByteCounter |
getTotalByteCounter()
Returns a ByteCounter that holds the total number of bytes that have been processed by this job so far. |
float |
getTotalPercentDone()
Method overridden to return a more accurate percentage of job processed so far by taking into account the current file's percentage of completion. |
ByteCounter |
getTotalSkippedByteCounter()
Returns a ByteCounter that holds the total number of bytes that have been skipped by this job so far. |
protected boolean |
isCheckingIntegrity()
Returns true if the integrity of the current file is being verified. |
boolean |
isIntegrityCheckEnabled()
Returns true if file transfers need to be checked for data integrity. |
protected void |
jobPaused()
Overrides FileJob.jobPaused() to pause any file processing
by having the source InputStream's read methods lock. |
protected void |
jobResumed()
Overrides FileJob.jobResumed() to resume any file processing by releasing
the lock on the source InputStream's read methods. |
protected void |
jobStopped()
Overrides FileJob.jobStopped() to stop any file processing by closing the source InputStream. |
protected void |
nextFile(AbstractFile file)
Advances file index and resets current file's byte counters. |
protected java.io.InputStream |
setCurrentInputStream(java.io.InputStream in)
Registers the given InputStream as currently in use, in order to: count the number of bytes that have been read from it (see getCurrentFileByteCounter())
block read methods calls when the job is paused
limit the throughput if a limit has been specified (see setThroughputLimit(long))
close the InputStream when the job is stopped
|
void |
setIntegrityCheckEnabled(boolean integrityCheckEnabled)
Specifies if file transfers need to be checked for data integrity. |
void |
setThroughputLimit(long bytesPerSecond)
Sets a transfer throughput limit in bytes per seconds, replacing any previous limit. |
void |
skipCurrentFile()
Interrupts the current file transfer and advance to the next one. |
protected boolean |
tryCopyFile(AbstractFile sourceFile,
AbstractFile destFile,
boolean append,
java.lang.String errorDialogTitle)
Tries to copy the given source file to the specified destination file (see copyFile(AbstractFile,AbstractFile,boolean)
displaying a generic error dialog #showErrorDialog() if something went wrong,
and giving the user the choice to skip the file, retry or cancel. |
boolean |
wasCurrentFileSkipped()
Return true if the file that is currently being processed has been skipped. |
| Methods inherited from class com.mucommander.job.FileJob |
|---|
addFileJobListener, getCurrentFileIndex, getCurrentFilename, getEffectiveJobTime, getEndDate, getNbFiles, getPausedTime, getPauseStartDate, getStartDate, getState, hasFolderChanged, interrupt, jobCompleted, jobStarted, processFile, refreshTables, removeFileJobListener, run, selectFileWhenFinished, setAutoUnmark, setPaused, setState, showErrorDialog, showErrorDialog, start, waitForUserResponse |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TransferFileJob(ProgressDialog progressDialog,
MainFrame mainFrame,
FileSet files)
| Method Detail |
|---|
protected void copyFile(AbstractFile sourceFile,
AbstractFile destFile,
boolean append)
throws FileTransferException
FileTransferException
protected boolean tryCopyFile(AbstractFile sourceFile,
AbstractFile destFile,
boolean append,
java.lang.String errorDialogTitle)
copyFile(AbstractFile,AbstractFile,boolean)
displaying a generic error dialog #showErrorDialog() if something went wrong,
and giving the user the choice to skip the file, retry or cancel.
protected java.io.InputStream setCurrentInputStream(java.io.InputStream in)
getCurrentFileByteCounter())
setThroughputLimit(long))
This method should be called by subclasses when creating a new InputStream, before the InputStream is used.
in - the InputStream to be used
protected void closeCurrentInputStream()
public boolean isIntegrityCheckEnabled()
true if file transfers need to be checked for data integrity. In this case, the checksum of
the source and destination files are both calculated and compared to verify they match.
public void setIntegrityCheckEnabled(boolean integrityCheckEnabled)
true is specified, the
checksum of the source and destination files will both be calculated and compared to verify they match.
integrityCheckEnabled - true if file transfers need to be checked for data integrityprotected boolean isCheckingIntegrity()
true if the integrity of the current file is being verified.
public void skipCurrentFile()
public boolean wasCurrentFileSkipped()
true if the file that is currently being processed has been skipped.
public float getFilePercentDone()
0 if the current file's size
is not available (in this case getNbCurrentFileBytesProcessed() returns -1).
public ByteCounter getCurrentFileByteCounter()
public ByteCounter getCurrentFileSkippedByteCounter()
public long getCurrentFileSize()
-1 if this information is not available.
public ByteCounter getTotalByteCounter()
ByteCounter that holds the total number of bytes that have been processed by this job so far.
public ByteCounter getTotalSkippedByteCounter()
ByteCounter that holds the total number of bytes that have been skipped by this job so far.
Bytes are skipped when file transfers are resumed.
public void setThroughputLimit(long bytesPerSecond)
Specifying 0 or -1 disables any throughput limit, the transfer will be carried out at full speed.
If this job is paused, the new limit will be effective after the job has been resumed. If not, it will be effective immediately.
bytesPerSecond - new throughput limit in bytes per second, 0 or -1 to disable the limitpublic long getThroughputLimit()
0 or -1 means that
there currently is no limit to the attainable transfer speed (full speed).
protected void jobStopped()
FileJob.jobStopped() to stop any file processing by closing the source InputStream.
jobStopped in class FileJobprotected void jobPaused()
FileJob.jobPaused() to pause any file processing
by having the source InputStream's read methods lock.
jobPaused in class FileJobprotected void jobResumed()
FileJob.jobResumed() to resume any file processing by releasing
the lock on the source InputStream's read methods.
jobResumed in class FileJobprotected void nextFile(AbstractFile file)
nextFile in class FileJobpublic float getTotalPercentDone()
getTotalPercentDone in class FileJobpublic java.lang.String getStatusString()
getStatusString in class FileJob
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard