net.sourceforge.jnlp

## Class JNLPFile

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

- Direct Known Subclasses:
    PluginBridge

      public class JNLPFile
      extends java.lang.Object

  Provides methods to access the information in a Java Network Launching Protocol (JNLP) file. The Java Network Launching Protocol specifies in an XML file the information needed to load, cache, and run Java code over the network and in a secure environment.

  This class represents the overall information about a JNLP file from the jnlp element. Other information is accessed through objects that represent the elements of a JNLP file (information, resources, application-desc, etc). References to these objects are obtained by calling the getInformation, getResources, getSecurity, etc methods.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `JNLPFile.ManifestBoolean`
    `class` | `JNLPFile.ManifestsAttributes`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.net.URL` | `codeBase` the URL used to resolve relative URLs in the file
    `protected ComponentDesc` | `component` the component description
    `protected java.lang.String` | `defaultArch` the default arch
    `protected java.util.Locale` | `defaultLocale` the default JVM locale
    `protected java.lang.String` | `defaultOS` the default OS
    `protected java.net.URL` | `fileLocation` the network location of this JNLP file
    `protected Version` | `fileVersion` file version
    `protected java.util.List<InformationDesc>` | `info` information
    `protected LaunchDesc` | `launchType` the application description
    `protected ParserSettings` | `parserSettings` the ParserSettings which were used to parse this file
    `protected java.util.List<ResourcesDesc>` | `resources` resources
    `protected SecurityDesc` | `security` the security descriptor
    `protected ResourcesDesc` | `sharedResources` additional resources not in JNLP file (from command line)
    `protected java.net.URL` | `sourceLocation` the location this JNLP file was created from
    `protected Version` | `specVersion` spec version
    `static java.lang.String` | `TITLE_NOT_FOUND`
    `protected java.lang.String` | `uniqueKey` A key that uniquely identifies connected instances (main jnlp+ext)
    `protected UpdateDesc` | `update`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `JNLPFile()` Empty stub, allowing child classes to override the constructor
    `` | `JNLPFile(java.io.InputStream input, ParserSettings settings)` Create a JNLPFile from an input stream.
    `` | `JNLPFile(java.io.InputStream input, java.net.URL codebase, ParserSettings settings)` Create a JNLPFile from an input stream.
    `` | `JNLPFile(java.net.URL location)` Create a JNLPFile from a URL.
    `` | `JNLPFile(java.net.URL location, ParserSettings settings)` Create a JNLPFile from a URL checking for updates using the default policy.
    `` | `JNLPFile(java.net.URL location, java.lang.String uniqueKey, Version version, ParserSettings settings, UpdatePolicy policy)` Create a JNLPFile from a URL, parent URLm a version and checking for updates using the specified policy.
    `` | `JNLPFile(java.net.URL location, Version version, ParserSettings settings)` Create a JNLPFile from a URL and a Version checking for updates using the default policy.
    `` | `JNLPFile(java.net.URL location, Version version, ParserSettings settings, UpdatePolicy policy)` Create a JNLPFile from a URL and a version, checking for updates using the specified policy.
    `protected` | `JNLPFile(java.net.URL location, Version version, ParserSettings settings, UpdatePolicy policy, java.net.URL forceCodebase)` Create a JNLPFile from a URL and a version, checking for updates using the specified policy.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `createJnlpTitle()`
    `java.lang.String` | `createJnlpTitleValue()`
    `java.lang.String` | `createJnlpVendor()`
    `java.lang.String` | `createJnlpVendorValue()`
    `AppletDesc` | `getApplet()`
    `ApplicationDesc` | `getApplication()`
    `java.net.URL` | `getCodeBase()`
    `ComponentDesc` | `getComponent()`
    `DownloadOptions` | `getDownloadOptions()`
    `java.net.URL` | `getFileLocation()`
    `Version` | `getFileVersion()`
    `InformationDesc` | `getInformation()`
    `InformationDesc` | `getInformation(java.util.Locale locale)`
    `InstallerDesc` | `getInstaller()`
    `LaunchDesc` | `getLaunchInfo()`
    `JNLPFile.ManifestsAttributes` | `getManifestsAttributes()`
    `java.util.List<java.lang.String>` | `getNewVMArgs()`
    `java.net.URL` | `getNotNullProbalbeCodeBase()` It is not recommended to use this method for internals of itw - use normal getCodeBase rather, as null is expected always except toString calls.
    `ParserSettings` | `getParserSettings()`
    `SecurityDesc.RequestedPermissionLevel` | `getRequestedPermissionLevel()`
    `ResourcesDesc` | `getResources()`
    `ResourcesDesc` | `getResources(java.util.Locale locale, java.lang.String os, java.lang.String arch)`
    `ResourcesDesc[]` | `getResourcesDescs()`
    `ResourcesDesc[]` | `getResourcesDescs(java.util.Locale locale, java.lang.String os, java.lang.String arch)`
    `SecurityDesc` | `getSecurity()`
    `java.net.URL` | `getSourceLocation()`
    `Version` | `getSpecVersion()`
    `java.lang.String` | `getTitle()`
    `java.lang.String` | `getTitleFromJnlp()`
    `java.lang.String` | `getTitleFromManifest()`
    `java.lang.String` | `getUniqueKey()`
    `UpdateDesc` | `getUpdate()`
    `java.lang.String` | `getVendor()`
    `boolean` | `isApplet()`
    `boolean` | `isApplication()`
    `boolean` | `isComponent()`
    `boolean` | `isInstaller()`
    `boolean` | `localeMatches(java.util.Locale requested, java.util.Locale[] available, net.sourceforge.jnlp.JNLPFile.Match matchLevel)` Returns whether a locale is matched by one of more other locales.
    `boolean` | `needsNewVM()`
    `static java.io.InputStream` | `openURL(java.net.URL location, Version version, UpdatePolicy policy)` Open the jnlp file URL from the cache if there, otherwise download to the cache.
    `boolean` | `requiresSignedJNLPWarning()` Returns a boolean after determining if a signed JNLP warning should be displayed in the 'More Information' panel.
    `void` | `setDefaults(java.lang.String os, java.lang.String arch, java.util.Locale locale)` Sets the default view of the JNLP file returned by getInformation, getResources, etc.
    `void` | `setSignedJNLPAsMissing()` Informs that a signed JNLP file is missing in the main jar

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

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

- - ### Field Detail

    - #### sourceLocation

          protected java.net.URL sourceLocation

      the location this JNLP file was created from

    - #### fileLocation

          protected java.net.URL fileLocation

      the network location of this JNLP file

    - #### parserSettings

          protected ParserSettings parserSettings

      the ParserSettings which were used to parse this file

    - #### uniqueKey

          protected java.lang.String uniqueKey

      A key that uniquely identifies connected instances (main jnlp+ext)

    - #### codeBase

          protected java.net.URL codeBase

      the URL used to resolve relative URLs in the file

    - #### fileVersion

          protected Version fileVersion

      file version

    - #### specVersion

          protected Version specVersion

      spec version

    - #### info

          protected java.util.List<InformationDesc> info

      information

    - #### update

          protected UpdateDesc update

    - #### resources

          protected java.util.List<ResourcesDesc> resources

      resources

    - #### sharedResources

          protected ResourcesDesc sharedResources

      additional resources not in JNLP file (from command line)

    - #### launchType

          protected LaunchDesc launchType

      the application description

    - #### component

          protected ComponentDesc component

      the component description

    - #### security

          protected SecurityDesc security

      the security descriptor

    - #### defaultLocale

          protected java.util.Locale defaultLocale

      the default JVM locale

    - #### defaultOS

          protected java.lang.String defaultOS

      the default OS

    - #### defaultArch

          protected java.lang.String defaultArch

      the default arch

    - #### TITLE_NOT_FOUND

          public static final java.lang.String TITLE_NOT_FOUND

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### JNLPFile

          protected JNLPFile()

      Empty stub, allowing child classes to override the constructor

    - #### JNLPFile

          public JNLPFile(java.net.URL location)
                   throws java.io.IOException,
                          ParseException

      Create a JNLPFile from a URL.
      Parameters:
        `location` - the location of the JNLP file
      Throws:
        `java.io.IOException` - if an IO exception occurred
        `ParseException` - if the JNLP file was invalid

    - #### JNLPFile

          public JNLPFile(java.net.URL location,
                          ParserSettings settings)
                   throws java.io.IOException,
                          ParseException

      Create a JNLPFile from a URL checking for updates using the default policy.
      Parameters:
        `location` - the location of the JNLP file
        `settings` - the parser settings to use while parsing the file
      Throws:
        `java.io.IOException` - if an IO exception occurred
        `ParseException` - if the JNLP file was invalid

    - #### JNLPFile

          public JNLPFile(java.net.URL location,
                          Version version,
                          ParserSettings settings)
                   throws java.io.IOException,
                          ParseException

      Create a JNLPFile from a URL and a Version checking for updates using the default policy.
      Parameters:
        `location` - the location of the JNLP file
        `version` - the version of the JNLP file
        `settings` - the parser settings to use while parsing the file
      Throws:
        `java.io.IOException` - if an IO exception occurred
        `ParseException` - if the JNLP file was invalid

    - #### JNLPFile

          public JNLPFile(java.net.URL location,
                          Version version,
                          ParserSettings settings,
                          UpdatePolicy policy)
                   throws java.io.IOException,
                          ParseException

      Create a JNLPFile from a URL and a version, checking for updates using the specified policy.
      Parameters:
        `location` - the location of the JNLP file
        `version` - the version of the JNLP file
        `settings` - the `ParserSettings` to use when parsing the `location`
        `policy` - the update policy
      Throws:
        `java.io.IOException` - if an IO exception occurred
        `ParseException` - if the JNLP file was invalid

    - #### JNLPFile

          protected JNLPFile(java.net.URL location,
                             Version version,
                             ParserSettings settings,
                             UpdatePolicy policy,
                             java.net.URL forceCodebase)
                      throws java.io.IOException,
                             ParseException

      Create a JNLPFile from a URL and a version, checking for updates using the specified policy.
      Parameters:
        `location` - the location of the JNLP file
        `version` - the version of the JNLP file
        `settings` - the parser settings to use while parsing the file
        `policy` - the update policy
        `forceCodebase` - codebase to use if not specified in JNLP file.
      Throws:
        `java.io.IOException` - if an IO exception occurred
        `ParseException` - if the JNLP file was invalid

    - #### JNLPFile

          public JNLPFile(java.net.URL location,
                          java.lang.String uniqueKey,
                          Version version,
                          ParserSettings settings,
                          UpdatePolicy policy)
                   throws java.io.IOException,
                          ParseException

      Create a JNLPFile from a URL, parent URLm a version and checking for updates using the specified policy.
      Parameters:
        `location` - the location of the JNLP file
        `uniqueKey` - A string that uniquely identifies connected instances
        `version` - the version of the JNLP file
        `settings` - the parser settings to use while parsing the file
        `policy` - the update policy
      Throws:
        `java.io.IOException` - if an IO exception occurred
        `ParseException` - if the JNLP file was invalid

    - #### JNLPFile

          public JNLPFile(java.io.InputStream input,
                          ParserSettings settings)
                   throws ParseException

      Create a JNLPFile from an input stream.
      Parameters:
        `input` - input stream from which create jnlp file
        `settings` - settings of parser
      Throws:
        `ParseException` - if the JNLP file was invalid

    - #### JNLPFile

          public JNLPFile(java.io.InputStream input,
                          java.net.URL codebase,
                          ParserSettings settings)
                   throws ParseException

      Create a JNLPFile from an input stream.
      Parameters:
        `input` - input stream of JNLP file.
        `codebase` - codebase to use if not specified in JNLP file..
        `settings` - the `ParserSettings` to use when parsing
      Throws:
        `ParseException` - if the JNLP file was invalid

  - ### Method Detail

    - #### openURL

          public static java.io.InputStream openURL(java.net.URL location,
                                                    Version version,
                                                    UpdatePolicy policy)
                                             throws java.io.IOException

      Open the jnlp file URL from the cache if there, otherwise download to the cache. Unless file is find in cache, this method blocks until it is downloaded. This is the best way in itw how to download and cache file
      Parameters:
        `location` - of resource to open
        `version` - of resource
        `policy` - update policy of resource
      Returns:
        opened streamfrom given url
      Throws:
        `java.io.IOException` - if something goes wrong

    - #### getTitle

          public java.lang.String getTitle()

      Returns:
        the JNLP file's best localized title. This method returns the same value as InformationDesc.getTitle(). Since jdk7 u45, also manifest title, and mainclass are taken to consideration; See PluginBridge

    - #### getTitleFromJnlp

          public java.lang.String getTitleFromJnlp()

      Returns:
        the JNLP file's best localized title. This method returns the same value as InformationDesc.getTitle().

    - #### getTitleFromManifest

          public java.lang.String getTitleFromManifest()

    - #### getVendor

          public java.lang.String getVendor()

      Returns:
        the JNLP file's best localized vendor. This method returns the same value as InformationDesc.getVendor().

    - #### getSourceLocation

          public java.net.URL getSourceLocation()

      Returns:
        the JNLP file's network location as specified in the JNLP file.

    - #### getFileLocation

          public java.net.URL getFileLocation()

      Returns:
        the location of the file parsed to create the JNLP file, or null if it was not created from a URL.

    - #### getUniqueKey

          public java.lang.String getUniqueKey()

      Returns:
        the location of the parent file if it exists, null otherwise

    - #### getParserSettings

          public ParserSettings getParserSettings()

      Returns:
        the ParserSettings that was used to parse this file

    - #### getFileVersion

          public Version getFileVersion()

      Returns:
        the JNLP file's version.

    - #### getSpecVersion

          public Version getSpecVersion()

      Returns:
        the specification version required by the file.

    - #### getCodeBase

          public java.net.URL getCodeBase()

      Returns:
        the codebase URL for the JNLP file.

    - #### getNotNullProbalbeCodeBase

          public java.net.URL getNotNullProbalbeCodeBase()

      It is not recommended to use this method for internals of itw - use normal getCodeBase rather, as null is expected always except toString calls. If you are not sure, use getCodeBase and chek null as you need. See that this method is used mostly for xtendedAppletSecuriyty dialogs.
      Returns:
        the codebase URL for the JNLP file or url of location of calling file (jnlp, hreffed jnlp, or directly html)

    - #### getInformation

          public InformationDesc getInformation()

      Returns:
        the information section of the JNLP file as viewed through the default locale.

    - #### getInformation

          public InformationDesc getInformation(java.util.Locale locale)

      Parameters:
        `locale` - preferred locale of informations
      Returns:
        the information section of the JNLP file as viewed through the specified locale.

    - #### getUpdate

          public UpdateDesc getUpdate()

      Returns:
        the update section of the JNLP file.

    - #### getSecurity

          public SecurityDesc getSecurity()

      Returns:
        the security section of the JNLP file.

    - #### getRequestedPermissionLevel

          public SecurityDesc.RequestedPermissionLevel getRequestedPermissionLevel()

    - #### getResources

          public ResourcesDesc getResources()

      Returns:
        the resources section of the JNLP file as viewed through the default locale and the os.name and os.arch properties.

    - #### getResources

          public ResourcesDesc getResources(java.util.Locale locale,
                                            java.lang.String os,
                                            java.lang.String arch)

      Parameters:
        `locale` - preferred locale of resource
        `os` - preferred os of resource
        `arch` - preferred arch of resource
      Returns:
        the resources section of the JNLP file for the specified locale, os, and arch.

    - #### getResourcesDescs

          public ResourcesDesc[] getResourcesDescs()

      Returns:
        the resources section of the JNLP file as viewed through the default locale and the os.name and os.arch properties. XXX: Before overriding this method or changing its implementation, read the comment in JNLPFile.getDownloadOptionsForJar(JARDesc).

    - #### getResourcesDescs

          public ResourcesDesc[] getResourcesDescs(java.util.Locale locale,
                                                   java.lang.String os,
                                                   java.lang.String arch)

      Parameters:
        `locale` - preferred locale of resource
        `os` - preferred os of resource
        `arch` - preferred arch of resource
      Returns:
        the resources section of the JNLP file for the specified locale, os, and arch.

    - #### getLaunchInfo

          public LaunchDesc getLaunchInfo()

      Returns:
        an object of one of the following types: AppletDesc, ApplicationDesc and InstallerDesc

    - #### getApplet

          public AppletDesc getApplet()

      Returns:
        the launch information for an applet.
      Throws:
        `java.lang.UnsupportedOperationException` - if there is no applet information

    - #### getApplication

          public ApplicationDesc getApplication()

      Returns:
        the launch information for an application.
      Throws:
        `java.lang.UnsupportedOperationException` - if there is no application information

    - #### getComponent

          public ComponentDesc getComponent()

      Returns:
        the launch information for a component.
      Throws:
        `java.lang.UnsupportedOperationException` - if there is no component information

    - #### getInstaller

          public InstallerDesc getInstaller()

      Returns:
        the launch information for an installer.
      Throws:
        `java.lang.UnsupportedOperationException` - if there is no installer information

    - #### isApplet

          public boolean isApplet()

      Returns:
        whether the lauch descriptor describes an Applet.

    - #### isApplication

          public boolean isApplication()

      Returns:
        whether the lauch descriptor describes an Application.

    - #### isComponent

          public boolean isComponent()

      Returns:
        whether the lauch descriptor describes a Component.

    - #### isInstaller

          public boolean isInstaller()

      Returns:
        whether the lauch descriptor describes an Installer.

    - #### setDefaults

          public void setDefaults(java.lang.String os,
                                  java.lang.String arch,
                                  java.util.Locale locale)

      Sets the default view of the JNLP file returned by getInformation, getResources, etc. If unset, the defaults are the properties os.name, os.arch, and the locale returned by Locale.getDefault().
      Parameters:
        `os` - preferred os of resource
        `arch` - preferred arch of resource
        `locale` - preferred locale of resource

    - #### localeMatches

          public boolean localeMatches(java.util.Locale requested,
                                       java.util.Locale[] available,
                                       net.sourceforge.jnlp.JNLPFile.Match matchLevel)

      Returns whether a locale is matched by one of more other locales. Only the non-empty language, country, and variant codes are compared; for example, a requested locale of Locale("","","") would always return true.
      Parameters:
        `requested` - the requested locale
        `available` - the available locales
        `matchLevel` - the depth with which to match locales.
      Returns:
        `true` if `requested` matches any of `available`, or if `available` is empty or `null`.
      See Also:
        `Locale`, `Match`

    - #### needsNewVM

          public boolean needsNewVM()

      Returns:
        true if the JNLP file specifies things that can only be applied on a new vm (eg: different max heap memory)

    - #### getNewVMArgs

          public java.util.List<java.lang.String> getNewVMArgs()

      Returns:
        a list of args to pass to the new JVM based on this JNLP file

    - #### getDownloadOptions

          public DownloadOptions getDownloadOptions()

      Returns:
        the download options to use for downloading jars listed in this jnlp file.

    - #### requiresSignedJNLPWarning

          public boolean requiresSignedJNLPWarning()

      Returns a boolean after determining if a signed JNLP warning should be displayed in the 'More Information' panel.
      Returns:
        true if a warning should be displayed; otherwise false

    - #### setSignedJNLPAsMissing

          public void setSignedJNLPAsMissing()

      Informs that a signed JNLP file is missing in the main jar

    - #### getManifestsAttributes

          public JNLPFile.ManifestsAttributes getManifestsAttributes()

    - #### createJnlpVendorValue

          public java.lang.String createJnlpVendorValue()

    - #### createJnlpVendor

          public java.lang.String createJnlpVendor()

    - #### createJnlpTitleValue

          public java.lang.String createJnlpTitleValue()

    - #### createJnlpTitle

          public java.lang.String createJnlpTitle()

Submit a bug or feature