Class JNLPUtilities

    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static java.net.URL canonicalizeJarURL​(java.net.URL possibleJarURL)
      Canonicalize a jar URL.
      static java.io.File getResourceSaveJarURLAsTempFile​(java.lang.String spec)
      Get the resource, if it is in a jar URL, then copy the resource to a temporary file first.
      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
    • 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.
      • getResourceSaveJarURLAsTempFile

        public static java.io.File getResourceSaveJarURLAsTempFile​(java.lang.String spec)
                                                            throws java.io.IOException
        Get the resource, if it is in a jar URL, then copy the resource to a temporary file first. If the file is copied to a temporary location, then it is deleted when the process exits. This method is used when jar URLs are not able to be read in by a function call. If the spec refers to a URL that is a directory, then the possibly shortened spec is returned with a trailing /. No temporary directory is created.
        Parameters:
        spec - The string to be found as a resource.
        Returns:
        The File.
        Throws:
        java.io.IOException - If the jar URL cannot be saved as a temporary file.
      • isRunningUnderWebStart

        public static boolean isRunningUnderWebStart()
        Return true if we are running under WebStart.
        Returns:
        True if we are running under WebStart.
      • jarURLEntryResource

        @Deprecated
        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.