import static java.util.logging.Level.WARNING;
import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.logging.Logger;
saveIds("KnownSones", knownSones);
}
+ public synchronized Map<String, Long> loadSoneFollowingTimes() {
+ Map<String, Long> soneFollowingTimes = new HashMap<String, Long>();
+ int counter = 0;
+ while (true) {
+ String soneId = configuration.getStringValue("SoneFollowingTimes/" + counter + "/Sone").getValue(null);
+ if (soneId == null) {
+ break;
+ }
+ long followingTime = configuration.getLongValue("SoneFollowingTimes/" + counter + "/Time").getValue(Long.MAX_VALUE);
+ soneFollowingTimes.put(soneId, followingTime);
+ counter++;
+ }
+ return soneFollowingTimes;
+ }
+
+ public synchronized void saveSoneFollowingTimes(Map<String, Long> soneFollowingTimes) {
+ try {
+ int counter = 0;
+ for (Entry<String, Long> soneFollowingTime : soneFollowingTimes.entrySet()) {
+ configuration.getStringValue("SoneFollowingTimes/" + counter + "/Sone")
+ .setValue(soneFollowingTime.getKey());
+ configuration.getLongValue("SoneFollowingTimes/" + counter + "/Time")
+ .setValue(soneFollowingTime.getValue());
+ counter++;
+ }
+ configuration.getStringValue("SoneFollowingTimes/" + counter + "/Sone").setValue(null);
+ } catch (ConfigurationException ce1) {
+ logger.log(WARNING, "Could not save Sone following times!", ce1);
+ }
+ }
+
public synchronized Set<String> loadKnownPosts() {
return loadIds("KnownPosts");
}