public class JythonJarManager
extends java.lang.Object
PuffinPlot can make use of Jython, but for reasons of size Jython is not included in the build. To use Jython in PuffinPlot, the Jython jar must be downloaded and installed locally. This class provides some static utility methods to check for a local Jython jar, verify its integrity, download it from a known URL, or delete it from the local cache.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SOURCE_URL_STRING
A string representation of the URL from which the jython jar is
downloaded.
|
Constructor and Description |
---|
JythonJarManager() |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkInstalled(boolean deleteIfWrongSize)
Checks whether the Jython jar file is installed locally and has the
correct size.
|
static boolean |
checkSha1Digest(boolean deleteIfIncorrect)
Calculates the SHA-1 digest of the Jython jar file and verifies it
against a hard-coded reference value.
|
static void |
download()
Downloads the Jython jar from a hard-coded URL and saves it in the
application data directory.
|
static long |
getExpectedDownloadSize() |
static java.nio.file.Path |
getPath()
Returns the local path for the Jython jar file with the application data
directory.
|
public static final java.lang.String SOURCE_URL_STRING
public static java.nio.file.Path getPath() throws java.io.IOException
java.io.IOException
- if there was an error determining the pathpublic static boolean checkSha1Digest(boolean deleteIfIncorrect) throws java.io.IOException, java.security.NoSuchAlgorithmException
deleteIfIncorrect
- If this parameter is true, and if the SHA-1
digest is not correct, the jar file will be deletedjava.io.IOException
- if there was an error reading the jar filejava.security.NoSuchAlgorithmException
- if the SHA-1 algorithm was not availablepublic static boolean checkInstalled(boolean deleteIfWrongSize) throws java.io.IOException
deleteIfWrongSize
- if true, and if the jar file
does not have the correct size, it will be deleted.java.io.IOException
- if there was an error checking or deleting
the jar filepublic static void download() throws java.io.IOException
This method may block indefinitely.
java.io.IOException
- if there is an error reading from the URL or writing
to the filepublic static long getExpectedDownloadSize()