Class FileTransfer
- java.lang.Object
-
- org.jivesoftware.smackx.filetransfer.FileTransfer
-
- Direct Known Subclasses:
IncomingFileTransfer,OutgoingFileTransfer
public abstract class FileTransfer extends java.lang.Object
Contains the generic file information and progress related to a particular file transfer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFileTransfer.Errorstatic classFileTransfer.StatusA class to represent the current status of the file transfer.
-
Field Summary
Fields Modifier and Type Field Description protected longamountWrittenprotected FileTransferNegotiatornegotiatorprotected java.lang.StringstreamID
-
Constructor Summary
Constructors Modifier Constructor Description protectedFileTransfer(Jid peer, java.lang.String streamID, FileTransferNegotiator negotiator)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidcancel()Cancels the file transfer.longgetAmountWritten()Return the length of bytes written out to the stream.FileTransfer.ErrorgetError()WhengetStatus()returns that there was anFileTransfer.Status.errorduring the transfer, the type of error can be retrieved through this method.java.lang.ExceptiongetException()If an exception occurs asynchronously it will be stored for later retrieval.java.lang.StringgetFileName()Returns the name of the file being transferred.java.lang.StringgetFilePath()Returns the local path of the file.longgetFileSize()Returns the size of the file being transferred.JidgetPeer()Returns the JID of the peer for this file transfer.doublegetProgress()Returns the progress of the file transfer as a number between 0 and 1.FileTransfer.StatusgetStatus()Returns the current status of the file transfer.java.lang.StringgetStreamID()booleanisDone()Returns true if the transfer has been cancelled, if it has stopped because of a an error, or the transfer completed successfully.protected voidsetError(FileTransfer.Error type)protected voidsetException(java.lang.Exception exception)protected voidsetFileInfo(java.lang.String fileName, long fileSize)protected voidsetFileInfo(java.lang.String path, java.lang.String fileName, long fileSize)protected voidsetStatus(FileTransfer.Status status)protected booleanupdateStatus(FileTransfer.Status oldStatus, FileTransfer.Status newStatus)protected voidwriteToStream(java.io.InputStream in, java.io.OutputStream out)
-
-
-
Field Detail
-
negotiator
protected FileTransferNegotiator negotiator
-
streamID
protected java.lang.String streamID
-
amountWritten
protected long amountWritten
-
-
Constructor Detail
-
FileTransfer
protected FileTransfer(Jid peer, java.lang.String streamID, FileTransferNegotiator negotiator)
-
-
Method Detail
-
setFileInfo
protected void setFileInfo(java.lang.String fileName, long fileSize)
-
setFileInfo
protected void setFileInfo(java.lang.String path, java.lang.String fileName, long fileSize)
-
getFileSize
public long getFileSize()
Returns the size of the file being transferred.- Returns:
- Returns the size of the file being transferred.
-
getFileName
public java.lang.String getFileName()
Returns the name of the file being transferred.- Returns:
- Returns the name of the file being transferred.
-
getFilePath
public java.lang.String getFilePath()
Returns the local path of the file.- Returns:
- Returns the local path of the file.
-
getPeer
public Jid getPeer()
Returns the JID of the peer for this file transfer.- Returns:
- Returns the JID of the peer for this file transfer.
-
getProgress
public double 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
public boolean 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
public FileTransfer.Status getStatus()
Returns the current status of the file transfer.- Returns:
- Returns the current status of the file transfer.
-
setError
protected void setError(FileTransfer.Error type)
-
getError
public FileTransfer.Error getError()
WhengetStatus()returns that there was anFileTransfer.Status.errorduring 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
public java.lang.Exception 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:
getError()
-
getStreamID
public java.lang.String getStreamID()
-
cancel
public abstract void cancel()
Cancels the file transfer.
-
setException
protected void setException(java.lang.Exception exception)
-
setStatus
protected void setStatus(FileTransfer.Status status)
-
updateStatus
protected boolean updateStatus(FileTransfer.Status oldStatus, FileTransfer.Status newStatus)
-
writeToStream
protected void writeToStream(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
getAmountWritten
public long getAmountWritten()
Return the length of bytes written out to the stream.- Returns:
- the amount in bytes written out.
-
-