diff options
author | Maurice Laveaux <m.laveaux@student.tue.nl> | 2014-05-01 17:26:17 +0200 |
---|---|---|
committer | Maurice Laveaux <m.laveaux@student.tue.nl> | 2014-05-01 17:26:17 +0200 |
commit | daf59bc4f7e5d29466e61ada9bf5eaaf2431ac3c (patch) | |
tree | 0c41df9d9d10fffeaf8c61c0eb9d180015f2a025 | |
parent | 355bb332328a16ae967cf276bfdbe4cda0776c47 (diff) | |
download | TwitterDataAnalytics-daf59bc4f7e5d29466e61ada9bf5eaaf2431ac3c.tar.gz |
Moved setting the default values.
* Moved from TweetShell to Configuration.
-rw-r--r-- | src/main/TweetShell.java | 6 | ||||
-rw-r--r-- | 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; } |