cz.vity.freerapid.model
Class DownloadFile

java.lang.Object
  extended by org.jdesktop.application.AbstractBean
      extended by cz.vity.freerapid.model.DownloadFile
All Implemented Interfaces:
HttpFile, PropertyChangeListener, EventListener

public class DownloadFile
extends org.jdesktop.application.AbstractBean
implements PropertyChangeListener, HttpFile

Hashcode a Equals nepretizeny na url (muze byt vic souboru s touto url, neni unikatni), pocita se s tim v ProcessManageru pri force download.

Author:
Vity

Constructor Summary
DownloadFile()
          Constructs a new DownloadFile.
DownloadFile(URL fileUrl, File saveToDirectory, String description)
           
 
Method Summary
 float getAllTimeAverageSpeed()
           
 float getAverageSpeed()
          Getter for property 'averageSpeed'.
 long getCompleteTaskDuration()
          Getter for property 'completeTaskDuration'.
 ConnectionSettings getConnectionSettings()
          Getter for property 'connectionSettings'.
 String getDescription()
          Description for this file (password etc.)
 long getDownloaded()
          Returns value - how many bytes were already downloaded for this file.
 int getErrorAttemptsCount()
          Getter for property 'errorAttemptsCount'.
 String getErrorMessage()
          Getter for property 'errorMessage'.
 String getFileName()
          Real physical file name of the downloaded file File name is initialized from given URL to some value.
 long getFileSize()
          Method to get whole file size of the give file.
 FileState getFileState()
          Getter
 String getFileType()
          Getter for property 'fileType'.
 URL getFileUrl()
          URL to file that is given by user
 File getOutputFile()
          Getter for property 'outputFile'.
 String getPluginID()
          Plugin ID associated with this file
 Map<String,Object> getProperties()
          Getter for property 'properties'.
 File getSaveToDirectory()
          Returns target save directory
 String getServiceName()
          Getter for property 'serviceName'.
 String getShareDownloadServiceID()
          Deprecated. 
 int getSleep()
          Getter for property 'sleep'.
 long getSpeed()
          Getter for property 'speed'.
 DownloadState getState()
          Returns current download state of file.
 DownloadTask getTask()
          Getter for property 'task'.
 int getTimeToQueued()
          Getter for property 'timeToQueued'.
 int getTimeToQueuedMax()
          Getter for property 'timeToQueuedMax'.
 void propertyChange(PropertyChangeEvent evt)
           
 void resetErrorAttempts()
           
 void resetSpeed()
           
 void setAllTimeAverageSpeed(float allTimeAverageSpeed)
           
 void setAverageSpeed(float averageSpeed)
          Setter for property 'averageSpeed'.
 void setCompleteTaskDuration(long completeTaskDuration)
          Setter for property 'completeTaskDuration'.
 void setConnectionSettings(ConnectionSettings connectionSettings)
          Setter for property 'connectionSettings'.
 void setDescription(String description)
          Description for this file
 void setDownloaded(long downloaded)
          Sets how many bytes were already downloaded for this file
 void setErrorAttemptsCount(int errorAttemptsCount)
          Setter for property 'errorAttemptsCount'.
 void setErrorMessage(String errorMessage)
          Setter for property 'errorMessage'.
 void setFileName(String fileName)
          Sets file name
 void setFileSize(long fileSize)
          Setter to update file size (of complete file)
 void setFileState(FileState fileState)
          Setter
 void setFileType(String fileType)
          Setter for property 'fileType'.
 void setFileUrl(URL fileUrl)
          Setter for property 'fileUrl'.
 void setNewURL(URL fileUrl)
          Sets new URL for this file for downloading.
 void setPluginID(String pluginID)
          Sets plugin ID associated with this file If pluginID is an empty string, the plugin ID selected automatically.
 void setProperties(Map<String,Object> properties)
          Setter for property 'properties'.
 void setSaveToDirectory(File saveToDirectory)
          Setter for property 'saveToDirectory'.
 void setServiceName(String serviceName)
          Setter for property 'serviceName'.
 void setShareDownloadServiceID(String shareDownloadServiceID)
          Deprecated. 
 void setSleep(int sleep)
          Setter for property 'sleep'.
 void setSpeed(long speed)
          Setter for property 'speed'.
 void setState(DownloadState state)
          Setter
 void setTask(DownloadTask task)
          Setter for property 'task'.
 void setTimeToQueued(int i)
          Setter for property 'timeToQueued'.
 void setTimeToQueuedMax(int timeToQueuedMax)
          Setter for property 'timeToQueuedMax'.
 String toString()
          
 
Methods inherited from class org.jdesktop.application.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DownloadFile

public DownloadFile()
Constructs a new DownloadFile.


DownloadFile

public DownloadFile(URL fileUrl,
                    File saveToDirectory,
                    String description)
Method Detail

setNewURL

public void setNewURL(URL fileUrl)
Sets new URL for this file for downloading. Filename is extracted from this url. Filesize is set to 0.

Specified by:
setNewURL in interface HttpFile
Parameters:
fileUrl - new URL

getSaveToDirectory

public File getSaveToDirectory()
Description copied from interface: HttpFile
Returns target save directory

Specified by:
getSaveToDirectory in interface HttpFile
Returns:
directory

getFileSize

public long getFileSize()
Method to get whole file size of the give file.

Specified by:
getFileSize in interface HttpFile
Returns:
<=0 if file is not known

setFileSize

public void setFileSize(long fileSize)
Setter to update file size (of complete file)

Specified by:
setFileSize in interface HttpFile
Parameters:
fileSize - new value of file size

getTask

public DownloadTask getTask()
Getter for property 'task'.

Returns:
Value for property 'task'.

setTask

public void setTask(DownloadTask task)
Setter for property 'task'.

Parameters:
task - Value to set for property 'task'.

getState

public DownloadState getState()
Returns current download state of file.

Specified by:
getState in interface HttpFile
Returns:
download state of file

setState

public void setState(DownloadState state)
Setter

Specified by:
setState in interface HttpFile
Parameters:
state - new download state during downloading

getFileUrl

public URL getFileUrl()
URL to file that is given by user

Specified by:
getFileUrl in interface HttpFile
Returns:
URL of the downloaded file

getFileName

public String getFileName()
Real physical file name of the downloaded file File name is initialized from given URL to some value. The final filename is updated by during makeFinalRequestForFile method

Specified by:
getFileName in interface HttpFile
Returns:
this method should never return null value
See Also:
HttpDownloadClient.makeFinalRequestForFile(org.apache.commons.httpclient.HttpMethod, HttpFile, boolean);

setFileName

public void setFileName(String fileName)
Sets file name

Specified by:
setFileName in interface HttpFile
Parameters:
fileName - file name

toString

public String toString()

Overrides:
toString in class Object

getDownloaded

public long getDownloaded()
Returns value - how many bytes were already downloaded for this file.

Specified by:
getDownloaded in interface HttpFile
Returns:
file size in bytes

setDownloaded

public void setDownloaded(long downloaded)
Sets how many bytes were already downloaded for this file

Specified by:
setDownloaded in interface HttpFile
Parameters:
downloaded - file size in bytes

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

setSpeed

public void setSpeed(long speed)
Setter for property 'speed'.

Parameters:
speed - Value to set for property 'speed'.

getSpeed

public long getSpeed()
Getter for property 'speed'.

Returns:
Value for property 'speed'.

setSleep

public void setSleep(int sleep)
Setter for property 'sleep'.

Parameters:
sleep - Value to set for property 'sleep'.

setAverageSpeed

public void setAverageSpeed(float averageSpeed)
Setter for property 'averageSpeed'.

Parameters:
averageSpeed - Value to set for property 'averageSpeed'.

setErrorMessage

public void setErrorMessage(String errorMessage)
Setter for property 'errorMessage'.

Parameters:
errorMessage - Value to set for property 'errorMessage'.

getSleep

public int getSleep()
Getter for property 'sleep'.

Returns:
Value for property 'sleep'.

getAverageSpeed

public float getAverageSpeed()
Getter for property 'averageSpeed'.

Returns:
Value for property 'averageSpeed'.

getServiceName

public String getServiceName()
Getter for property 'serviceName'.

Returns:
Value for property 'serviceName'.

setServiceName

public void setServiceName(String serviceName)
Setter for property 'serviceName'.

Parameters:
serviceName - Value to set for property 'serviceName'.

getErrorMessage

public String getErrorMessage()
Getter for property 'errorMessage'.

Returns:
Value for property 'errorMessage'.

getOutputFile

public File getOutputFile()
Getter for property 'outputFile'.

Returns:
Value for property 'outputFile'.

setFileUrl

public void setFileUrl(URL fileUrl)
Setter for property 'fileUrl'.

Parameters:
fileUrl - Value to set for property 'fileUrl'.

setSaveToDirectory

public void setSaveToDirectory(File saveToDirectory)
Setter for property 'saveToDirectory'.

Parameters:
saveToDirectory - Value to set for property 'saveToDirectory'.

getDescription

public String getDescription()
Description for this file (password etc.)

Specified by:
getDescription in interface HttpFile
Returns:
description for this file

setDescription

public void setDescription(String description)
Description for this file

Specified by:
setDescription in interface HttpFile
Parameters:
description - new value description

getFileType

public String getFileType()
Getter for property 'fileType'.

Returns:
Value for property 'fileType'.

setFileType

public void setFileType(String fileType)
Setter for property 'fileType'.

Parameters:
fileType - Value to set for property 'fileType'.

getShareDownloadServiceID

@Deprecated
public String getShareDownloadServiceID()
Deprecated. 

Getter for property 'shareDownloadServiceID'.

Returns:
Value for property 'shareDownloadServiceID'.

setTimeToQueued

public void setTimeToQueued(int i)
Setter for property 'timeToQueued'.

Parameters:
i - Value to set for property 'timeToQueued'.

getTimeToQueued

public int getTimeToQueued()
Getter for property 'timeToQueued'.

Returns:
Value for property 'timeToQueued'.

setErrorAttemptsCount

public void setErrorAttemptsCount(int errorAttemptsCount)
Setter for property 'errorAttemptsCount'.

Parameters:
errorAttemptsCount - Value to set for property 'errorAttemptsCount'.

getErrorAttemptsCount

public int getErrorAttemptsCount()
Getter for property 'errorAttemptsCount'.

Returns:
Value for property 'errorAttemptsCount'.

resetErrorAttempts

public void resetErrorAttempts()

setShareDownloadServiceID

@Deprecated
public void setShareDownloadServiceID(String shareDownloadServiceID)
Deprecated. 

Setter for property 'shareDownloadServiceID'.

Parameters:
shareDownloadServiceID - Value to set for property 'shareDownloadServiceID'.

getTimeToQueuedMax

public int getTimeToQueuedMax()
Getter for property 'timeToQueuedMax'.

Returns:
Value for property 'timeToQueuedMax'.

setTimeToQueuedMax

public void setTimeToQueuedMax(int timeToQueuedMax)
Setter for property 'timeToQueuedMax'.

Parameters:
timeToQueuedMax - Value to set for property 'timeToQueuedMax'.

resetSpeed

public void resetSpeed()

getCompleteTaskDuration

public long getCompleteTaskDuration()
Getter for property 'completeTaskDuration'.

Returns:
Value for property 'completeTaskDuration'.

setCompleteTaskDuration

public void setCompleteTaskDuration(long completeTaskDuration)
Setter for property 'completeTaskDuration'.

Parameters:
completeTaskDuration - Value to set for property 'completeTaskDuration'.

getConnectionSettings

public ConnectionSettings getConnectionSettings()
Getter for property 'connectionSettings'.

Returns:
Value for property 'connectionSettings'.

setConnectionSettings

public void setConnectionSettings(ConnectionSettings connectionSettings)
Setter for property 'connectionSettings'.

Parameters:
connectionSettings - Value to set for property 'connectionSettings'.

getFileState

public FileState getFileState()
Getter

Specified by:
getFileState in interface HttpFile
Returns:
returns actual file state (its existence state on the server)

setFileState

public void setFileState(FileState fileState)
Setter

Specified by:
setFileState in interface HttpFile
Parameters:
fileState - new value of file state

getProperties

public Map<String,Object> getProperties()
Description copied from interface: HttpFile
Getter for property 'properties'.

Specified by:
getProperties in interface HttpFile
Returns:
Value for property 'properties'.

setProperties

public void setProperties(Map<String,Object> properties)
Setter for property 'properties'.

Parameters:
properties - Value to set for property 'properties'.

setPluginID

public void setPluginID(String pluginID)
Sets plugin ID associated with this file If pluginID is an empty string, the plugin ID selected automatically.

Specified by:
setPluginID in interface HttpFile
Parameters:
pluginID - plugin ID

getPluginID

public String getPluginID()
Plugin ID associated with this file

Specified by:
getPluginID in interface HttpFile
Returns:

getAllTimeAverageSpeed

public float getAllTimeAverageSpeed()

setAllTimeAverageSpeed

public void setAllTimeAverageSpeed(float allTimeAverageSpeed)