public class JythonJarManager extends 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 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 Path |
getPath()
Returns the local path for the Jython jar file with the application data
directory.
|
public static final String SOURCE_URL_STRING
public static Path getPath() throws IOException
IOException
- if there was an error determining the pathpublic static boolean checkSha1Digest(boolean deleteIfIncorrect) throws IOException, NoSuchAlgorithmException
deleteIfIncorrect
- If this parameter is true, and if the SHA-1
digest is not correct, the jar file will be deletedIOException
- if there was an error reading the jar fileNoSuchAlgorithmException
- if the SHA-1 algorithm was not availablepublic static boolean checkInstalled(boolean deleteIfWrongSize) throws IOException
deleteIfWrongSize
- if true, and if the jar file
does not have the correct size, it will be deleted.IOException
- if there was an error checking or deleting
the jar filepublic static void download() throws IOException
This method may block indefinitely.
IOException
- if there is an error reading from the URL or writing
to the filepublic static long getExpectedDownloadSize()
Copyright © 2022. All rights reserved.