This commit is contained in:
Ilkka Seppälä 2017-08-13 10:09:46 +03:00
commit cbba487ff8
3 changed files with 26 additions and 5 deletions

View File

@ -25,6 +25,10 @@ package com.iluwatar.model.view.presenter;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Every instance of this class represents the Model component in the Model-View-Presenter
@ -32,7 +36,14 @@ import java.io.FileReader;
* <p>
* It is responsible for reading and loading the contents of a given file.
*/
public class FileLoader {
public class FileLoader implements Serializable{
/**
* Generated serial version UID
*/
private static final long serialVersionUID = -4745803872902019069L;
private static final Logger LOGGER = LoggerFactory.getLogger(FileLoader.class);
/**
* Indicates if the file is loaded or not.
@ -48,7 +59,8 @@ public class FileLoader {
* Loads the data of the file specified.
*/
public String loadData() {
try (BufferedReader br = new BufferedReader(new FileReader(new File(this.fileName)))) {
String dataFileName = this.fileName;
try (BufferedReader br = new BufferedReader(new FileReader(new File(dataFileName)))) {
StringBuilder sb = new StringBuilder();
String line;
@ -60,7 +72,7 @@ public class FileLoader {
return sb.toString();
} catch (Exception e) {
e.printStackTrace();
LOGGER.error("File {} does not exist", dataFileName);
}
return null;

View File

@ -22,13 +22,20 @@
*/
package com.iluwatar.model.view.presenter;
import java.io.Serializable;
/**
* Every instance of this class represents the Presenter component in the Model-View-Presenter
* architectural pattern.
* <p>
* It is responsible for reacting to the user's actions and update the View component.
*/
public class FileSelectorPresenter {
public class FileSelectorPresenter implements Serializable{
/**
* Generated serial version UID
*/
private static final long serialVersionUID = 1210314339075855074L;
/**
* The View component that the presenter interacts with.

View File

@ -22,11 +22,13 @@
*/
package com.iluwatar.model.view.presenter;
import java.io.Serializable;
/**
* This interface represents the View component in the Model-View-Presenter pattern. It can be
* implemented by either the GUI components, or by the Stub.
*/
public interface FileSelectorView {
public interface FileSelectorView extends Serializable{
/**
* Opens the view.