public class FileManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
inputPath |
static java.lang.String |
outputPath |
Constructor and Description |
---|
FileManager() |
Modifier and Type | Method and Description |
---|---|
static void |
addTeam(java.lang.String fullName,
java.lang.String shortName)
Adds a team with no logo
Updates
teams.txt . |
static void |
addTeam(java.lang.String fullName,
java.lang.String shortName,
java.nio.file.Path image)
Adds a team with no logo
Updates
teams.txt . |
static void |
checkForUpdates()
checks GitHub for any new releases after current version.
|
static int |
compareVersions(java.lang.String version1,
java.lang.String version2)
Returns 1 if
v1 > v2 , -1 otherwise |
static boolean |
convertFormat(java.lang.String inputImagePath,
java.lang.String outputImagePath,
java.lang.String formatName)
Converts an image to another format
|
protected static java.nio.file.Path |
findFile(java.util.LinkedList<java.nio.file.Path> allTeamImages,
java.lang.String searchFor)
Takes a list of
Path s and finds a certain file by name, excluding extension |
static java.util.LinkedList<java.lang.String> |
getAllMapsFromDisk()
Gets an updated list of maps from the
maps.txt file |
static java.lang.String |
getDefaultInputPath()
Gets the default (OS specific) application input folder path.
|
static java.lang.String |
getDefaultOutputPath()
Gets the default (OS specific) application output folder path.
|
static java.lang.String |
getInputPath()
Gets the currently set application input folder path.
|
static java.lang.String |
getOutputPath()
Gets the currently set application output folder path.
|
static void |
getScsBracket(int number) |
static java.lang.String |
getShortName(java.lang.String longName)
Parses `teams.txt` to get a team's longName from its shortName.
|
static java.lang.String |
getTournamentName()
Gets the current tournament name from file
|
static int |
getTourneyNumber()
Gets the current tournament number from file
|
static void |
main(java.lang.String[] args) |
static void |
noInputFolderPrompt()
Prompts user that input folder wasn't found.
|
static void |
refreshPreferences()
Attempts to refresh the application's preferences.
|
static void |
removeMap()
Remove the map image and name.
|
static void |
removeTeam(java.lang.String teamIdentifier)
Remove the currently set team from given team letter/identifier.
|
static void |
resetInputPath()
Resets the inputPath to application default
|
static void |
resetOutputPath()
Resets the outputPath to application default
|
static void |
resetPreferences()
Calls
Preferences.clear() on the FileManager's preference node - effectively resetting it. |
static void |
setInputPath(java.lang.String inputPath)
Sets the preferred input path
|
static boolean |
setMap(java.lang.String mapName)
Sets the current map.
|
static void |
setMap(java.lang.String mapName,
boolean isSpawn)
Sets the current map, with or without spawn locations
|
static void |
setOutputPath(java.lang.String outputPath)
Sets the preferred output path
|
static void |
setTeam(java.lang.String newTeamName,
java.lang.String teamIdentifier)
Sets the current team.
|
static void |
setTournamentName(java.lang.String tournamentName)
Updates the
TournamentName.txt file. |
static boolean |
setTourneyNumber(java.lang.String number)
Sets the current tournament number.
|
static void |
verifyContent()
Checks for
input and output folders, creates them if necessary. |
public static java.lang.String outputPath
public static java.lang.String inputPath
public static void main(java.lang.String[] args)
public static java.lang.String getOutputPath()
getInputPath()
public static java.lang.String getDefaultOutputPath()
/
'),
so that content may be appended to itgetDefaultInputPath()
public static java.lang.String getInputPath()
getOutputPath()
public static java.lang.String getDefaultInputPath()
/
'),
so that content may be appended to itgetDefaultOutputPath()
public static void setOutputPath(java.lang.String outputPath)
outputPath
- valid path to new output folder, MUST END IN FILE SEPARATORpublic static void setInputPath(java.lang.String inputPath)
inputPath
- valid path to new input folder, MUST END IN FILE SEPARATORpublic static void resetOutputPath()
public static void resetInputPath()
public static boolean setTourneyNumber(java.lang.String number)
number
- new number representing current tournamentpublic static int getTourneyNumber() throws java.lang.NumberFormatException, java.io.FileNotFoundException
java.lang.NumberFormatException
- if tournament file does not contain valid contentjava.io.FileNotFoundException
- TournamentNumber.txt could not be foundpublic static void noInputFolderPrompt()
verifyContent()
public static void verifyContent() throws java.io.IOException
input
and output
folders, creates them if necessary.java.io.IOException
- Error creating file or directorypublic static void setTournamentName(java.lang.String tournamentName) throws java.io.IOException
TournamentName.txt
file.tournamentName
- new content for filejava.io.IOException
- if error writing to filepublic static java.lang.String getTournamentName() throws java.io.FileNotFoundException, java.util.NoSuchElementException
java.io.FileNotFoundException
- tournament file could not be foundjava.util.NoSuchElementException
- file contains unexpected (or no) contentpublic static boolean setMap(java.lang.String mapName) throws java.io.IOException
mapName
- Name of map to be set as current.java.io.IOException
- IO error for maps.txt opening or writingjava.io.FileNotFoundException
- Likely error finding map filepublic static void setMap(java.lang.String mapName, boolean isSpawn) throws java.io.IOException
mapName
- Name of map to be set as currentisSpawn
- If spawns should be shown on map or notjava.io.IOException
- IO error for maps.txt opening or writingjava.io.FileNotFoundException
- Likely error finding map filepublic static void setTeam(java.lang.String newTeamName, java.lang.String teamIdentifier) throws java.io.IOException, java.lang.IllegalArgumentException
"Team" + teamIdentifier + ".png"
Updates the team & teamShort txt files to the new team's name.
File name formatted as "Team" + teamIdentifier + ".txt"
,
and "TeamShort" + teamIdentifier + ".txt"
newTeamName
- Name of the team. Must occur in teams.txtteamIdentifier
- Value to identify team. Must be a valid character for filesystemjava.io.IOException
- error writing, reading, or converting files team files.java.lang.IllegalArgumentException
- Thrown if fcn args contain invalid characters or do not correspond to a team in teams.txtpublic static void addTeam(java.lang.String fullName, java.lang.String shortName) throws java.io.IOException
teams.txt
.fullName
- full team name to addshortName
- short name of team, will be converted to capsjava.io.IOException
- IO on teams.txt failed.public static void addTeam(java.lang.String fullName, java.lang.String shortName, java.nio.file.Path image) throws java.io.IOException
teams.txt
.fullName
- full team name to addshortName
- short name of team, will be converted to capsimage
- Path to image file which will be added to input folderjava.io.IOException
- file copy for image failed, or IO to teams.txt failedjava.io.FileNotFoundException
- if the Path is a directory or extensionless fileprotected static java.nio.file.Path findFile(java.util.LinkedList<java.nio.file.Path> allTeamImages, java.lang.String searchFor)
Path
s and finds a certain file by name, excluding extensionallTeamImages
- list of paths, all paths should be a file with an extensionpublic static java.lang.String getShortName(java.lang.String longName) throws java.io.FileNotFoundException
longName
- longName to find corresponding shortName ofnull
if no shortname can be foundjava.io.FileNotFoundException
- teams.txt could not be foundpublic static boolean convertFormat(java.lang.String inputImagePath, java.lang.String outputImagePath, java.lang.String formatName) throws java.io.IOException
inputImagePath
- Path of the source imageoutputImagePath
- Path of the destination imageformatName
- the format to be converted to, one of: jpeg, png,
bmp, wbmp, and gifjava.io.IOException
- if errors occur during writingpublic static java.util.LinkedList<java.lang.String> getAllMapsFromDisk() throws java.io.FileNotFoundException
maps.txt
filejava.io.FileNotFoundException
- if maps.txt
file was not foundpublic static void getScsBracket(int number)
public static int compareVersions(java.lang.String version1, java.lang.String version2)
v1 > v2
, -1 otherwiseversion1
- version2
- public static void checkForUpdates()
public static void resetPreferences() throws java.util.prefs.BackingStoreException
Preferences.clear()
on the FileManager's preference node - effectively resetting it.
Does not guarantee full refresh of preferences in app until after a restart.java.util.prefs.BackingStoreException
- if could not complete clear due to failure relating to the backing storepublic static void refreshPreferences()
public static void removeTeam(java.lang.String teamIdentifier) throws java.io.IOException
setTeam(String, String)
.teamIdentifier
- Value to identify team. Must be a valid character for filesystemjava.io.IOException
- if files (Team.txt and TeamShort.txt) couldn't be written topublic static void removeMap() throws java.io.IOException
setMap(String)
.java.io.IOException
- if Map.txt
couldn't be written to