Class Parser

java.lang.Object
net.sourceforge.jnlp.Parser

public final class Parser extends Object
Contains methods to parse an XML document into a JNLPFile. Implements JNLP specification version 1.0.
Version:
$Revision: 1.13 $
Author:
Jon A. Maxwell (JAM) - initial author
  • Constructor Details

    • Parser

      public Parser(JNLPFile file, URL base, XmlNode root, ParserSettings settings) throws ParseException
      Create a parser for the JNLP file. If the location parameters is not null it is used as the default codebase (does not override value of jnlp element's href attribute).

      The root node may be normalized as a side effect of this constructor.

      Parameters:
      file - the (uninitialized) file reference
      base - if codebase is not specified, a default base for relative URLs
      root - the root node
      settings - the parser settings to use when parsing the JNLP file
      Throws:
      ParseException - if the JNLP file is invalid
    • Parser

      public Parser(JNLPFile file, URL base, XmlNode root, ParserSettings settings, URL codebase) throws ParseException
      Create a parser for the JNLP file. If the location parameters is not null it is used as the default codebase (does not override value of jnlp element's href attribute).

      The root node may be normalized as a side effect of this constructor.

      Parameters:
      file - the (uninitialized) file reference
      base - if codebase is not specified, a default base for relative URLs
      root - the root node
      settings - the parser settings to use when parsing the JNLP file
      codebase - codebase to use if we did not parse one from JNLP file.
      Throws:
      ParseException - if the JNLP file is invalid
  • Method Details

    • getFileVersion

      public VersionId getFileVersion()
      Returns the version of the application being launched, as well as the version of the JNLP file itself.
      Returns:
      version of file
    • getFileLocation

      public URL getFileLocation()
      Returns the file location.
      Returns:
      url of source file
    • getCodeBase

      public URL getCodeBase()
      Returns:
      the codebase.
    • getSpecVersion

      public VersionString getSpecVersion()
      Returns the versions of the specification that this JNLP file requires. The value of the attribute is specified as a version string, see JSR-56, section 3.1
      Returns:
      the specification version.
    • getResources

      public List<ResourcesDesc> getResources(XmlNode parent, boolean j2se) throws ParseException
      Parameters:
      parent - the parent node (either jnlp or j2se)
      j2se - true if the resources are located under a j2se or java node
      Returns:
      all of the ResourcesDesc elements under the specified node (jnlp or j2se).
      Throws:
      ParseException - if the JNLP file is invalid
    • getInformationDescs

      public List<InformationDesc> getInformationDescs(XmlNode parent) throws ParseException
      Search through the information elements in the order specified in the JNLP file (resp. the specified node).

      For each information element, it checks if the value specified in the locale attribute matches the current locale. If a match is found, the values specified in that information element will be used, possibly overriding values found in previous information elements. Thus, the locale-independent information needs only to be specified once, in the information element without the locale attribute.

      Parameters:
      parent - the parent node containing the information elements in the order specified in the JNLP file
      Returns:
      all of the information elements under the specified node.
      Throws:
      ParseException - if the JNLP file is invalid
    • addInfo

      protected void addInfo(InformationDesc info, XmlNode node, String mod, Object value)
      Adds a key,value pair to the information object.
      Parameters:
      info - the information object
      node - node name to be used as the key
      mod - key name appended with "-"+mod if not null
      value - the info object to add (icon or string)
    • getSecurity

      public SecurityDesc getSecurity(XmlNode parent) throws ParseException
      Parameters:
      parent - the parent node
      Returns:
      the security descriptor element. If no security element was specified in the JNLP file then a SecurityDesc with applet permissions is returned.
      Throws:
      ParseException - if the JNLP file is invalid
    • getEntryPointDesc

      public EntryPoint getEntryPointDesc(XmlNode parent) throws ParseException
      Load the entry point descriptor element.
      Parameters:
      parent - the parent node
      Returns:
      the entry point descriptor element, never null
      Throws:
      ParseException - if the JNLP file is invalid
      See Also: