public class Resource
extends java.lang.Object
Information about a single resource to download. This class tracks the downloading of various resources of a JNLP file to local files. It can be used to download icons, jnlp and extension files, jars, and jardiff files using the version based protocol or any file using the basic download protocol.
Resources can be put into download groups by specifying a part name for the resource. The resource tracker can also be configured to prefetch resources, which are downloaded in the order added to the media tracker.
Modifier and Type | Class and Description |
---|---|
static class |
Resource.Status |
Modifier and Type | Method and Description |
---|---|
void |
addTracker(ResourceTracker tracker)
Adds the tracker to the list of trackers monitoring this
resource.
|
void |
changeStatus(java.util.Collection<Resource.Status> clear,
java.util.Collection<Resource.Status> add)
Changes the status by clearing the flags in the first
parameter and setting the flags in the second.
|
boolean |
equals(java.lang.Object other) |
protected void |
fireDownloadEvent()
Instructs the trackers monitoring this resource to fire a
download event.
|
java.util.Set<Resource.Status> |
getCopyOfStatus() |
java.net.URL |
getDownloadLocation()
Returns the URL to use for downloading the resource.
|
DownloadOptions |
getDownloadOptions() |
Version |
getDownloadVersion() |
java.io.File |
getLocalFile() |
java.net.URL |
getLocation()
Returns the remote location of the resource.
|
Version |
getRequestVersion() |
static Resource |
getResource(java.net.URL location,
Version requestVersion,
UpdatePolicy updatePolicy)
Return a shared Resource object representing the given
location and version.
|
long |
getSize()
Returns the size of the resource
|
long |
getTransferred() |
UpdatePolicy |
getUpdatePolicy() |
boolean |
hasFlags(java.util.Collection<Resource.Status> flags)
Check if all the specified flags are set.
|
int |
hashCode() |
void |
incrementTransferred(long incTrans)
Increments the amount transferred (in bytes)
|
boolean |
isConnectable() |
boolean |
isInitialized()
Check if this resource has been initialized
|
boolean |
isSet(Resource.Status flag)
Check if the specified flag is set.
|
void |
removeTracker(ResourceTracker tracker)
Removes the tracker to the list of trackers monitoring this
resource.
|
void |
resetStatus()
Clear all flags
|
void |
setDownloadLocation(java.net.URL downloadLocation)
Set the url to use for downloading the resource
|
void |
setDownloadOptions(DownloadOptions downloadOptions) |
void |
setDownloadVersion(Version downloadVersion)
Sets the version downloaded from server
|
void |
setLocalFile(java.io.File localFile)
Sets the local file to be downloaded
|
void |
setSize(long size)
Sets the size of the resource
|
void |
setStatusFlag(Resource.Status flag)
Set status flag
|
void |
setStatusFlags(java.util.Collection<Resource.Status> flags)
Set flags
|
void |
setTransferred(long transferred)
Sets the amount transferred
|
java.lang.String |
toString() |
void |
unsetStatusFlag(java.util.Collection<Resource.Status> flags)
Unset flags
|
public static Resource getResource(java.net.URL location, Version requestVersion, UpdatePolicy updatePolicy)
location
- final location of resourcerequestVersion
- final version of resourceupdatePolicy
- final policy for updatingpublic java.net.URL getLocation()
public java.net.URL getDownloadLocation()
public void setDownloadLocation(java.net.URL downloadLocation)
downloadLocation
- url to be donloadedpublic java.io.File getLocalFile()
public void setLocalFile(java.io.File localFile)
localFile
- location of stored resourcepublic Version getRequestVersion()
public Version getDownloadVersion()
public void setDownloadVersion(Version downloadVersion)
downloadVersion
- version of downloaded resourcepublic long getTransferred()
public void setTransferred(long transferred)
transferred
- set the whole transfered amount to this valuepublic void incrementTransferred(long incTrans)
incTrans
- transfered amount in last transferpublic long getSize()
public void setSize(long size)
size
- desired size of resourcepublic java.util.Set<Resource.Status> getCopyOfStatus()
public boolean isSet(Resource.Status flag)
flag
- a status flagpublic boolean hasFlags(java.util.Collection<Resource.Status> flags)
flags
- a collection of flagspublic UpdatePolicy getUpdatePolicy()
public void changeStatus(java.util.Collection<Resource.Status> clear, java.util.Collection<Resource.Status> add)
clear
- a collection of status flags to unsetadd
- a collection of status flags to setpublic void setStatusFlag(Resource.Status flag)
flag
- a flag to setpublic void setStatusFlags(java.util.Collection<Resource.Status> flags)
flags
- a collection of flags to setpublic void unsetStatusFlag(java.util.Collection<Resource.Status> flags)
flags
- a collection of flags to unsetpublic void resetStatus()
public boolean isInitialized()
public void removeTracker(ResourceTracker tracker)
tracker
- tracker to be removedpublic void addTracker(ResourceTracker tracker)
tracker
- to observing resourceprotected void fireDownloadEvent()
public void setDownloadOptions(DownloadOptions downloadOptions)
public DownloadOptions getDownloadOptions()
public boolean isConnectable()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object