netx.jnlp.cache

Class Resource


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.

Version:
$Revision: 1.9 $
Author:
Jon A. Maxwell (JAM) - initial author

Field Summary

static int
CONNECT
static int
CONNECTED
static int
CONNECTING
static int
DOWNLOAD
static int
DOWNLOADED
static int
DOWNLOADING
static int
ERROR
static int
STARTED
static int
UNINITIALIZED
status bits
(package private) URLConnection
connection
connection to resource
(package private) Version
downloadVersion
the version downloaded from server
(package private) File
localFile
the local file downloaded to
(package private) URL
location
the remote location of the resource
(package private) Version
requestVersion
the requested version
(package private) long
size
total size of the resource, or -1 if unknown
(package private) int
status
the status of the resource
(package private) long
transferred
amount in bytes transferred

Method Summary

void
addTracker(ResourceTracker tracker)
Adds the tracker to the list of trackers monitoring this resource.
void
changeStatus(int clear, int add)
Changes the status by clearing the flags in the first parameter and setting the flags in the second.
boolean
equals(Object other)
protected void
fireDownloadEvent()
Instructs the trackers monitoring this resource to fire a download event.
URL
getLocation()
Returns the remote location of the resource.
static Resource
getResource(URL location, Version requestVersion)
Return a shared Resource object representing the given location and version.
(package private) ResourceTracker
getTracker()
Returns the tracker that first created or monitored the resource, or null if no trackers are monitoring the resource.
boolean
isSet(int flag)
Returns true if any of the specified flags are set.
void
removeTracker(ResourceTracker tracker)
Removes the tracker to the list of trackers monitoring this resource.
String
toString()

Field Details

CONNECT

public static final int CONNECT
Field Value:
1

CONNECTED

public static final int CONNECTED
Field Value:
4

CONNECTING

public static final int CONNECTING
Field Value:
2

DOWNLOAD

public static final int DOWNLOAD
Field Value:
8

DOWNLOADED

public static final int DOWNLOADED
Field Value:
32

DOWNLOADING

public static final int DOWNLOADING
Field Value:
16

ERROR

public static final int ERROR
Field Value:
64

STARTED

public static final int STARTED
Field Value:
128

UNINITIALIZED

public static final int UNINITIALIZED
status bits
Field Value:
0

connection

(package private)  URLConnection connection
connection to resource

downloadVersion

(package private)  Version downloadVersion
the version downloaded from server

localFile

(package private)  File localFile
the local file downloaded to

location

(package private)  URL location
the remote location of the resource

requestVersion

(package private)  Version requestVersion
the requested version

size

(package private)  long size
total size of the resource, or -1 if unknown

status

(package private)  int status
the status of the resource

transferred

(package private)  long transferred
amount in bytes transferred

Method Details

addTracker

public void addTracker(ResourceTracker tracker)
Adds the tracker to the list of trackers monitoring this resource.

changeStatus

public void changeStatus(int clear,
                         int add)
Changes the status by clearing the flags in the first parameter and setting the flags in the second. This method is synchronized on this resource.

equals

public boolean equals(Object other)

fireDownloadEvent

protected void fireDownloadEvent()
Instructs the trackers monitoring this resource to fire a download event.

getLocation

public URL getLocation()
Returns the remote location of the resource.

getResource

public static Resource getResource(URL location,
                                   Version requestVersion)
Return a shared Resource object representing the given location and version.

getTracker

(package private)  ResourceTracker getTracker()
Returns the tracker that first created or monitored the resource, or null if no trackers are monitoring the resource.

isSet

public boolean isSet(int flag)
Returns true if any of the specified flags are set.

removeTracker

public void removeTracker(ResourceTracker tracker)
Removes the tracker to the list of trackers monitoring this resource.

toString

public String toString()