Class FileTransfer
java.lang.Object
org.jivesoftware.smackx.filetransfer.FileTransfer
- Direct Known Subclasses:
IncomingFileTransfer
,OutgoingFileTransfer
Contains the generic file information and progress related to a particular
file transfer.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
A class to represent the current status of the file transfer. -
Field Summary
Modifier and TypeFieldDescriptionprotected long
protected FileTransferNegotiator
protected String
-
Constructor Summary
ModifierConstructorDescriptionprotected
FileTransfer
(Jid peer, String streamID, FileTransferNegotiator negotiator) -
Method Summary
Modifier and TypeMethodDescriptionabstract void
cancel()
Cancels the file transfer.long
Return the length of bytes written out to the stream.getError()
WhengetStatus()
returns that there was anFileTransfer.Status.error
during the transfer, the type of error can be retrieved through this method.If an exception occurs asynchronously it will be stored for later retrieval.Returns the name of the file being transferred.Returns the local path of the file.long
Returns the size of the file being transferred.getPeer()
Returns the JID of the peer for this file transfer.double
Returns the progress of the file transfer as a number between 0 and 1.Returns the current status of the file transfer.boolean
isDone()
Returns true if the transfer has been cancelled, if it has stopped because of a an error, or the transfer completed successfully.protected void
setError
(FileTransfer.Error type) protected void
setException
(Exception exception) protected void
setFileInfo
(String fileName, long fileSize) protected void
setFileInfo
(String path, String fileName, long fileSize) protected void
setStatus
(FileTransfer.Status status) protected boolean
updateStatus
(FileTransfer.Status oldStatus, FileTransfer.Status newStatus) protected void
writeToStream
(InputStream in, OutputStream out)
-
Field Details
-
negotiator
-
streamID
-
amountWritten
-
-
Constructor Details
-
FileTransfer
-
-
Method Details
-
setFileInfo
-
setFileInfo
-
getFileSize
Returns the size of the file being transferred.- Returns:
- Returns the size of the file being transferred.
-
getFileName
Returns the name of the file being transferred.- Returns:
- Returns the name of the file being transferred.
-
getFilePath
Returns the local path of the file.- Returns:
- Returns the local path of the file.
-
getPeer
Returns the JID of the peer for this file transfer.- Returns:
- Returns the JID of the peer for this file transfer.
-
getProgress
Returns the progress of the file transfer as a number between 0 and 1.- Returns:
- Returns the progress of the file transfer as a number between 0 and 1.
-
isDone
Returns true if the transfer has been cancelled, if it has stopped because of a an error, or the transfer completed successfully.- Returns:
- Returns true if the transfer has been cancelled, if it has stopped because of a an error, or the transfer completed successfully.
-
getStatus
Returns the current status of the file transfer.- Returns:
- Returns the current status of the file transfer.
-
setError
-
getError
WhengetStatus()
returns that there was anFileTransfer.Status.error
during the transfer, the type of error can be retrieved through this method.- Returns:
- Returns the type of error that occurred if one has occurred.
-
getException
If an exception occurs asynchronously it will be stored for later retrieval. If there is an error there maybe an exception set.- Returns:
- The exception that occurred or null if there was no exception.
- See Also:
-
getStreamID
-
cancel
Cancels the file transfer. -
setException
-
setStatus
-
updateStatus
-
writeToStream
- Throws:
IOException
-
getAmountWritten
Return the length of bytes written out to the stream.- Returns:
- the amount in bytes written out.
-