Merge pull request #605 from mookkiah/587_model-view-presenter
#587 SonarQube reports bugs
This commit is contained in:
commit
2e99cb41ad
@ -25,6 +25,10 @@ package com.iluwatar.model.view.presenter;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
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
|
* Every instance of this class represents the Model component in the Model-View-Presenter
|
||||||
@ -32,7 +36,14 @@ import java.io.FileReader;
|
|||||||
* <p>
|
* <p>
|
||||||
* It is responsible for reading and loading the contents of a given file.
|
* 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.
|
* Indicates if the file is loaded or not.
|
||||||
@ -48,7 +59,8 @@ public class FileLoader {
|
|||||||
* Loads the data of the file specified.
|
* Loads the data of the file specified.
|
||||||
*/
|
*/
|
||||||
public String loadData() {
|
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();
|
StringBuilder sb = new StringBuilder();
|
||||||
String line;
|
String line;
|
||||||
|
|
||||||
@ -60,7 +72,7 @@ public class FileLoader {
|
|||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("File {} does not exist", dataFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -22,13 +22,20 @@
|
|||||||
*/
|
*/
|
||||||
package com.iluwatar.model.view.presenter;
|
package com.iluwatar.model.view.presenter;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Every instance of this class represents the Presenter component in the Model-View-Presenter
|
* Every instance of this class represents the Presenter component in the Model-View-Presenter
|
||||||
* architectural pattern.
|
* architectural pattern.
|
||||||
* <p>
|
* <p>
|
||||||
* It is responsible for reacting to the user's actions and update the View component.
|
* 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.
|
* The View component that the presenter interacts with.
|
||||||
|
@ -22,11 +22,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.iluwatar.model.view.presenter;
|
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
|
* 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.
|
* implemented by either the GUI components, or by the Stub.
|
||||||
*/
|
*/
|
||||||
public interface FileSelectorView {
|
public interface FileSelectorView extends Serializable{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the view.
|
* Opens the view.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user