Package net.sourceforge.jnlp
Class JNLPFile
java.lang.Object
net.sourceforge.jnlp.JNLPFile
- Direct Known Subclasses:
PluginBridge
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 ClassesModifier and TypeClassDescriptionstatic enum
class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected URL
the URL used to resolve relative URLs in the fileprotected ComponentDesc
the component descriptionprotected String
the default archprotected Locale
the default JVM localeprotected String
the default OSprotected URL
the network location of this JNLP fileprotected Version
file versionprotected List<InformationDesc>
informationprotected LaunchDesc
the application descriptionprotected ParserSettings
the ParserSettings which were used to parse this fileprotected List<ResourcesDesc>
resourcesprotected SecurityDesc
the security descriptorprotected ResourcesDesc
additional resources not in JNLP file (from command line)protected URL
the location this JNLP file was created fromprotected Version
spec versionstatic final String
protected String
A key that uniquely identifies connected instances (main jnlp+ext)protected UpdateDesc
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
JNLPFile()
Empty stub, allowing child classes to override the constructorJNLPFile
(InputStream input, URL codebase, ParserSettings settings) Create a JNLPFile from an input stream.JNLPFile
(InputStream input, ParserSettings settings) Create a JNLPFile from an input stream.Create a JNLPFile from a URL.JNLPFile
(URL location, 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
(URL location, ParserSettings settings) Create a JNLPFile from a URL checking for updates using the default policy.JNLPFile
(URL location, Version version, ParserSettings settings) Create a JNLPFile from a URL and a Version checking for updates using the default policy.JNLPFile
(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
(URL location, Version version, ParserSettings settings, UpdatePolicy policy, URL forceCodebase) Create a JNLPFile from a URL and a version, checking for updates using the specified policy. -
Method Summary
Modifier and TypeMethodDescriptiongetInformation
(Locale locale) It is not recommended to use this method for internals of itw - use normal getCodeBase rather, as null is expected always except toString calls.getResources
(Locale locale, String os, String arch) getResourcesDescs
(Locale locale, String os, String arch) getTitle()
getTitle
(boolean kill) getVendor
(boolean kill) boolean
isApplet()
boolean
boolean
boolean
boolean
localeMatches
(Locale requested, Locale[] available, net.sourceforge.jnlp.JNLPFile.Match matchLevel) Returns whether a locale is matched by one of more other locales.boolean
static InputStream
openURL
(URL location, Version version, UpdatePolicy policy) Open the jnlp file URL from the cache if there, otherwise download to the cache.boolean
Returns a boolean after determining if a signed JNLP warning should be displayed in the 'More Information' panel.void
setDefaults
(String os, String arch, Locale locale) Sets the default view of the JNLP file returned by getInformation, getResources, etc.void
Informs that a signed JNLP file is missing in the main jar
-
Field Details
-
sourceLocation
the location this JNLP file was created from -
fileLocation
the network location of this JNLP file -
parserSettings
the ParserSettings which were used to parse this file -
uniqueKey
A key that uniquely identifies connected instances (main jnlp+ext) -
codeBase
the URL used to resolve relative URLs in the file -
fileVersion
file version -
specVersion
spec version -
info
information -
update
-
resources
resources -
launchType
the application description -
component
the component description -
security
the security descriptor -
defaultLocale
the default JVM locale -
defaultOS
the default OS -
defaultArch
the default arch -
TITLE_NOT_FOUND
- See Also:
-
-
Constructor Details
-
JNLPFile
protected JNLPFile()Empty stub, allowing child classes to override the constructor -
JNLPFile
Create a JNLPFile from a URL.- Parameters:
location
- the location of the JNLP file- Throws:
IOException
- if an IO exception occurredParseException
- if the JNLP file was invalid
-
JNLPFile
Create a JNLPFile from a URL checking for updates using the default policy.- Parameters:
location
- the location of the JNLP filesettings
- the parser settings to use while parsing the file- Throws:
IOException
- if an IO exception occurredParseException
- if the JNLP file was invalid
-
JNLPFile
public JNLPFile(URL location, Version version, ParserSettings settings) throws 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 fileversion
- the version of the JNLP filesettings
- the parser settings to use while parsing the file- Throws:
IOException
- if an IO exception occurredParseException
- if the JNLP file was invalid
-
JNLPFile
public JNLPFile(URL location, Version version, ParserSettings settings, UpdatePolicy policy) throws 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 fileversion
- the version of the JNLP filesettings
- theParserSettings
to use when parsing thelocation
policy
- the update policy- Throws:
IOException
- if an IO exception occurredParseException
- if the JNLP file was invalid
-
JNLPFile
protected JNLPFile(URL location, Version version, ParserSettings settings, UpdatePolicy policy, URL forceCodebase) throws 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 fileversion
- the version of the JNLP filesettings
- the parser settings to use while parsing the filepolicy
- the update policyforceCodebase
- codebase to use if not specified in JNLP file.- Throws:
IOException
- if an IO exception occurredParseException
- if the JNLP file was invalid
-
JNLPFile
public JNLPFile(URL location, String uniqueKey, Version version, ParserSettings settings, UpdatePolicy policy) throws 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 fileuniqueKey
- A string that uniquely identifies connected instancesversion
- the version of the JNLP filesettings
- the parser settings to use while parsing the filepolicy
- the update policy- Throws:
IOException
- if an IO exception occurredParseException
- if the JNLP file was invalid
-
JNLPFile
Create a JNLPFile from an input stream.- Parameters:
input
- input stream from which create jnlp filesettings
- settings of parser- Throws:
ParseException
- if the JNLP file was invalid
-
JNLPFile
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
- theParserSettings
to use when parsing- Throws:
ParseException
- if the JNLP file was invalid
-
-
Method Details
-
openURL
public static InputStream openURL(URL location, Version version, UpdatePolicy policy) throws 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 openversion
- of resourcepolicy
- update policy of resource- Returns:
- opened streamfrom given url
- Throws:
IOException
- if something goes wrong
-
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
-
getTitle
- Throws:
MissingTitleException
-
getTitleFromJnlp
- Returns:
- the JNLP file's best localized title. This method returns the same value as InformationDesc.getTitle().
-
getTitleFromManifest
-
getVendor
- Returns:
- the JNLP file's best localized vendor. This method returns the same value as InformationDesc.getVendor().
-
getVendor
- Throws:
MissingVendorException
-
getSourceLocation
- Returns:
- the JNLP file's network location as specified in the JNLP file.
-
getFileLocation
- Returns:
- the location of the file parsed to create the JNLP file, or null if it was not created from a URL.
-
getUniqueKey
- Returns:
- the location of the parent file if it exists, null otherwise
-
getParserSettings
- Returns:
- the ParserSettings that was used to parse this file
-
getFileVersion
- Returns:
- the JNLP file's version.
-
getSpecVersion
- Returns:
- the specification version required by the file.
-
getCodeBase
- Returns:
- the codebase URL for the JNLP file.
-
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
- Returns:
- the information section of the JNLP file as viewed through the default locale.
-
getInformation
- Parameters:
locale
- preferred locale of informations- Returns:
- the information section of the JNLP file as viewed through the specified locale.
-
getUpdate
- Returns:
- the update section of the JNLP file.
-
getSecurity
- Returns:
- the security section of the JNLP file.
-
getRequestedPermissionLevel
-
getResources
- Returns:
- the resources section of the JNLP file as viewed through the default locale and the os.name and os.arch properties.
-
getResources
- Parameters:
locale
- preferred locale of resourceos
- preferred os of resourcearch
- preferred arch of resource- Returns:
- the resources section of the JNLP file for the specified locale, os, and arch.
-
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
- Parameters:
locale
- preferred locale of resourceos
- preferred os of resourcearch
- preferred arch of resource- Returns:
- the resources section of the JNLP file for the specified locale, os, and arch.
-
getLaunchInfo
- Returns:
- an object of one of the following types: AppletDesc, ApplicationDesc and InstallerDesc
-
getApplet
- Returns:
- the launch information for an applet.
- Throws:
UnsupportedOperationException
- if there is no applet information
-
getApplication
- Returns:
- the launch information for an application.
- Throws:
UnsupportedOperationException
- if there is no application information
-
getComponent
- Returns:
- the launch information for a component.
- Throws:
UnsupportedOperationException
- if there is no component information
-
getInstaller
- Returns:
- the launch information for an installer.
- Throws:
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
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 resourcearch
- preferred arch of resourcelocale
- preferred locale of resource
-
localeMatches
public boolean localeMatches(Locale requested, 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 localeavailable
- the available localesmatchLevel
- the depth with which to match locales.- Returns:
true
ifrequested
matches any ofavailable
, or ifavailable
is empty ornull
.- See Also:
-
Locale
JNLPFile.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
- Returns:
- a list of args to pass to the new JVM based on this JNLP file
-
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
-
createJnlpVendorValue
-
createJnlpVendor
-
createJnlpTitle
-
createNameForDesktopFile
-