aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/cache
diff options
context:
space:
mode:
authorAndrew John Hughes <[email protected]>2010-10-21 21:12:21 +0100
committerAndrew John Hughes <[email protected]>2010-10-21 21:12:21 +0100
commit61aeaaf89164aa93280527c7eb80cf4c1432fbee (patch)
tree73a8266a319eadc6126f3196f35ccb28ef330bcf /netx/net/sourceforge/jnlp/cache
parent16d8de7b9030235bfc7e3cb8e6a480a08f6a46d8 (diff)
Fix most warnings arising from NetX code.
2010-10-20 Andrew John Hughes <[email protected]> * netx/javax/jnlp/ServiceManager.java: (lookupTable): Add generic types. * netx/net/sourceforge/jnlp/AppletDesc.java: (parameters): Likewise. (AppletDesc(String,String,URL,int,int,Map)): Likewise. (getParameters()): Likewise. * netx/net/sourceforge/jnlp/ApplicationDesc.java: (getArguments()): Remove redundant cast. (addArgument(String)): Add generic typing. * netx/net/sourceforge/jnlp/ExtensionDesc.java: (extToPart): Add generic types. (eagerExtParts): Likewise. * netx/net/sourceforge/jnlp/InformationDesc.java: (info): Likewise. (getIcons(Object)): Add generic typing. (getAssociations()): Likewise. (getRelatedContents()): Likewise. (getItem(Object)): Likewise. (getItems(Object)): Likewise. (addItem(String,Object)): Likewise. * netx/net/sourceforge/jnlp/JNLPFile.java: (resources): Likewise. (InformationDesc.getItems(Object)): Likewise. (getResources(Class)): Likewise. * netx/net/sourceforge/jnlp/LaunchException.java: (getCauses()): Likewise. * netx/net/sourceforge/jnlp/Launcher.java: (launchApplication(JNLPFile)): Likewise. * netx/net/sourceforge/jnlp/NetxPanel.java: (NetxPanel(URL,Hashtable)): Likewise. (NetxPanel(URL,Hashtable,boolean)): Likewise. * netx/net/sourceforge/jnlp/Node.java: (getChildNodes()): Likewise. * netx/net/sourceforge/jnlp/Parser.java: (getResources(Node,boolean)): Likewise. (getInfo(Node)): Likewise. (getInformationDesc(Node)): Likewise. (getApplet(Node)): Likewise. (getApplication(Node)): Likewise. (splitString(String)): Likewise. (getLocales(Node)): Likewise. (getChildNodes(Node,String)): Likewise. * netx/net/sourceforge/jnlp/PluginBridge.java: Fix variable naming and add generic types. (cacheJars): Changed from cache_jars. (cacheExJars): Changed from cache_ex-jars. (atts): Add generic typing. (PluginBridge(URL,URL,String,String,int,int,Hashtable)): Likewise. (getInformation(Locale)): Likewise. (getResources(Locale,String,String)): Likewise. (getJARs()): Avoid excessive copying; filtering already performed by getResources in JNLPFile. * netx/net/sourceforge/jnlp/ResourcesDesc.java: (resources): Add generic typing. (getJREs()): Likewise. (getJARs()): Likewise. (getJARs(String)): Likewise. (getExtensions()): Likewise. (getPackages()): Likewise. (getPackages(String)): Likewise. (getProperties()): Likewise. (getPropertiesMap()): Likewise. (getResources(Class)): Make generic. * netx/net/sourceforge/jnlp/Version.java: (matches(Version)): Add generic types. (matchesAny(Version)): Likewise. (matchesSingle(String)): Likewise. (matches(String,String)): Likewise. (equal(List,List)): Likewise. (greater(List,List)): Likewise. (compare(String,String)): Use Integer.valueOf. (normalize(List,int)): Add generic types, using a List of lists rather than an array of lists. (getVersionStrings()): Add generic types. (getParts()): Likewise. * netx/net/sourceforge/jnlp/cache/CacheUtil.java: (waitForResources(ApplicationInstance,ResourceTracker, URL,String)): Likewise. * netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java: (getListener(ApplicatonInstance,String,URL)): Use setVisible instead of show(). (disposeListener(DownloadServiceListener)): Use setVisible instead of hide(). (DownloadPanel.urls): Add generic typing. (DownloadPanel.panels): Likewise. (DownloadPanel.update(URL,String,long,long,int)): Fix formatting. Add generic types. * netx/net/sourceforge/jnlp/cache/Resource.java: (resources): Add generic typing. (trackers): Likewise. (getResource(URL,Version,UpdatePolicy)): Use generic types. (getTracker()): Likewise. (addTracker(ResourceTracker)): Likewise. (fireDownloadEvent()): Likewise. * netx/net/sourceforge/jnlp/cache/ResourceTracker.java: (prefetchTrackers): Add generic typing. (queue): Likewise. (active): Likewise. (resources): Likewise. (listeners): Likewise. (fireDownloadEvent(Resource)): Remove unneeded cast. (getPrefetch()): Use generic typing. (selectByFlag(List,int,int)): Likewise. (getResource(URL)): Likewise. * netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java: (weakClips): Add generic types. (destroy()): Use generic typing. (getApplets()): Likewise. (getStreamKeys()): Likewise. * netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java: (weakWindows): Add generic types. (installEnvironment()): Likewise. (destroy()): Remove redundant cast. * netx/net/sourceforge/jnlp/runtime/Boot.java: Extend PrivilegedAction<Void>. (run()): Add generic typing. (getOptions(String)): Likewise. * netx/net/sourceforge/jnlp/runtime/Boot13.java: (main(String[]): Likewise. * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: Fix formatting. (urlToLoader): Add generic types. (resourcePermissions): Likewise. (available): Likewise. (jarEntries): Likewise. (getInstance(JNLPFile,UpdatePolicy)): Remove redundant cast. (getInstance(URL,String,Version,UpdatePolicy)): Likewise. (initializeExtensions()): Add generic types. (initializePermissions()): Likewise. (initializeResources()): Likewise. (getPermissions(CodeSource)): Likewise. (fillInPartJars(List)): Likewise. (activateJars(List)): Likewise. (loadClass(String)): Likewise. Suppress warnings due to sun.misc.JarIndex usage. (findResources(String)): Mark as overriding. Add generic types. (getExtensionName()): Add @Deprecated annotation. (getExtensionHREF()): Likewise. * netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java: (weakWindows): Add generic typing. (weakApplications): Likewise. (getApplication(Window)): Remove redundant casts. Add w, which is window cast to Window. * netx/net/sourceforge/jnlp/services/ServiceUtil.java: (invoke(Object,Method,Object[])): Use generic types. * netx/net/sourceforge/jnlp/services/XPersistenceService.java: (getNames(URL)): Likewise. * netx/net/sourceforge/jnlp/tools/JarSigner.java: (verifyJars(List,ResourceTracker)): Remove redundant cast. * netx/net/sourceforge/jnlp/util/WeakList.java: Redesign as a generic type. (refs): Add generic types. (deref(WeakReference)): Likewise. (get(int)): Likewise. (set(int,Object)): Likewise. (add(int,E)): Likewise. (remove()): Likewise. (hardList()): Likewise. * netx/net/sourceforge/nanoxml/XMLElement.java: (attributes): Add generic typing. (children): Likewise. (entities): Likewise. (XMLElement()): Use generic types. (XMLElement(Hashtable): Likewise. (resolveEntity(StringBuffer)): Remove redundant cast.
Diffstat (limited to 'netx/net/sourceforge/jnlp/cache')
-rw-r--r--netx/net/sourceforge/jnlp/cache/CacheUtil.java4
-rw-r--r--netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java14
-rw-r--r--netx/net/sourceforge/jnlp/cache/Resource.java17
-rw-r--r--netx/net/sourceforge/jnlp/cache/ResourceTracker.java25
4 files changed, 33 insertions, 27 deletions
diff --git a/netx/net/sourceforge/jnlp/cache/CacheUtil.java b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
index 9623edb..451e04a 100644
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java
+++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
@@ -400,12 +400,12 @@ public class CacheUtil {
return;
// only resources not starting out downloaded are displayed
- List urlList = new ArrayList();
+ List<URL> urlList = new ArrayList<URL>();
for (int i=0; i < resources.length; i++) {
if (!tracker.checkResource(resources[i]))
urlList.add(resources[i]);
}
- URL undownloaded[] = (URL[]) urlList.toArray( new URL[urlList.size()] );
+ URL undownloaded[] = urlList.toArray( new URL[urlList.size()] );
listener = indicator.getListener(app, title, undownloaded);
diff --git a/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java b/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
index bd1cbd9..407d6f4 100644
--- a/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
+++ b/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
@@ -118,7 +118,7 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
screen.height-frame.getHeight());
}
- frame.show();
+ frame.setVisible(true);
return result;
}
@@ -135,7 +135,7 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
ActionListener hider = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (frame.getContentPane().getComponentCount() == 1)
- frame.hide();
+ frame.setVisible(false);
frame.getContentPane().remove((DownloadPanel) listener);
frame.pack();
@@ -161,10 +161,10 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
private JLabel header = new JLabel();
/** list of URLs being downloaded */
- private List urls = new ArrayList();
+ private List<URL> urls = new ArrayList<URL>();
/** list of ProgressPanels */
- private List panels = new ArrayList();
+ private List<ProgressPanel> panels = new ArrayList<ProgressPanel>();
/**
@@ -199,7 +199,9 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
/**
* Update the download progress of a url.
*/
- protected void update(final URL url, final String version, final long readSoFar, final long total, final int overallPercent) {
+ protected void update(final URL url, final String version,
+ final long readSoFar, final long total,
+ final int overallPercent) {
Runnable r = new Runnable() {
public void run() {
if (!urls.contains(url))
@@ -207,7 +209,7 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
setOverallPercent(overallPercent);
- ProgressPanel panel = (ProgressPanel) panels.get(urls.indexOf(url));
+ ProgressPanel panel = panels.get(urls.indexOf(url));
panel.setProgress(readSoFar, total);
panel.repaint();
}
diff --git a/netx/net/sourceforge/jnlp/cache/Resource.java b/netx/net/sourceforge/jnlp/cache/Resource.java
index 172220f..08a31fb 100644
--- a/netx/net/sourceforge/jnlp/cache/Resource.java
+++ b/netx/net/sourceforge/jnlp/cache/Resource.java
@@ -60,10 +60,10 @@ public class Resource {
public static final int STARTED = 128; // enqueued or being worked on
/** list of weak references of resources currently in use */
- private static WeakList resources = new WeakList();
+ private static WeakList<Resource> resources = new WeakList<Resource>();
/** weak list of trackers monitoring this resource */
- private WeakList trackers = new WeakList();
+ private WeakList<ResourceTracker> trackers = new WeakList<ResourceTracker>();
/** the remote location of the resource */
URL location;
@@ -111,7 +111,7 @@ public class Resource {
int index = resources.indexOf(resource);
if (index >= 0) { // return existing object
- Resource result = (Resource) resources.get(index);
+ Resource result = resources.get(index);
if (result != null)
return result;
}
@@ -136,9 +136,9 @@ public class Resource {
*/
ResourceTracker getTracker() {
synchronized (trackers) {
- List t = trackers.hardList();
+ List<ResourceTracker> t = trackers.hardList();
if (t.size() > 0)
- return (ResourceTracker) t.get(0);
+ return t.get(0);
return null;
}
@@ -225,7 +225,8 @@ public class Resource {
*/
public void addTracker(ResourceTracker tracker) {
synchronized (trackers) {
- List t = trackers.hardList(); // prevent GC between contains and add
+ // prevent GC between contains and add
+ List<ResourceTracker> t = trackers.hardList();
if (!t.contains(tracker))
trackers.add(tracker);
@@ -238,14 +239,14 @@ public class Resource {
* download event.
*/
protected void fireDownloadEvent() {
- List send;
+ List<ResourceTracker> send;
synchronized (trackers) {
send = trackers.hardList();
}
for (int i=0; i < send.size(); i++) {
- ResourceTracker rt = (ResourceTracker) send.get(i);
+ ResourceTracker rt = send.get(i);
rt.fireDownloadEvent(this);
}
}
diff --git a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
index d65c840..df923f2 100644
--- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
+++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
@@ -113,19 +113,21 @@ public class ResourceTracker {
private static int threads = 0;
/** weak list of resource trackers with resources to prefetch */
- private static WeakList prefetchTrackers = new WeakList();
+ private static WeakList<ResourceTracker> prefetchTrackers =
+ new WeakList<ResourceTracker>();
/** resources requested to be downloaded */
- private static ArrayList queue = new ArrayList();
+ private static ArrayList<Resource> queue = new ArrayList<Resource>();
/** resource trackers threads are working for (used for load balancing across multi-tracker downloads) */
- private static ArrayList active = new ArrayList(); //
+ private static ArrayList<ResourceTracker> active =
+ new ArrayList<ResourceTracker>(); //
/** the resources known about by this resource tracker */
- private List resources = new ArrayList();
+ private List<Resource> resources = new ArrayList<Resource>();
/** download listeners for this tracker */
- private List listeners = new ArrayList();
+ private List<DownloadListener> listeners = new ArrayList<DownloadListener>();
/** whether to download parts before requested */
private boolean prefetch;
@@ -293,7 +295,7 @@ public class ResourceTracker {
protected void fireDownloadEvent(Resource resource) {
DownloadListener l[] = null;
synchronized (listeners) {
- l = (DownloadListener[]) listeners.toArray(new DownloadListener[0]);
+ l = listeners.toArray(new DownloadListener[0]);
}
int status;
@@ -865,7 +867,7 @@ public class ResourceTracker {
// first find one to initialize
synchronized (prefetchTrackers) {
for (int i=0; i < prefetchTrackers.size() && result == null; i++) {
- ResourceTracker tracker = (ResourceTracker) prefetchTrackers.get(i);
+ ResourceTracker tracker = prefetchTrackers.get(i);
if (tracker == null)
continue;
@@ -907,12 +909,13 @@ public class ResourceTracker {
* Calls to this method should be synchronized on lock and
* source list.<p>
*/
- private static Resource selectByFlag(List source, int flag, int notflag) {
+ private static Resource selectByFlag(List<Resource> source, int flag,
+ int notflag) {
Resource result = null;
int score = Integer.MAX_VALUE;
for (int i=0; i < source.size(); i++) {
- Resource resource = (Resource) source.get(i);
+ Resource resource = source.get(i);
boolean selectable = false;
synchronized (resource) {
@@ -924,7 +927,7 @@ public class ResourceTracker {
int activeCount = 0;
for (int j=0; j < active.size(); j++)
- if ((ResourceTracker)active.get(j) == resource.getTracker())
+ if (active.get(j) == resource.getTracker())
activeCount++;
// try to spread out the downloads so that a slow host
@@ -947,7 +950,7 @@ public class ResourceTracker {
private Resource getResource(URL location) {
synchronized (resources) {
for (int i=0; i < resources.size(); i++) {
- Resource resource = (Resource) resources.get(i);
+ Resource resource = resources.get(i);
if (CacheUtil.urlEquals(resource.location, location))
return resource;