public static interface VersionChecker.ProgramAccess
Modifier and Type | Method and Description |
---|---|
java.lang.String[] |
endWithoutExit()
End the application, but don't exit.
|
java.lang.String |
getCurrentVersion()
Get a string describing the current version.
|
java.lang.String |
getInfoFileUrl()
Get the URL of the file containing version and possibly other information.
|
default java.io.File |
getOutputJar()
Get the file to which the downloaded jar is written.
|
java.lang.String |
getPackageUrl(java.lang.String versionNumber,
java.lang.String oldVersion)
Get the URL of an update zip.
|
java.lang.String |
getProgramJarName()
Get the base name of the installed jar file.
|
java.lang.String |
getUpdateUrl(java.lang.String versionNumber,
java.lang.String oldVersion)
Get the URL of the program jar.
|
boolean |
isNewerVersion(java.lang.String version)
Tell whether a given version is newer.
|
boolean |
isUserOkayDownload(java.lang.String currentVersion,
java.lang.String newVersion)
Get an okay from the user to download and install a new version.
|
boolean |
isUserOkayRestart(java.lang.String currentVersion,
java.lang.String newVersion)
Get an okay from the user to restart the program.
|
default boolean |
registerRenameShutdownHook(java.io.File tmpFile)
Register a shutdown hook for renaming the temp file where the updated jar is stored to?
|
void |
showErrorDownloadFailureIO(java.lang.String currentVersion,
java.lang.String newVersion,
java.lang.String url,
java.io.IOException exception)
Show an error method that downloading failed because the file could not be downloaded due to i/o problems.
|
void |
showErrorDownloadFailureNotFound(java.lang.String currentVersion,
java.lang.String newVersion,
java.lang.String url,
java.lang.Exception exception)
Show an error method that downloading failed because the file was not accessible.
|
void |
showInfoNeedRestart(java.lang.String currentVersion,
java.lang.String newVersion)
Show an info that a restart of the application is necessary in order to run the new version.
|
void |
showInfoNoUpdatePossible(java.net.URL url,
java.lang.String currentVersion,
java.lang.String newVersion)
Show the HTML content of an URL describing why an update is not possible.
|
default void |
versionIsCurrent()
Informative callback called when it is determined that there is no newer version available.
|
@NotNull java.lang.String getCurrentVersion()
boolean isNewerVersion(@NotNull java.lang.String version)
version
- possibly newer versiontrue
version is newer than the current versionfalse
version is not new than the current version@NotNull java.lang.String getInfoFileUrl()
The file format is simple.
A line starting with a hash character (#
) is starting a comment.
Empty lines are ignored.
All other lines have the format
TAG: CONTENT
where TAG is one of the following
@Nullable java.lang.String getPackageUrl(@NotNull java.lang.String versionNumber, @NotNull java.lang.String oldVersion)
versionNumber
- version number requested.oldVersion
- old version currently runningnull
if there is no update possible@Nullable java.lang.String getUpdateUrl(@NotNull java.lang.String versionNumber, @NotNull java.lang.String oldVersion)
versionNumber
- version number requestedoldVersion
- number of installed versionnull
if there is no update location,
in which case getPackageUrl(String, String)
should not return null
@NotNull java.lang.String getProgramJarName()
@Nullable default java.io.File getOutputJar()
null
) is to
overwrite the currently running jar.null
for the default behaviorvoid showInfoNoUpdatePossible(@NotNull java.net.URL url, @NotNull java.lang.String currentVersion, @NotNull java.lang.String newVersion)
url
- URL to showcurrentVersion
- current versionnewVersion
- new versiondefault void versionIsCurrent()
boolean isUserOkayDownload(@NotNull java.lang.String currentVersion, @NotNull java.lang.String newVersion)
Typical question text:
"A new version of XY is available: "+version+
"Do you want to download and install it?"
currentVersion
- current versionnewVersion
- new versiontrue
: install new versionfalse
: don't install new versionboolean isUserOkayRestart(@NotNull java.lang.String currentVersion, @NotNull java.lang.String newVersion)
Typical question text:
"The new version "+version+" is now installed."+
"Would you like to restart?"
currentVersion
- current versionnewVersion
- new versiontrue
: restart into new versionfalse
: keep runningvoid showInfoNeedRestart(@NotNull java.lang.String currentVersion, @NotNull java.lang.String newVersion)
This is called when it is not possible to do an automatic restart.
Typical text:
" "The new version "+version+" is now installed."+
"You'll need to restart the program to finish the installation."
currentVersion
- current versionnewVersion
- new versionvoid showErrorDownloadFailureNotFound(@NotNull java.lang.String currentVersion, @NotNull java.lang.String newVersion, @NotNull java.lang.String url, @NotNull java.lang.Exception exception)
currentVersion
- current versionnewVersion
- new version which was tried to be downloadedurl
- URL with which it was tried to downloadexception
- the exception on which the error is basedvoid showErrorDownloadFailureIO(@NotNull java.lang.String currentVersion, @NotNull java.lang.String newVersion, @NotNull java.lang.String url, @NotNull java.io.IOException exception)
currentVersion
- current versionnewVersion
- new version which was tried to be downloadedurl
- URL with which it was tried to downloadexception
- the exception on which the error is based@Nullable java.lang.String[] endWithoutExit()
This should write all necessary data to disk, and store the preferences, stop all threads no longer necessary and close all windows.
default boolean registerRenameShutdownHook(@NotNull java.io.File tmpFile)
tmpFile
- temporary filetrue
: for automatically taking carefalse
: the program access itself cares for renaming