class Parser
extends java.lang.Object
Constructor and Description |
---|
Parser(JNLPFile file,
java.net.URL base,
Node root,
boolean strict,
boolean allowExtensions)
Create a parser for the JNLP file.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addInfo(InformationDesc info,
Node node,
java.lang.String mod,
java.lang.Object value)
Adds a key,value pair to the information object.
|
AppletDesc |
getApplet(Node node)
Returns the applet descriptor.
|
ApplicationDesc |
getApplication(Node node)
Returns the application descriptor.
|
java.lang.String |
getAttribute(Node node,
java.lang.String name,
java.lang.String defaultValue)
Retuns an attribute or the specified defaultValue if there is
no such attribute.
|
static Node |
getChildNode(Node node,
java.lang.String name)
Returns the first child node with the specified name.
|
static Node[] |
getChildNodes(Node node,
java.lang.String name)
Returns all child nodes with the specified name.
|
java.net.URL |
getCodeBase()
Returns the codebase.
|
ComponentDesc |
getComponent(Node node)
Returns the component descriptor.
|
ExtensionDesc |
getExtension(Node node)
Returns the Extension element at the specified node.
|
java.net.URL |
getFileLocation()
Returns the file location.
|
Version |
getFileVersion()
Returns the file version.
|
IconDesc |
getIcon(Node node)
Returns the icon element at the specified node.
|
java.util.List |
getInfo(Node parent)
Returns all of the information elements under the specified
node.
|
InformationDesc |
getInformationDesc(Node node)
Returns the information element at the specified node.
|
InstallerDesc |
getInstaller(Node node)
Returns the installer descriptor.
|
JARDesc |
getJAR(Node node)
Returns the JAR element at the specified node.
|
JREDesc |
getJRE(Node node)
Returns the JRE element at the specified node.
|
java.lang.Object |
getLauncher(Node parent)
Returns the launch descriptor element, either AppletDesc,
ApplicationDesc, ComponentDesc, or InstallerDesc.
|
java.util.Locale |
getLocale(java.lang.String localeStr)
Returns a Locale from a single locale.
|
java.util.Locale[] |
getLocales(Node node)
Returns the Locale object(s) from a node's locale attribute.
|
PackageDesc |
getPackage(Node node)
Returns the Package element at the specified node.
|
PropertyDesc |
getProperty(Node node)
Returns the Property element at the specified node.
|
java.lang.String |
getRequiredAttribute(Node node,
java.lang.String name,
java.lang.String defaultValue)
Returns the same result as getAttribute except that if strict
mode is enabled or the default value is null a parse
exception is thrown instead of returning the default value.
|
java.net.URL |
getRequiredURL(Node node,
java.lang.String name,
java.net.URL base)
Returns the same result as getURL except that a
ParseException is thrown if the attribute is null or empty.
|
java.util.List |
getResources(Node parent,
boolean j2se)
Returns all of the ResourcesDesc elements under the specified
node (jnlp or j2se).
|
ResourcesDesc |
getResourcesDesc(Node node,
boolean j2se)
Returns the ResourcesDesc element at the specified node.
|
static Node |
getRootNode(java.io.InputStream input)
Return the root node from the XML document in the specified
input stream.
|
SecurityDesc |
getSecurity(Node parent)
Returns the security descriptor element.
|
java.lang.String |
getSpanText(Node node)
Returns the implied text under a node, for example "text" in
"
|
Version |
getSpecVersion()
Returns the specification version.
|
static Version |
getSupportedVersions()
Return the JNLP specification versions supported.
|
java.net.URL |
getURL(Node node,
java.lang.String name,
java.net.URL base)
Returns a URL object from a href string relative to the
code base.
|
Version |
getVersion(Node node,
java.lang.String name,
java.lang.String defaultValue)
Returns a Version from the specified attribute and default
value.
|
protected boolean |
isTrustedEnvironment()
Returns whether the JNLP file requests a trusted execution
environment.
|
java.lang.String[] |
splitString(java.lang.String source)
Returns an array of substrings seperated by spaces (spaces
escaped with backslash do not separate strings).
|
public Parser(JNLPFile file, java.net.URL base, Node root, boolean strict, boolean allowExtensions) throws ParseException
The root node may be normalized as a side effect of this constructor.
file
- the (uninitialized) file referencebase
- if codebase is not specified, a default base for relative URLsroot
- the root nodestrict
- whether to enforce strict compliance with the JNLP specallowExtensions
- whether to allow extensions to the JNLP specParseException
- if the JNLP file is invalidpublic static Version getSupportedVersions()
public Version getFileVersion()
public java.net.URL getFileLocation()
public java.net.URL getCodeBase()
public Version getSpecVersion()
public java.util.List getResources(Node parent, boolean j2se) throws ParseException
parent
- the parent node (either jnlp or j2se)j2se
- true if the resources are located under a j2se nodeParseException
- if the JNLP file is invalidpublic ResourcesDesc getResourcesDesc(Node node, boolean j2se) throws ParseException
node
- the resources nodej2se
- true if the resources are located under a j2se nodeParseException
- if the JNLP file is invalidpublic JREDesc getJRE(Node node) throws ParseException
node
- the j2se nodeParseException
- if the JNLP file is invalidpublic JARDesc getJAR(Node node) throws ParseException
node
- the jar or nativelib nodeParseException
- if the JNLP file is invalidpublic ExtensionDesc getExtension(Node node) throws ParseException
node
- the extension nodeParseException
- if the JNLP file is invalidpublic PropertyDesc getProperty(Node node) throws ParseException
node
- the property nodeParseException
- if the JNLP file is invalidpublic PackageDesc getPackage(Node node) throws ParseException
node
- the package nodeParseException
- if the JNLP file is invalidpublic java.util.List getInfo(Node parent) throws ParseException
parent
- the parent node (jnlp)ParseException
- if the JNLP file is invalidpublic InformationDesc getInformationDesc(Node node) throws ParseException
node
- the information nodeParseException
- if the JNLP file is invalidprotected void addInfo(InformationDesc info, Node node, java.lang.String mod, java.lang.Object value)
info
- the information objectnode
- node name to be used as the keymod
- key name appended with "-"+mod if not nullvalue
- the info object to add (icon or string)public IconDesc getIcon(Node node) throws ParseException
node
- the icon nodeParseException
- if the JNLP file is invalidpublic SecurityDesc getSecurity(Node parent) throws ParseException
parent
- the parent nodeParseException
- if the JNLP file is invalidprotected boolean isTrustedEnvironment()
public java.lang.Object getLauncher(Node parent) throws ParseException
parent
- the parent nodeParseException
- if the JNLP file is invalidpublic AppletDesc getApplet(Node node) throws ParseException
ParseException
- if the JNLP file is invalidpublic ApplicationDesc getApplication(Node node) throws ParseException
ParseException
- if the JNLP file is invalidpublic ComponentDesc getComponent(Node node)
public InstallerDesc getInstaller(Node node)
public java.lang.String[] splitString(java.lang.String source)
public java.util.Locale[] getLocales(Node node)
node
- the node with a locale attributepublic java.util.Locale getLocale(java.lang.String localeStr)
locale
- the locale stringpublic java.lang.String getSpanText(Node node) throws ParseException
node
- the node with text under itParseException
- if the JNLP file is invalidpublic static Node getChildNode(Node node, java.lang.String name)
public static Node[] getChildNodes(Node node, java.lang.String name)
public java.net.URL getRequiredURL(Node node, java.lang.String name, java.net.URL base) throws ParseException
node
- the nodename
- the attribute containing an hrefbase
- the base URLParseException
- if the JNLP file is invalidpublic java.net.URL getURL(Node node, java.lang.String name, java.net.URL base) throws ParseException
node
- the nodename
- the attribute containing an hrefbase
- the base URLParseException
- if the JNLP file is invalidpublic Version getVersion(Node node, java.lang.String name, java.lang.String defaultValue)
node
- the nodename
- the attributedefaultValue
- default if no such attributepublic java.lang.String getRequiredAttribute(Node node, java.lang.String name, java.lang.String defaultValue) throws ParseException
node
- the nodename
- the attributedefaultValue
- default valueParseException
- if the attribute does not exist or is emptypublic java.lang.String getAttribute(Node node, java.lang.String name, java.lang.String defaultValue)
node
- the nodename
- the attributedefaultValue
- default if no such attributepublic static Node getRootNode(java.io.InputStream input) throws ParseException
ParseException
- if the JNLP file is invalid