public class RecentFileTracker
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_BUFFER_SIZE
default buffer size for a tracker
|
protected java.lang.String |
PREFERENCE_ID
ID for the preferences
|
protected java.util.prefs.Preferences |
PREFS
preferences storage
|
protected int |
RECENT_URLS_BUFFER_SIZE
buffer size for this tracker
|
Constructor and Description |
---|
RecentFileTracker(java.lang.Class<?> preferenceNode,
java.lang.String preferenceID)
Constructor with a default buffer size of 10
|
RecentFileTracker(int bufferSize,
java.lang.Class<?> preferenceNode,
java.lang.String preferenceID)
Constructor which generates the preferences from the specified preference node
|
RecentFileTracker(int bufferSize,
java.util.prefs.Preferences prefs,
java.lang.String preferenceID)
Primary constructor
|
Modifier and Type | Method and Description |
---|---|
javax.swing.JFileChooser |
applyMostRecentFile(javax.swing.JFileChooser fileChooser)
Set the file chooser's selected file to the most recent file.
|
javax.swing.JFileChooser |
applyRecentFolder(javax.swing.JFileChooser fileChooser)
Set the file chooser's current directory to the recent folder.
|
void |
cacheURL(java.io.File file)
Cache the URL of the specified file.
|
void |
cacheURL(java.lang.String urlSpec)
Cache the URL
|
void |
cacheURL(java.net.URL url)
Cache the URL.
|
void |
clearCache()
Clear the cache of the recent URL specs
|
java.io.File |
getMostRecentFile()
Get the most recent file
|
java.io.File |
getRecentFolder()
Get the folder corresponding to the most recently cached URL.
|
java.lang.String |
getRecentFolderPath()
Get the folder path corresponding to the most recently cached URL.
|
java.lang.String[] |
getRecentURLSpecs()
Get the array of URLs corresponding to recently registered URLs.
|
protected static java.lang.String[] |
getTokens(java.lang.String string)
Parse a string into tokens where whitespace is the delimiter.
|
protected static java.lang.String[] |
getTokens(java.lang.String string,
java.lang.String delim)
Parse a string into tokens with the specified delimiter.
|
protected static final int DEFAULT_BUFFER_SIZE
protected final int RECENT_URLS_BUFFER_SIZE
protected final java.util.prefs.Preferences PREFS
protected final java.lang.String PREFERENCE_ID
public RecentFileTracker(int bufferSize, java.util.prefs.Preferences prefs, java.lang.String preferenceID)
bufferSize
- the buffer size of the recent URL specs to cacheprefs
- the preferences used to save the cache of recent URL specspreferenceID
- the ID of the preference to savepublic RecentFileTracker(int bufferSize, java.lang.Class<?> preferenceNode, java.lang.String preferenceID)
bufferSize
- the buffer size of the recent URL specs to cachepreferenceNode
- the node used for saving the preferencepreferenceID
- the ID of the preference to savepublic RecentFileTracker(java.lang.Class<?> preferenceNode, java.lang.String preferenceID)
preferenceNode
- the node used for saving the preferencepreferenceID
- the ID of the preference to savepublic void clearCache()
public void cacheURL(java.io.File file)
file
- the file whose URL is to be cached.public void cacheURL(java.net.URL url)
url
- the URL to cache.public void cacheURL(java.lang.String urlSpec)
urlSpec
- the URL Spec to cache.public java.lang.String[] getRecentURLSpecs()
public java.io.File getRecentFolder()
public java.lang.String getRecentFolderPath()
public java.io.File getMostRecentFile()
public javax.swing.JFileChooser applyRecentFolder(javax.swing.JFileChooser fileChooser)
fileChooser
- the file chooser for which to set the current directorypublic javax.swing.JFileChooser applyMostRecentFile(javax.swing.JFileChooser fileChooser)
fileChooser
- the file chooser for which to set the current directoryprotected static java.lang.String[] getTokens(java.lang.String string)
string
- The string to parse.protected static java.lang.String[] getTokens(java.lang.String string, java.lang.String delim)
string
- The string to parse.delim
- The delimiter