public class FileControl extends Object implements FileControlInterface
Constructor and Description |
---|
FileControl(LanguageManagerInterface languageManager)
The default constructor used by the Dependency injector.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkFileIntegrity(List<String> lines)
Will read all the lines contained in the 'lines' variable and will check steps by steps if the file is
correctly written.
|
static boolean |
fileExists(String filePath)
check if a file exists.
|
MapArea |
initializeMap(List<String> fileContents)
use the maps configured in the file and will create a new map.
|
Map<Mower,String> |
loadMowers(List<String> commandsLines,
MapArea initialMap)
Will read and parse the 'commandLines' extracted with the 'readFile' method and will set them on the map,
it will return a map with the mowers and their commands.
|
List<String> |
readFile(String filename)
Read a file and puts all the data in a String array.
|
@Inject public FileControl(LanguageManagerInterface languageManager)
languageManager
- The injected language manager for internationalizationpublic static boolean fileExists(String filePath)
filePath
- location of the file to testspublic MapArea initializeMap(List<String> fileContents) throws MowerInstructionFileException
initializeMap
in interface FileControlInterface
fileContents
- the content of the file which contains commands data.MowerInstructionFileException
- if file is mal formattedpublic Map<Mower,String> loadMowers(List<String> commandsLines, MapArea initialMap)
loadMowers
in interface FileControlInterface
initialMap
- the map where the mower will be set on.commandsLines
- the content of the file which contains commands data.public List<String> readFile(String filename) throws IOException
readFile
in interface FileControlInterface
filename
- the file locationIOException
- if the file doesn't exists or if it's brokenpublic boolean checkFileIntegrity(List<String> lines) throws MowerInstructionFileException
checkFileIntegrity
in interface FileControlInterface
lines
- the commands data located in the 'FilePath' variable and extracted with readFile()MowerInstructionFileException
- if the file is malformedCopyright © 2016. All Rights Reserved.