From eae8bd5edfb2300861eb1e646595b27b68293829 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 9 Sep 2013 11:32:36 -0400 Subject: PR1533: Inherit jnlp.packEnabled and jnlp.versionEnabled like other properties Treat jnlp.packEnabled and jnlp.versionEnabled just like other properties that can be set in one resource element and inherited/filtered in others. 2013-09-09 Omair Majid * netx/net/sourceforge/jnlp/JNLPFile.java (getDownloadOptionsForJar): Rename to ... (getDownloadOptions): New method. Look up jnlp.packEnabled and jnlp.versionEnabled in any resources element. * netx/net/sourceforge/jnlp/PluginBridge.java (getDownloadOptionsForJar): Rename to ... (getDownloadOptions): New method. * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java (initializeResources): Invoke file.getDownloadResources. (getDownloadOptionsForJar): Remove. * tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java (testDownloadOptionsAppliedEverywhere): New method. (testDownloadOptionsFilteredOut): New method. --- netx/net/sourceforge/jnlp/JNLPFile.java | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'netx/net/sourceforge/jnlp/JNLPFile.java') diff --git a/netx/net/sourceforge/jnlp/JNLPFile.java b/netx/net/sourceforge/jnlp/JNLPFile.java index f8c953e..a48ed7e 100644 --- a/netx/net/sourceforge/jnlp/JNLPFile.java +++ b/netx/net/sourceforge/jnlp/JNLPFile.java @@ -20,7 +20,6 @@ import static net.sourceforge.jnlp.runtime.Translator.R; import java.io.IOException; import java.io.InputStream; -import java.io.Reader; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; @@ -791,29 +790,17 @@ public class JNLPFile { } /** - * XXX: this method does a "==" comparison between the input JARDesc and - * jars it finds through getResourcesDescs(). If ever the implementation - * of that function should change to return copies of JARDescs objects, - * then the "jar == aJar" comparison below should change accordingly. - * @param jar the jar whose download options to get. - * @return the download options. + * @return the download options to use for downloading jars listed in this jnlp file. */ - public DownloadOptions getDownloadOptionsForJar(JARDesc jar) { + public DownloadOptions getDownloadOptions() { boolean usePack = false; boolean useVersion = false; - ResourcesDesc[] descs = getResourcesDescs(); - for (ResourcesDesc desc: descs) { - JARDesc[] jars = desc.getJARs(); - for (JARDesc aJar: jars) { - if (jar == aJar) { - if (Boolean.valueOf(desc.getPropertiesMap().get("jnlp.packEnabled"))) { - usePack = true; - } - if (Boolean.valueOf(desc.getPropertiesMap().get("jnlp.versionEnabled"))) { - useVersion = true; - } - } - } + ResourcesDesc desc = getResources(); + if (Boolean.valueOf(desc.getPropertiesMap().get("jnlp.packEnabled"))) { + usePack = true; + } + if (Boolean.valueOf(desc.getPropertiesMap().get("jnlp.versionEnabled"))) { + useVersion = true; } return new DownloadOptions(usePack, useVersion); } -- cgit v1.2.3