Parser (IcedTea-Web: NetX )
Keywords: net.sourceforge.jnlp.Parser class
Date: 2021-05-10

net.sourceforge.jnlp

## Class Parser

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

-     public final class Parser
      extends java.lang.Object

  Contains methods to parse an XML document into a JNLPFile. Implements JNLP specification version 1.0.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `MALFORMED_PARSER_CLASS`
    `static java.lang.String` | `NORMAL_PARSER_CLASS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Parser(JNLPFile file, java.net.URL base, Node root, ParserSettings settings)` Create a parser for the JNLP file.
    `Parser(JNLPFile file, java.net.URL base, Node root, ParserSettings settings, java.net.URL codebase)` Create a parser for the JNLP file.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    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.
    `java.net.URL` | `getCodeBase()`
    `java.net.URL` | `getFileLocation()` Returns the file location.
    `Version` | `getFileVersion()` Returns the file version.
    `java.util.List<InformationDesc>` | `getInfo(Node parent)`
    `LaunchDesc` | `getLauncher(Node parent)`
    `java.util.Locale` | `getLocale(java.lang.String localeStr)` Returns a `Locale` from a single locale.
    `static java.lang.Object` | `getParserInstance(ParserSettings settings)`
    `java.util.List<ResourcesDesc>` | `getResources(Node parent, boolean j2se)`
    `static Node` | `getRootNode(java.io.InputStream input, ParserSettings settings)`
    `SecurityDesc` | `getSecurity(Node parent)`
    `Version` | `getSpecVersion()`
    `java.net.URL` | `getURL(Node node, java.lang.String name, java.net.URL base)`
    `static java.net.URL` | `getURL(java.lang.String href, java.lang.String nodeName, java.net.URL base, boolean strict)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MALFORMED_PARSER_CLASS

          public static final java.lang.String MALFORMED_PARSER_CLASS

      See Also:
        Constant Field Values

    - #### NORMAL_PARSER_CLASS

          public static final java.lang.String NORMAL_PARSER_CLASS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Parser

          public Parser(JNLPFile file,
                        java.net.URL base,
                        Node 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,
                        java.net.URL base,
                        Node root,
                        ParserSettings settings,
                        java.net.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 Detail

    - #### getFileVersion

          public Version getFileVersion()

      Returns the file version.
      Returns:
        version of file

    - #### getFileLocation

          public java.net.URL getFileLocation()

      Returns the file location.
      Returns:
        url of source file

    - #### getCodeBase

          public java.net.URL getCodeBase()

      Returns:
        the codebase.

    - #### getSpecVersion

          public Version getSpecVersion()

      Returns:
        the specification version.

    - #### getResources

          public java.util.List<ResourcesDesc> getResources(Node 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

    - #### getInfo

          public java.util.List<InformationDesc> getInfo(Node parent)
                                                  throws ParseException

      Parameters:
        `parent` - the parent node (jnlp)
      Returns:
        all of the information elements under the specified node.
      Throws:
        `ParseException` - if the JNLP file is invalid

    - #### addInfo

          protected void addInfo(InformationDesc info,
                                 Node node,
                                 java.lang.String mod,
                                 java.lang.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(Node 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

    - #### getLauncher

          public LaunchDesc getLauncher(Node parent)
                                 throws ParseException

      Parameters:
        `parent` - the parent node
      Returns:
        the launch descriptor element, either AppletDesc, ApplicationDesc, or InstallerDesc.
      Throws:
        `ParseException` - if the JNLP file is invalid

    - #### getLocale

          public java.util.Locale getLocale(java.lang.String localeStr)

      Returns a `Locale` from a single locale.
      Parameters:
        `localeStr` - the locale string
      Returns:
        locale of document

    - #### getURL

          public java.net.URL getURL(Node node,
                                     java.lang.String name,
                                     java.net.URL base)
                              throws ParseException

      Parameters:
        `node` - the node
        `name` - the attribute containing an href
        `base` - the base URL
      Returns:
        a URL object from a href string relative to the code base. If the href denotes a relative URL, it must reference a location that is a subdirectory of the codebase.
      Throws:
        `ParseException` - if the JNLP file is invalid

    - #### getURL

          public static java.net.URL getURL(java.lang.String href,
                                            java.lang.String nodeName,
                                            java.net.URL base,
                                            boolean strict)
                                     throws ParseException

      Throws:
        `ParseException`

    - #### getRootNode

          public static Node getRootNode(java.io.InputStream input,
                                         ParserSettings settings)
                                  throws ParseException

      Returns:
        the root node from the XML document in the specified input stream.
      Throws:
        `ParseException` - if the JNLP file is invalid

    - #### getParserInstance

          public static java.lang.Object getParserInstance(ParserSettings settings)
                                                    throws java.lang.ClassNotFoundException,
                                                           java.lang.IllegalAccessException,
                                                           java.lang.InstantiationException

      Throws:
        `java.lang.ClassNotFoundException`
        `java.lang.IllegalAccessException`
        `java.lang.InstantiationException`

Submit a bug or feature