Package org.apache.pdfbox.debugger.ui
Class RecentFiles
java.lang.Object
org.apache.pdfbox.debugger.ui.RecentFiles
A class to save recent file history in preference using java Preference api.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final String
private final int
private static final String
private static final String
private final Preferences
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a new file in recent file history.private String[]
breakString
(String fullPath) void
close()
This method save the present recent file history in the preference.getFiles()
This gives the file in descending order where order is according to the time it is added.boolean
isEmpty()
Check if file history is empty.void
Clear the previous recent file history.void
removeFile
(String path) Remove a file from recent file history.private void
writeHistoryToPref
(Queue<String> filePaths)
-
Field Details
-
KEY
- See Also:
-
PATH_KEY
- See Also:
-
PIECES_LENGTH_KEY
- See Also:
-
HISTORY_LENGTH
- See Also:
-
pref
-
filePaths
-
maximum
private final int maximum
-
-
Constructor Details
-
RecentFiles
Constructor.- Parameters:
className
- the class for which this Recentfiles object is created and it will be used to create preference instance.maximumFile
- the number of recent files to remember.
-
-
Method Details
-
removeAll
public void removeAll()Clear the previous recent file history. -
isEmpty
public boolean isEmpty()Check if file history is empty.- Returns:
- if history is empty return true otherwise return false.
-
addFile
Add a new file in recent file history.- Parameters:
path
- path to the file. this path means File#getPath() method returned String.
-
removeFile
Remove a file from recent file history.- Parameters:
path
- path string to the file. this path means File#getPath() method returned String.
-
getFiles
This gives the file in descending order where order is according to the time it is added. This checks for file's existence in file history.- Returns:
- return the file paths in a List.
-
close
This method save the present recent file history in the preference. To get the recent file history in next session this method must be called.- Throws:
IOException
- if saving in preference doesn't success.
-
breakString
-
writeHistoryToPref
-
readHistoryFromPref
-