aboutsummaryrefslogtreecommitdiffstats
path: root/netx
diff options
context:
space:
mode:
Diffstat (limited to 'netx')
-rw-r--r--netx/net/sourceforge/jnlp/JNLPFile.java4
-rw-r--r--netx/net/sourceforge/jnlp/PluginBridge.java4
-rw-r--r--netx/net/sourceforge/jnlp/ResourcesDesc.java17
-rw-r--r--netx/net/sourceforge/jnlp/cache/CacheUtil.java31
-rw-r--r--netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java8
-rw-r--r--netx/net/sourceforge/jnlp/cache/Resource.java3
-rw-r--r--netx/net/sourceforge/jnlp/cache/ResourceTracker.java37
-rw-r--r--netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java4
-rw-r--r--netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java7
9 files changed, 56 insertions, 59 deletions
diff --git a/netx/net/sourceforge/jnlp/JNLPFile.java b/netx/net/sourceforge/jnlp/JNLPFile.java
index 5ddb989..41354d3 100644
--- a/netx/net/sourceforge/jnlp/JNLPFile.java
+++ b/netx/net/sourceforge/jnlp/JNLPFile.java
@@ -396,9 +396,7 @@ public class JNLPFile {
public <T> List<T> getResources(Class<T> launchType) {
List<T> result = new ArrayList<T>();
- for (int i = 0; i < resources.size(); i++) {
- ResourcesDesc rescDesc = resources.get(i);
-
+ for (ResourcesDesc rescDesc : resources) {
if (localMatches(locale, rescDesc.getLocales())
&& stringMatches(os, rescDesc.getOS())
&& stringMatches(arch, rescDesc.getArch()))
diff --git a/netx/net/sourceforge/jnlp/PluginBridge.java b/netx/net/sourceforge/jnlp/PluginBridge.java
index 2146e64..273b213 100644
--- a/netx/net/sourceforge/jnlp/PluginBridge.java
+++ b/netx/net/sourceforge/jnlp/PluginBridge.java
@@ -204,9 +204,7 @@ public class PluginBridge extends JNLPFile {
List<JARDesc> jarDescs = new ArrayList<JARDesc>();
jarDescs.addAll(sharedResources.getResources(JARDesc.class));
- Iterator<String> it = jars.iterator();
- while(it.hasNext()) {
- String name = it.next();
+ for (String name : jars) {
if (name.length() > 0)
jarDescs.add(new JARDesc(new URL(codeBase, name),
null, null, false, true, false, true));
diff --git a/netx/net/sourceforge/jnlp/ResourcesDesc.java b/netx/net/sourceforge/jnlp/ResourcesDesc.java
index 4c861b5..42eec01 100644
--- a/netx/net/sourceforge/jnlp/ResourcesDesc.java
+++ b/netx/net/sourceforge/jnlp/ResourcesDesc.java
@@ -75,9 +75,10 @@ public class ResourcesDesc {
public JARDesc getMainJAR() {
JARDesc jars[] = getJARs();
- for (int i = 0; i < jars.length; i++)
- if (jars[i].isMain())
- return jars[i];
+ for (JARDesc jar : jars) {
+ if (jar.isMain())
+ return jar;
+ }
if (jars.length > 0)
return jars[0];
@@ -160,8 +161,7 @@ public class ResourcesDesc {
public Map<String, String> getPropertiesMap() {
Map<String, String> properties = new HashMap<String, String>();
List<PropertyDesc> resources = getResources(PropertyDesc.class);
- for (int i = 0; i < resources.size(); i++) {
- PropertyDesc prop = resources.get(i);
+ for (PropertyDesc prop : resources) {
properties.put(prop.getKey(), prop.getValue());
}
@@ -205,9 +205,10 @@ public class ResourcesDesc {
public <T> List<T> getResources(Class<T> type) {
List<T> result = new ArrayList<T>();
- for (int i = 0; i < resources.size(); i++)
- if (type.isAssignableFrom(resources.get(i).getClass()))
- result.add(type.cast(resources.get(i)));
+ for (Object resource : resources) {
+ if (type.isAssignableFrom(resource.getClass()))
+ result.add(type.cast(resource));
+ }
return result;
}
diff --git a/netx/net/sourceforge/jnlp/cache/CacheUtil.java b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
index ec65094..b918625 100644
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java
+++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java
@@ -500,9 +500,9 @@ public class CacheUtil {
// only resources not starting out downloaded are displayed
List<URL> urlList = new ArrayList<URL>();
- for (int i = 0; i < resources.length; i++) {
- if (!tracker.checkResource(resources[i]))
- urlList.add(resources[i]);
+ for (URL url : resources) {
+ if (!tracker.checkResource(url))
+ urlList.add(url);
}
URL undownloaded[] = urlList.toArray(new URL[urlList.size()]);
@@ -512,28 +512,29 @@ public class CacheUtil {
long read = 0;
long total = 0;
- for (int i = 0; i < undownloaded.length; i++) {
+ for (URL url : undownloaded) {
// add in any -1's; they're insignificant
- total += tracker.getTotalSize(undownloaded[i]);
- read += tracker.getAmountRead(undownloaded[i]);
+ total += tracker.getTotalSize(url);
+ read += tracker.getAmountRead(url);
}
int percent = (int) ((100 * read) / Math.max(1, total));
- for (int i = 0; i < undownloaded.length; i++)
- listener.progress(undownloaded[i], "version",
- tracker.getAmountRead(undownloaded[i]),
- tracker.getTotalSize(undownloaded[i]),
+ for (URL url : undownloaded) {
+ listener.progress(url, "version",
+ tracker.getAmountRead(url),
+ tracker.getTotalSize(url),
percent);
+ }
} while (!tracker.waitForResources(resources, indicator.getUpdateRate()));
// make sure they read 100% until indicator closes
- for (int i = 0; i < undownloaded.length; i++)
- listener.progress(undownloaded[i], "version",
- tracker.getTotalSize(undownloaded[i]),
- tracker.getTotalSize(undownloaded[i]),
+ for (URL url : undownloaded) {
+ listener.progress(url, "version",
+ tracker.getTotalSize(url),
+ tracker.getTotalSize(url),
100);
-
+ }
} catch (InterruptedException ex) {
if (JNLPRuntime.isDebug())
ex.printStackTrace();
diff --git a/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java b/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
index 8710a6a..915a9ff 100644
--- a/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
+++ b/netx/net/sourceforge/jnlp/cache/DefaultDownloadIndicator.java
@@ -106,9 +106,11 @@ public class DefaultDownloadIndicator implements DownloadIndicator {
frame.getContentPane().setLayout(new GridBagLayout());
}
- if (resources != null)
- for (int i = 0; i < resources.length; i++)
- result.addProgressPanel(resources[i], null);
+ if (resources != null) {
+ for (URL url : resources) {
+ result.addProgressPanel(url, null);
+ }
+ }
frame.getContentPane().add(result, vertical);
frame.pack();
diff --git a/netx/net/sourceforge/jnlp/cache/Resource.java b/netx/net/sourceforge/jnlp/cache/Resource.java
index 1c4cb0f..00d411b 100644
--- a/netx/net/sourceforge/jnlp/cache/Resource.java
+++ b/netx/net/sourceforge/jnlp/cache/Resource.java
@@ -272,8 +272,7 @@ public class Resource {
send = trackers.hardList();
}
- for (int i = 0; i < send.size(); i++) {
- ResourceTracker rt = send.get(i);
+ for (ResourceTracker rt : send) {
rt.fireDownloadEvent(this);
}
}
diff --git a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
index bc46947..0050757 100644
--- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
+++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java
@@ -331,13 +331,13 @@ public class ResourceTracker {
}
DownloadEvent event = new DownloadEvent(this, resource);
- for (int i = 0; i < l.length; i++) {
+ for (DownloadListener dl : l) {
if (0 != ((ERROR | DOWNLOADED) & status))
- l[i].downloadCompleted(event);
+ dl.downloadCompleted(event);
else if (0 != (DOWNLOADING & status))
- l[i].downloadStarted(event);
+ dl.downloadStarted(event);
else if (0 != (CONNECTING & status))
- l[i].updateStarted(event);
+ dl.updateStarted(event);
}
}
@@ -449,8 +449,9 @@ public class ResourceTracker {
synchronized (resources) {
// keep the lock so getResource doesn't have to aquire it each time
- for (int i = 0; i < urls.length; i++)
+ for (int i = 0; i < urls.length; i++) {
resources[i] = getResource(urls[i]);
+ }
}
if (resources.length > 0)
@@ -868,8 +869,7 @@ public class ResourceTracker {
resource.toString() + " : " + urls);
}
URL bestUrl = null;
- for (int i = 0; i < urls.size(); i++) {
- URL url = urls.get(i);
+ for (URL url : urls) {
try {
URLConnection connection = url.openConnection();
connection.addRequestProperty("Accept-Encoding", "pack200-gzip, gzip");
@@ -999,8 +999,7 @@ public class ResourceTracker {
Resource result = null;
int score = Integer.MAX_VALUE;
- for (int i = 0; i < source.size(); i++) {
- Resource resource = source.get(i);
+ for (Resource resource : source) {
boolean selectable = false;
synchronized (resource) {
@@ -1011,9 +1010,10 @@ public class ResourceTracker {
if (selectable) {
int activeCount = 0;
- for (int j = 0; j < active.size(); j++)
- if (active.get(j) == resource.getTracker())
+ for (ResourceTracker rt : active) {
+ if (rt == resource.getTracker())
activeCount++;
+ }
// try to spread out the downloads so that a slow host
// won't monopolize the downloads
@@ -1034,9 +1034,7 @@ public class ResourceTracker {
*/
private Resource getResource(URL location) {
synchronized (resources) {
- for (int i = 0; i < resources.size(); i++) {
- Resource resource = resources.get(i);
-
+ for (Resource resource : resources) {
if (CacheUtil.urlEquals(resource.location, location))
return resource;
}
@@ -1058,8 +1056,9 @@ public class ResourceTracker {
long startTime = System.currentTimeMillis();
// start them downloading / connecting in background
- for (int i = 0; i < resources.length; i++)
- startResource(resources[i]);
+ for (Resource resource : resources) {
+ startResource(resource);
+ }
// wait for completion
while (true) {
@@ -1067,11 +1066,11 @@ public class ResourceTracker {
synchronized (lock) {
// check for completion
- for (int i = 0; i < resources.length; i++) {
+ for (Resource resource : resources) {
//NetX Deadlocking may be solved by removing this
//synch block.
- synchronized (resources[i]) {
- if (!resources[i].isSet(DOWNLOADED | ERROR)) {
+ synchronized (resource) {
+ if (!resource.isSet(DOWNLOADED | ERROR)) {
finished = false;
break;
}
diff --git a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java
index 321e18e..03ab465 100644
--- a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java
+++ b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java
@@ -116,8 +116,8 @@ public class AppletEnvironment implements AppletContext, AppletStub {
destroyed = true;
List<AppletAudioClip> clips = weakClips.hardList();
- for (int i = 0; i < clips.size(); i++) {
- clips.get(i).dispose();
+ for (AppletAudioClip clip : clips) {
+ clip.dispose();
}
}
diff --git a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
index 320228a..fc7c1b7 100644
--- a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
+++ b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
@@ -231,8 +231,8 @@ public class ApplicationInstance {
PrivilegedAction<Object> installProps = new PrivilegedAction<Object>() {
public Object run() {
- for (int i = 0; i < props.length; i++) {
- System.setProperty(props[i].getKey(), props[i].getValue());
+ for (PropertyDesc propDesc : props) {
+ System.setProperty(propDesc.getKey(), propDesc.getValue());
}
return null;
@@ -272,8 +272,7 @@ public class ApplicationInstance {
try {
// destroy resources
- for (int i = 0; i < weakWindows.size(); i++) {
- Window w = weakWindows.get(i);
+ for (Window w : weakWindows) {
if (w != null)
w.dispose();
}