Class MRUFileManager
- java.lang.Object
-
- org.apache.log4j.lf5.viewer.configure.MRUFileManager
-
public class MRUFileManager extends java.lang.Object
MRUFileManager handles the storage and retrival the most recently opened log files.
-
-
Field Summary
Fields Modifier and Type Field Description private int
_maxSize
private java.util.LinkedList
_mruFileList
private static java.lang.String
CONFIG_FILE_NAME
private static int
DEFAULT_MAX_SIZE
-
Constructor Summary
Constructors Constructor Description MRUFileManager()
MRUFileManager(int maxSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
createConfigurationDirectory()
Creates the directory where the MRU file list will be written.java.lang.Object
getFile(int index)
Returns a particular file name stored in a MRU file list based on an index value.protected java.lang.String
getFilename()
java.io.InputStream
getInputStream(int index)
Returns a input stream to the resource at the specified indexprotected java.io.InputStream
getInputStream(java.io.File file)
Gets an input stream for the corresponding file.protected java.io.InputStream
getInputStream(java.net.URL url)
Gets an input stream for the corresponding URL.java.lang.String[]
getMRUFileList()
Gets the list of files stored in the MRU file list.protected void
load()
Loads the MRU file list in from a file and stores it in a LinkedList.void
moveToTop(int index)
Moves the the index to the top of the MRU Listvoid
save()
Saves a list of MRU files out to a file.void
set(java.io.File file)
Adds a file name to the MRU file list.void
set(java.net.URL url)
Adds a url to the MRU file list.protected void
setMaxSize(int maxSize)
Ensures that the MRU list will have a MaxSize.protected void
setMRU(java.lang.Object o)
Adds an object to the mru.int
size()
Gets the size of the MRU file list.
-
-
-
Field Detail
-
CONFIG_FILE_NAME
private static final java.lang.String CONFIG_FILE_NAME
- See Also:
- Constant Field Values
-
DEFAULT_MAX_SIZE
private static final int DEFAULT_MAX_SIZE
- See Also:
- Constant Field Values
-
_maxSize
private int _maxSize
-
_mruFileList
private java.util.LinkedList _mruFileList
-
-
Method Detail
-
save
public void save()
Saves a list of MRU files out to a file.
-
size
public int size()
Gets the size of the MRU file list.
-
getFile
public java.lang.Object getFile(int index)
Returns a particular file name stored in a MRU file list based on an index value.
-
getInputStream
public java.io.InputStream getInputStream(int index) throws java.io.IOException, java.io.FileNotFoundException
Returns a input stream to the resource at the specified index- Throws:
java.io.IOException
java.io.FileNotFoundException
-
set
public void set(java.io.File file)
Adds a file name to the MRU file list.
-
set
public void set(java.net.URL url)
Adds a url to the MRU file list.
-
getMRUFileList
public java.lang.String[] getMRUFileList()
Gets the list of files stored in the MRU file list.
-
moveToTop
public void moveToTop(int index)
Moves the the index to the top of the MRU List- Parameters:
index
- The index to be first in the mru list
-
createConfigurationDirectory
public static void createConfigurationDirectory()
Creates the directory where the MRU file list will be written. The ".logfactor5" directory is created in the Documents and Settings directory on Windows 2000 machines and where ever the user.home variable points on all other platforms.
-
getInputStream
protected java.io.InputStream getInputStream(java.io.File file) throws java.io.IOException, java.io.FileNotFoundException
Gets an input stream for the corresponding file.- Parameters:
file
- The file to create the input stream from.- Returns:
- InputStream
- Throws:
java.io.IOException
java.io.FileNotFoundException
-
getInputStream
protected java.io.InputStream getInputStream(java.net.URL url) throws java.io.IOException
Gets an input stream for the corresponding URL.- Parameters:
url
- The url to create the input stream from.- Returns:
- InputStream
- Throws:
java.io.IOException
-
setMRU
protected void setMRU(java.lang.Object o)
Adds an object to the mru.
-
load
protected void load()
Loads the MRU file list in from a file and stores it in a LinkedList. If no file exists, a new LinkedList is created.
-
getFilename
protected java.lang.String getFilename()
-
setMaxSize
protected void setMaxSize(int maxSize)
Ensures that the MRU list will have a MaxSize.
-
-