From daf59bc4f7e5d29466e61ada9bf5eaaf2431ac3c Mon Sep 17 00:00:00 2001 From: Maurice Laveaux Date: Thu, 1 May 2014 17:26:17 +0200 Subject: Moved setting the default values. * Moved from TweetShell to Configuration. --- src/main/TweetShell.java | 6 ++---- src/utils/Configuration.java | 10 +++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/TweetShell.java b/src/main/TweetShell.java index 25d785a..0849592 100644 --- a/src/main/TweetShell.java +++ b/src/main/TweetShell.java @@ -227,14 +227,12 @@ public class TweetShell implements TwitterApi.PinSupplier { if (!(oldListener instanceof DataWriter)) { Configuration config = Configuration.getConfig(); - String profilesFilename = config.getProperty(DataWriter.CFG_PROFILE_FILENAME, "profiles.txt"); - String tweetsFilename = config.getProperty(DataWriter.CFG_TWEETS_FILENAME, "tweets.txt"); + String profilesFilename = config.getProperty(DataWriter.CFG_PROFILE_FILENAME); + String tweetsFilename = config.getProperty(DataWriter.CFG_TWEETS_FILENAME); stream.setResultListener(new DataWriter(profilesFilename, tweetsFilename)); // save the changes to the config. - config.setProperty(DataWriter.CFG_PROFILE_FILENAME, profilesFilename); - config.setProperty(DataWriter.CFG_TWEETS_FILENAME, tweetsFilename); config.save(); } break; diff --git a/src/utils/Configuration.java b/src/utils/Configuration.java index 78bd9e2..1e810c3 100644 --- a/src/utils/Configuration.java +++ b/src/utils/Configuration.java @@ -1,5 +1,6 @@ package utils; +import io.DataWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -22,7 +23,7 @@ public class Configuration { public static final String REQUEST_TOKEN_URL = "https://twitter.com/oauth/request_token"; public static final String AUTHORIZE_URL = "https://twitter.com/oauth/authorize"; public static final String ACCESS_TOKEN_URL = "https://twitter.com/oauth/access_token"; - + public static final String DEFAULT_TWEETS_FILENAME = "tweets.txt"; public static final String DEFAULT_PROFILE_FILENAME = "profiles.txt"; @@ -48,6 +49,13 @@ public class Configuration { private Properties getDefaults() { Properties defs = new Properties(); // set default preferences as needed + + String profilesFilename = defs.getProperty(DataWriter.CFG_PROFILE_FILENAME, "profiles.txt"); + String tweetsFilename = defs.getProperty(DataWriter.CFG_TWEETS_FILENAME, "tweets.txt"); + + defs.setProperty(DataWriter.CFG_PROFILE_FILENAME, profilesFilename); + defs.setProperty(DataWriter.CFG_TWEETS_FILENAME, tweetsFilename); + return defs; } -- cgit v1.2.1