aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmair Majid <[email protected]>2010-10-29 17:40:16 -0400
committerOmair Majid <[email protected]>2010-10-29 17:40:16 -0400
commit60189f6316f063f261147d54a73ab819d71426bf (patch)
tree660cb2a54f5b72960cc29bb58459f02d41bb4ec6
parentc18badf11407f45220f65200094438295c846ca5 (diff)
Parse jnlps containing <component-desc> as well as <application-desc> elements
2010-10-29 Omair Majid <[email protected]> * netx/net/sourceforge/jnlp/JNLPFile.java: Add component. (getLaunchInfo): Modify javadoc to indicate that it does not return the ComponentDesc. (getComponent): Return component instead of launchType. (isComponent): Check if component is not null. (parse): Find and set component descriptor. * netx/net/sourceforge/jnlp/Parser.java (getLauncher): Remove all checks for component-desc. Allow having none of application-desc, applet-desc and installer-desc. (getComponent): Check for more than one component-desc element. Read and parse the component-desc.
-rw-r--r--ChangeLog14
-rw-r--r--netx/net/sourceforge/jnlp/JNLPFile.java10
-rw-r--r--netx/net/sourceforge/jnlp/Parser.java26
3 files changed, 40 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 7a347c9..18e147c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2010-10-29 Omair Majid <[email protected]>
+
+ * netx/net/sourceforge/jnlp/JNLPFile.java: Add component.
+ (getLaunchInfo): Modify javadoc to indicate that it does not return
+ the ComponentDesc.
+ (getComponent): Return component instead of launchType.
+ (isComponent): Check if component is not null.
+ (parse): Find and set component descriptor.
+ * netx/net/sourceforge/jnlp/Parser.java
+ (getLauncher): Remove all checks for component-desc. Allow having
+ none of application-desc, applet-desc and installer-desc.
+ (getComponent): Check for more than one component-desc element.
+ Read and parse the component-desc.
+
2010-10-28 Omair Majid <[email protected]>
* netx/net/sourceforge/jnlp/security/SecurityWarningDialog.java
diff --git a/netx/net/sourceforge/jnlp/JNLPFile.java b/netx/net/sourceforge/jnlp/JNLPFile.java
index b0b8065..6ba186f 100644
--- a/netx/net/sourceforge/jnlp/JNLPFile.java
+++ b/netx/net/sourceforge/jnlp/JNLPFile.java
@@ -95,6 +95,9 @@ public class JNLPFile {
/** the application description */
protected Object launchType;
+ /** the component description */
+ protected ComponentDesc component;
+
/** the security descriptor */
protected SecurityDesc security;
@@ -402,7 +405,7 @@ public class JNLPFile {
/**
* Returns an object of one of the following types: AppletDesc,
- * ApplicationDesc, InstallerDesc, and ComponentDesc.
+ * ApplicationDesc and InstallerDesc
*/
public Object getLaunchInfo() {
return launchType;
@@ -441,7 +444,7 @@ public class JNLPFile {
if (!isComponent())
throw new UnsupportedOperationException(R("JNotComponent"));
- return (ComponentDesc) launchType;
+ return component;
}
/**
@@ -474,7 +477,7 @@ public class JNLPFile {
* Returns whether the lauch descriptor describes a Component.
*/
public boolean isComponent() {
- return launchType instanceof ComponentDesc;
+ return component != null;
}
/**
@@ -574,6 +577,7 @@ public class JNLPFile {
update = parser.getUpdate(root);
resources = parser.getResources(root, false); // false == not a j2se/java resources section
launchType = parser.getLauncher(root);
+ component = parser.getComponent(root);
security = parser.getSecurity(root);
}
catch (ParseException ex) {
diff --git a/netx/net/sourceforge/jnlp/Parser.java b/netx/net/sourceforge/jnlp/Parser.java
index 41721e0..c5b7a34 100644
--- a/netx/net/sourceforge/jnlp/Parser.java
+++ b/netx/net/sourceforge/jnlp/Parser.java
@@ -598,16 +598,15 @@ class Parser {
/**
* Returns the launch descriptor element, either AppletDesc,
- * ApplicationDesc, ComponentDesc, or InstallerDesc.
+ * ApplicationDesc, or InstallerDesc.
*
* @param parent the parent node
* @throws ParseException if the JNLP file is invalid
*/
public Object getLauncher(Node parent) throws ParseException {
// check for other than one application type
- if (1 != getChildNodes(parent, "applet-desc").length
+ if (1 < getChildNodes(parent, "applet-desc").length
+ getChildNodes(parent, "application-desc").length
- + getChildNodes(parent, "component-desc").length
+ getChildNodes(parent, "installer-desc").length)
throw new ParseException(R("PTwoDescriptors"));
@@ -619,8 +618,6 @@ class Parser {
return getApplet(child);
if ("application-desc".equals(name))
return getApplication(child);
- if ("component-desc".equals(name))
- return getComponent(child);
if ("installer-desc".equals(name))
return getInstaller(child);
@@ -693,8 +690,23 @@ class Parser {
/**
* Returns the component descriptor.
*/
- public ComponentDesc getComponent(Node node) {
- return new ComponentDesc();
+ public ComponentDesc getComponent(Node parent) throws ParseException {
+
+ if (1 < getChildNodes(parent, "component-desc").length) {
+ throw new ParseException(R("PTwoDescriptors"));
+ }
+
+ Node child = parent.getFirstChild();
+ while (child != null) {
+ String name = child.getNodeName();
+
+ if ("component-desc".equals(name))
+ return new ComponentDesc();
+
+ child = child.getNextSibling();
+ }
+
+ return null;
}
/**