ptolemy.actor.gui
Class JNLPUtilities

java.lang.Object
  extended by ptolemy.actor.gui.JNLPUtilities

public class JNLPUtilities
extends java.lang.Object

This class contains utilities for use with JNLP, aka Web Start.

For more information about Web Start, see http://java.sun.com/products/javawebstart or $PTII/doc/webStartHelp

Since:
Ptolemy II 2.0
Version:
$Id: JNLPUtilities.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Christopher Hylands
See Also:
Configuration
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Constructor Summary
private JNLPUtilities()
          Instances of this class cannot be created.
 
Method Summary
private static java.net.URL _lookupJarURL(java.lang.String jarURLName)
           
static java.net.URL canonicalizeJarURL(java.net.URL possibleJarURL)
          Canonicalize a jar URL.
static boolean isRunningUnderWebStart()
          Return true if we are running under WebStart.
static java.net.URL jarURLEntryResource(java.lang.String spec)
          Deprecated. Use ptolemy.util.ClassUtilities#jarURLEntryResource(String)
static java.lang.String saveJarURLAsTempFile(java.lang.String jarURLName, java.lang.String prefix, java.lang.String suffix, java.io.File directory)
          Given a jar URL, read in the resource and save it as a file.
static java.lang.String saveJarURLInClassPath(java.lang.String jarURLName)
          Given a jar URL, read in the resource and save it as a file in a similar directory in the classpath if possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JNLPUtilities

private JNLPUtilities()
Instances of this class cannot be created.

Method Detail

canonicalizeJarURL

public static java.net.URL canonicalizeJarURL(java.net.URL possibleJarURL)
                                       throws java.net.MalformedURLException
Canonicalize a jar URL. If the possibleJarURL argument is a jar URL (that is, it starts with 'jar:'), then convert any space characters to %20. If the possibleJarURL argument is not a jar URL, then return the possibleJarURL argument.

Parameters:
possibleJarURL - A URL that may or may not be a jar URL
Returns:
either the original possibleJarURL or a canonicalized jar URL
Throws:
java.net.MalformedURLException - If new URL() throws it.

isRunningUnderWebStart

public static boolean isRunningUnderWebStart()
Return true if we are running under WebStart.

Returns:
True if we are running under WebStart.

jarURLEntryResource

public static java.net.URL jarURLEntryResource(java.lang.String spec)
                                        throws java.io.IOException
Deprecated. Use ptolemy.util.ClassUtilities#jarURLEntryResource(String)

Given a jar url of the format jar:{url}!/{entry}, return the resource, if any of the {entry}. If the string does not contain !/, then return null. Web Start uses jar URL, and there are some cases where if we have a jar URL, then we may need to strip off the jar:url!/ part so that we can search for the {entry} as a resource.

Parameters:
spec - The string containing the jar url.
Returns:
the resource if any.
Throws:
java.io.IOException - If it cannot convert the specification to a URL.
See Also:
ClassUtilities.jarURLEntryResource(String), JarURLConnection

saveJarURLAsTempFile

public static java.lang.String saveJarURLAsTempFile(java.lang.String jarURLName,
                                                    java.lang.String prefix,
                                                    java.lang.String suffix,
                                                    java.io.File directory)
                                             throws java.io.IOException
Given a jar URL, read in the resource and save it as a file. The file is created using the prefix and suffix in the directory referred to by the directory argument. If the directory argument is null, then it is saved in the platform dependent temporary directory. The file is deleted upon exit.

Parameters:
jarURLName - The name of the jar URL to read. jar URLS start with "jar:" and have a "!/" in them.
prefix - The prefix used to generate the name, it must be at least three characters long.
suffix - The suffix to use to generate the name. If the suffix is null, then the suffix of the jarURLName is used. If the jarURLName does not contain a ".", then ".tmp" will be used
directory - The directory where the temporary file is created. If directory is null then the platform dependent temporary directory is used.
Returns:
the name of the temporary file that was created
Throws:
java.io.IOException - If there is a problem saving the jar URL.
See Also:
File.createTempFile(java.lang.String, java.lang.String, java.io.File)

saveJarURLInClassPath

public static java.lang.String saveJarURLInClassPath(java.lang.String jarURLName)
                                              throws java.io.IOException
Given a jar URL, read in the resource and save it as a file in a similar directory in the classpath if possible. In this context, by similar directory, we mean the directory where the file would found if it was not in the jar url. For example, if the jar url is jar:file:/ptII/doc/design.jar!/doc/design/design.pdf then this method will read design.pdf from design.jar and save it as /ptII/doc/design.pdf.

Parameters:
jarURLName - The name of the jar URL to read. jar URLS start with "jar:" and have a "!/" in them.
Returns:
the name of the file that was created or null if the file cannot be created
Throws:
java.io.IOException - If there is a problem saving the jar URL.

_lookupJarURL

private static java.net.URL _lookupJarURL(java.lang.String jarURLName)
                                   throws java.io.IOException
Throws:
java.io.IOException