Package it.univr.wordautomata.backend
Class AutomataSaver
java.lang.Object
it.univr.wordautomata.backend.AutomataSaver
The AutomataSaver class provides methods for saving and reading automata
objects to/from files,
as well as managing recent files and file dialogs.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Clears the list of recent files.Retrieves a list of recent files.static File
Returns the temporary folder used by the application.static com.brunomnsilva.smartgraph.graph.DigraphEdgeList
<State, Transition> read()
Reads a DigraphEdgeList from a file.static com.brunomnsilva.smartgraph.graph.DigraphEdgeList
<State, Transition> Reads a DigraphEdgeList from a file.static void
recordRecentFile
(File file) Records the given file as a recent file in the application.static void
save()
Saves the currently opened file.static void
Saves the automata to a file.static File
Represents a file in the file system.static File
Represents a file in the file system.
-
Method Details
-
save
Saves the automata to a file.- Parameters:
file
- the file to save the automata to
-
read
public static com.brunomnsilva.smartgraph.graph.DigraphEdgeList<State,Transition> read(File file, boolean debug) Reads a DigraphEdgeList from a file.- Parameters:
file
- the file to read the DigraphEdgeList from- Returns:
- the DigraphEdgeList read from the file
-
getTmpFolder
Returns the temporary folder used by the application. If the folder doesn't exist, it creates a new one. Also, if the recent files file doesn't exist, it creates a new one.- Returns:
- the temporary folder used by the application
- Throws:
IOException
- if an I/O error occurs while creating the folder or file
-
getRecentFiles
Retrieves a list of recent files.- Returns:
- A list of recently accessed files.
-
recordRecentFile
Records the given file as a recent file in the application. If the file already exists in the recent files list, it is removed and added to the top. If the number of recent files exceeds the maximum limit, the oldest file is removed.- Parameters:
file
- the file to be recorded as a recent file
-
clearRecentFiles
public static void clearRecentFiles()Clears the list of recent files. This method deletes the file that stores the list of recent files. If the file does not exist or cannot be deleted, an IOException is thrown. -
save
public static void save()Saves the currently opened file. -
read
Reads a DigraphEdgeList from a file.- Returns:
- the DigraphEdgeList read from the file
-
showOpenDialog
Represents a file in the file system. -
showSaveDialog
Represents a file in the file system.
-