netx.jnlp

Class JNLPFile


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.

Version:
$Revision: 1.21 $
Author:
Jon A. Maxwell (JAM) - initial author

Constructor Summary

JNLPFile(InputStream input, boolean strict)
Create a JNLPFile from an input stream.
JNLPFile(URL location)
Create a JNLPFile from a URL.
JNLPFile(URL location, boolean strict)
Create a JNLPFile from a URL checking for updates using the default policy.
JNLPFile(URL location, boolean strict, UpdatePolicy policy)
Create a JNLPFile from a URL checking for updates using the specified policy.

Method Summary

AppletDesc
getApplet()
Returns the launch information for an applet.
ApplicationDesc
getApplication()
Returns the launch information for an application.
URL
getCodeBase()
Returns the codebase URL for the JNLP file.
ComponentDesc
getComponent()
Returns the launch information for a component.
URL
getFileLocation()
Returns the location of the file parsed to create the JNLP file, or null if it was not created from a URL.
Version
getFileVersion()
Returns the JNLP file's version.
InformationDesc
getInformation()
Returns the information section of the JNLP file as viewed through the default locale.
InformationDesc
getInformation(Locale locale)
Returns the information section of the JNLP file as viewed through the specified locale.
InstallerDesc
getInstaller()
Returns the launch information for an installer.
Object
getLaunchInfo()
Returns an object of one of the following types: AppletDesc, ApplicationDesc, InstallerDesc, and ComponentDesc.
ResourcesDesc
getResources()
Returns the resources section of the JNLP file as viewed through the default locale and the os.name and os.arch properties.
ResourcesDesc
getResources(Locale locale, String os, String arch)
Returns the information section of the JNLP file for the specified locale, os, and arch.
SecurityDesc
getSecurity()
Returns the security section of the JNLP file.
URL
getSourceLocation()
Returns the JNLP file's network location as specified in the JNLP file.
Version
getSpecVersion()
Returns the specification version required by the file.
static Version
getSupportedVersions()
Returns the JNLP specification versions supported.
String
getTitle()
Returns the JNLP file's title.
boolean
isApplet()
Returns whether the lauch descriptor describes an Applet.
boolean
isApplication()
Returns whether the lauch descriptor describes an Application.
boolean
isComponent()
Returns whether the lauch descriptor describes a Component.
boolean
isInstaller()
Returns whether the lauch descriptor describes an Installer.
void
setDefaults(String os, String arch, Locale locale)
Sets the default view of the JNLP file returned by getInformation, getResources, etc.

Constructor Details

JNLPFile

public JNLPFile(InputStream input,
                boolean strict)
            throws ParseException
Create a JNLPFile from an input stream.
Throws:
ParseException - if the JNLP file was invalid

JNLPFile

public JNLPFile(URL location)
            throws IOException,
                   ParseException
Create a JNLPFile from a URL.
Parameters:
location - the location of the JNLP file
Throws:
ParseException - if the JNLP file was invalid

JNLPFile

public JNLPFile(URL location,
                boolean strict)
            throws IOException,
                   ParseException
Create a JNLPFile from a URL checking for updates using the default policy.
Parameters:
location - the location of the JNLP file
strict - whether to enforce the spec when
Throws:
ParseException - if the JNLP file was invalid

JNLPFile

public JNLPFile(URL location,
                boolean strict,
                UpdatePolicy policy)
            throws IOException,
                   ParseException
Create a JNLPFile from a URL checking for updates using the specified policy.
Parameters:
location - the location of the JNLP file
strict - whether to enforce the spec when
policy - the update policy
Throws:
ParseException - if the JNLP file was invalid

Method Details

getApplet

public AppletDesc getApplet()
Returns the launch information for an applet.

getApplication

public ApplicationDesc getApplication()
Returns the launch information for an application.

getCodeBase

public URL getCodeBase()
Returns the codebase URL for the JNLP file.

getComponent

public ComponentDesc getComponent()
Returns the launch information for a component.

getFileLocation

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

getFileVersion

public Version getFileVersion()
Returns the JNLP file's version.

getInformation

public InformationDesc getInformation()
Returns the information section of the JNLP file as viewed through the default locale.

getInformation

public InformationDesc getInformation(Locale locale)
Returns the information section of the JNLP file as viewed through the specified locale.

getInstaller

public InstallerDesc getInstaller()
Returns the launch information for an installer.

getLaunchInfo

public Object getLaunchInfo()
Returns an object of one of the following types: AppletDesc, ApplicationDesc, InstallerDesc, and ComponentDesc.

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(Locale locale,
                                  String os,
                                  String arch)
Returns the information section of the JNLP file for the specified locale, os, and arch.

getSecurity

public SecurityDesc getSecurity()
Returns the security section of the JNLP file.

getSourceLocation

public URL getSourceLocation()
Returns the JNLP file's network location as specified in the JNLP file.

getSpecVersion

public Version getSpecVersion()
Returns the specification version required by the file.

getSupportedVersions

public static Version getSupportedVersions()
Returns the JNLP specification versions supported.

getTitle

public String getTitle()
Returns the JNLP file's title. This method returns the same value as InformationDesc.getTitle().

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(String os,
                        String arch,
                        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().