Class Resource
java.lang.Object
net.adoptopenjdk.icedteaweb.resources.Resource
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.
- Version:
- $Revision: 1.9 $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DownloadOptionsDownload options for this resourceA future to wait for completion of download of this resourceprivate Filethe local file downloaded toprivate final URLthe remote location of the resourceprivate final PropertyChangeSupportprivate final VersionStringthe requested versionlist of weak references of resources currently in useprivate longtotal size of the resource, or -1 if unknownstatic final Stringprivate ResourceStatusthe status of the resourceprivate longamount in bytes transferredstatic final Stringprivate final UpdatePolicyUpdate policy for this resource -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateResource(URL location, VersionString requestVersion, DownloadOptions downloadOptions, UpdatePolicy updatePolicy) Create a resource. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener) (package private) static ResourcecreateOrGetResource(URL location, VersionString requestVersion, DownloadOptions downloadOptions, UpdatePolicy updatePolicy) Creates and returns a shared Resource object representing the given location and version.booleanboolean(package private) FileReturns the remote location of the resource.longgetSize()Returns the size of the resource(package private) longinthashCode()(package private) booleanhasStatus(ResourceStatus flag) Check if the specified flag is set.(package private) boolean(package private) booleanputIntoCache(Executor downloadExecutor) voidsetLocalFile(File localFile) Sets the local file to be downloadedvoidsetSize(long size) Sets the size of the resourcevoidsetStatus(ResourceStatus status) Changes the status.voidsetTransferred(long transferred) Sets the amount transferredtoString()
-
Field Details
-
resources
-
SIZE_PROPERTY
- See Also:
-
TRANSFERRED_PROPERTY
- See Also:
-
propertyChangeSupport
-
location
the remote location of the resource -
requestVersion
the requested version -
updatePolicy
Update policy for this resource -
downloadOptions
Download options for this resource -
localFile
the local file downloaded to -
transferred
private volatile long transferredamount in bytes transferred -
size
private volatile long sizetotal size of the resource, or -1 if unknown -
futureForDownloaded
-
status
the status of the resource
-
-
Constructor Details
-
Resource
private Resource(URL location, VersionString requestVersion, DownloadOptions downloadOptions, UpdatePolicy updatePolicy) Create a resource.
-
-
Method Details
-
addPropertyChangeListener
-
addPropertyChangeListener
-
createOrGetResource
static Resource createOrGetResource(URL location, VersionString requestVersion, DownloadOptions downloadOptions, UpdatePolicy updatePolicy) Creates and returns a shared Resource object representing the given location and version.- Parameters:
location- final location of resourcerequestVersion- final version of resourcedownloadOptions- hint for downloadingupdatePolicy- final policy for updating- Returns:
- new resource, which is already added in resources list
-
getLocation
Returns the remote location of the resource.- Returns:
- the same location as the one with which this resource was created
-
getLocalFile
File getLocalFile()- Returns:
- the local file currently being downloaded
-
setLocalFile
Sets the local file to be downloaded- Parameters:
localFile- location of stored resource
-
getRequestVersion
- Returns:
- the requested version
-
getTransferred
long getTransferred()- Returns:
- the amount in bytes transferred
-
setTransferred
public void setTransferred(long transferred) Sets the amount transferred- Parameters:
transferred- set the whole transferred amount to this value
-
getSize
public long getSize()Returns the size of the resource- Returns:
- size of resource (-1 if unknown)
-
setSize
public void setSize(long size) Sets the size of the resource- Parameters:
size- desired size of resource
-
isBeingProcessed
boolean isBeingProcessed() -
hasStatus
Check if the specified flag is set.- Parameters:
flag- a status flag- Returns:
- true iff the flag is set
-
isComplete
boolean isComplete() -
getUpdatePolicy
- Returns:
- the update policy for this resource
-
forceUpdateRequested
public boolean forceUpdateRequested() -
setStatus
Changes the status.- Parameters:
status- a collection of status flags to set
-
getDownloadOptions
-
hashCode
-
equals
-
toString
-
getSimpleName
-
putIntoCache
-