summaryrefslogtreecommitdiff
path: root/src/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/io')
-rw-r--r--src/io/DataReader.java57
-rw-r--r--src/io/InputReader.java56
2 files changed, 0 insertions, 113 deletions
diff --git a/src/io/DataReader.java b/src/io/DataReader.java
deleted file mode 100644
index 21a1036..0000000
--- a/src/io/DataReader.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package io;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.util.Scanner;
-import java.util.logging.Level;
-import main.ResultListener;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- * Create a data reader that reads the input file.
- *
- * @author Maurice Laveaux
- */
-public class DataReader {
-
- /* The listener that receives the data input. */
- private final ResultListener m_listener;
-
- /* The input stream for the given file. */
- private final FileInputStream m_input;
-
- /**
- * @param filename The filename to read from.
- * @param listener The listener of the read tweets.
- */
- public DataReader(final String filename, final ResultListener listener) {
- try {
- m_listener = listener;
- m_input = new FileInputStream(filename);
- } catch (FileNotFoundException ex) {
- throw new IllegalArgumentException("the given filename \"" + filename + "\" doesn't exist.");
- }
-
- }
- public void startloop(){
- Scanner scanner=null;
- scanner = new Scanner(m_input);
- try {
- while(scanner.hasNextLine()){
-
-
- JSONObject tweet = new JSONObject(scanner.nextLine());
-
- m_listener.tweetReceived(tweet);
-
- }
-
-
-
- } catch (Exception e){
- e.printStackTrace();
- }
- }
-}
diff --git a/src/io/InputReader.java b/src/io/InputReader.java
deleted file mode 100644
index 985a59b..0000000
--- a/src/io/InputReader.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package io;
-
-import java.util.Scanner;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import main.ResultListener;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- * Read from standard input and inserts these tweets into the database.
- *
- * @author Maurice Laveaux
- */
-public class InputReader {
-
- /* The listener for standard input tweets. */
- private final ResultListener m_listener;
-
- /**
- * @param listener The given listener for the input.
- */
- public InputReader(final ResultListener listener) {
- m_listener = listener;
- }
-
- /* Create a reader for the standard input, read each line and tweetReceived
- * listener when a valid JSONObject is generated.
- */
- public void startLoop() {
- Scanner input = new Scanner(System.in);
-
- while (input.hasNext()) {
- try {
- String line = input.nextLine();
- if(line.equals("exit")) {
- return;
- }
-
- JSONObject tweet = new JSONObject(line);
-
- if (!tweet.has("user")) {
- throw new JSONException("not a valid tweet JSON object");
- }
-
- m_listener.tweetReceived(tweet);
- } catch (JSONException ex) {
- getLogger().log(Level.INFO, null, ex);
- }
- }
- }
-
- private Logger getLogger() {
- return Logger.getLogger(InputReader.class.getName());
- }
-}