From: David ‘Bombe’ Roden Date: Wed, 24 Nov 2010 12:06:36 +0000 (+0100) Subject: Expose the saveConfiguration method. X-Git-Tag: 0.3.1-RC1~33 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=a78eb39c508342d22fa063dad9dc2dab1d24bc0a Expose the saveConfiguration method. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 1f89196..c41d04b 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1268,6 +1268,52 @@ public class Core implements IdentityListener { stopped = true; } + /** + * Saves the current options. + */ + public void saveConfiguration() { + /* store the options first. */ + try { + configuration.getIntValue("Option/InsertionDelay").setValue(options.getIntegerOption("InsertionDelay").getReal()); + configuration.getBooleanValue("Option/SoneRescueMode").setValue(options.getBooleanOption("SoneRescueMode").getReal()); + configuration.getBooleanValue("Option/ClearOnNextRestart").setValue(options.getBooleanOption("ClearOnNextRestart").getReal()); + configuration.getBooleanValue("Option/ReallyClearOnNextRestart").setValue(options.getBooleanOption("ReallyClearOnNextRestart").getReal()); + + /* save known Sones. */ + int soneCounter = 0; + synchronized (newSones) { + for (String knownSoneId : knownSones) { + configuration.getStringValue("KnownSone/" + soneCounter++ + "/ID").setValue(knownSoneId); + } + configuration.getStringValue("KnownSone/" + soneCounter + "/ID").setValue(null); + } + + /* save known posts. */ + int postCounter = 0; + synchronized (newPosts) { + for (String knownPostId : knownPosts) { + configuration.getStringValue("KnownPosts/" + postCounter++ + "/ID").setValue(knownPostId); + } + configuration.getStringValue("KnownPosts/" + postCounter + "/ID").setValue(null); + } + + /* save known replies. */ + int replyCounter = 0; + synchronized (newReplies) { + for (String knownReplyId : knownReplies) { + configuration.getStringValue("KnownReplies/" + replyCounter++ + "/ID").setValue(knownReplyId); + } + configuration.getStringValue("KnownReplies/" + replyCounter + "/ID").setValue(null); + } + + /* now save it. */ + configuration.save(); + + } catch (ConfigurationException ce1) { + logger.log(Level.SEVERE, "Could not store configuration!", ce1); + } + } + // // PRIVATE METHODS // @@ -1343,52 +1389,6 @@ public class Core implements IdentityListener { } /** - * Saves the current options. - */ - private void saveConfiguration() { - /* store the options first. */ - try { - configuration.getIntValue("Option/InsertionDelay").setValue(options.getIntegerOption("InsertionDelay").getReal()); - configuration.getBooleanValue("Option/SoneRescueMode").setValue(options.getBooleanOption("SoneRescueMode").getReal()); - configuration.getBooleanValue("Option/ClearOnNextRestart").setValue(options.getBooleanOption("ClearOnNextRestart").getReal()); - configuration.getBooleanValue("Option/ReallyClearOnNextRestart").setValue(options.getBooleanOption("ReallyClearOnNextRestart").getReal()); - - /* save known Sones. */ - int soneCounter = 0; - synchronized (newSones) { - for (String knownSoneId : knownSones) { - configuration.getStringValue("KnownSone/" + soneCounter++ + "/ID").setValue(knownSoneId); - } - configuration.getStringValue("KnownSone/" + soneCounter + "/ID").setValue(null); - } - - /* save known posts. */ - int postCounter = 0; - synchronized (newPosts) { - for (String knownPostId : knownPosts) { - configuration.getStringValue("KnownPosts/" + postCounter++ + "/ID").setValue(knownPostId); - } - configuration.getStringValue("KnownPosts/" + postCounter + "/ID").setValue(null); - } - - /* save known replies. */ - int replyCounter = 0; - synchronized (newReplies) { - for (String knownReplyId : knownReplies) { - configuration.getStringValue("KnownReplies/" + replyCounter++ + "/ID").setValue(knownReplyId); - } - configuration.getStringValue("KnownReplies/" + replyCounter + "/ID").setValue(null); - } - - /* now save it. */ - configuration.save(); - - } catch (ConfigurationException ce1) { - logger.log(Level.SEVERE, "Could not store configuration!", ce1); - } - } - - /** * Generate a Sone URI from the given URI and latest edition. * * @param uriString