X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fgui%2FUpdateChecker.java;h=44be635ae9ea5c7595192ee0b7f3d7f3cffa5a56;hb=a7d90795bb3f97633bdeb0ccc5b060f39f14eb54;hp=5a13072049b30a977b852311c4450392b5f4400b;hpb=0aae9b10c223574f08d00abf179e8cd9ee9a80df;p=jSite.git
diff --git a/src/de/todesbaum/jsite/gui/UpdateChecker.java b/src/de/todesbaum/jsite/gui/UpdateChecker.java
index 5a13072..44be635 100644
--- a/src/de/todesbaum/jsite/gui/UpdateChecker.java
+++ b/src/de/todesbaum/jsite/gui/UpdateChecker.java
@@ -86,14 +86,34 @@ public class UpdateChecker implements Runnable {
// EVENT LISTENER MANAGEMENT
//
+ /**
+ * Adds an update listener to the list of registered listeners.
+ *
+ * @param updateListener
+ * The update listener to add
+ */
public void addUpdateListener(UpdateListener updateListener) {
updateListeners.add(updateListener);
}
+ /**
+ * Removes the given listener from the list of registered listeners.
+ *
+ * @param updateListener
+ * The update listener to remove
+ */
public void removeUpdateListener(UpdateListener updateListener) {
updateListeners.remove(updateListener);
}
+ /**
+ * Notifies all listeners that a version was found.
+ *
+ * @param foundVersion
+ * The version that was found
+ * @param versionTimestamp
+ * The timestamp of the version
+ */
protected void fireUpdateFound(Version foundVersion, long versionTimestamp) {
for (UpdateListener updateListener : updateListeners) {
updateListener.foundUpdateData(foundVersion, versionTimestamp);
@@ -101,13 +121,32 @@ public class UpdateChecker implements Runnable {
}
//
+ // ACCESSORS
+ //
+
+ /**
+ * Returns the latest version that was found.
+ *
+ * @return The latest found version
+ */
+ public Version getLatestVersion() {
+ return lastVersion;
+ }
+
+ //
// ACTIONS
//
+ /**
+ * Starts the update checker.
+ */
public void start() {
new Thread(this).start();
}
+ /**
+ * Stops the update checker.
+ */
public void stop() {
synchronized (syncObject) {
shouldStop = true;
@@ -119,12 +158,25 @@ public class UpdateChecker implements Runnable {
// PRIVATE METHODS
//
+ /**
+ * Returns whether the update checker should stop.
+ *
+ * @return true
if the update checker should stop,
+ * false
otherwise
+ */
private boolean shouldStop() {
synchronized (syncObject) {
return shouldStop;
}
}
+ /**
+ * Creates the URI of the update file for the given edition.
+ *
+ * @param edition
+ * The edition number
+ * @return The URI for the update file for the given edition
+ */
private String constructUpdateKey(int edition) {
return UPDATE_KEY + "/jSite/" + edition + "/jSite.properties";
}
@@ -133,6 +185,9 @@ public class UpdateChecker implements Runnable {
// INTERFACE Runnable
//
+ /**
+ * {@inheritDoc}
+ */
public void run() {
Connection connection = freenetInterface.getConnection("jSite-" + ++counter + "-UpdateChecker");
try {
@@ -222,4 +277,5 @@ public class UpdateChecker implements Runnable {
}
}
}
+
}