org.alltimeflashdreamer.filelister
Class FileLister

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.ArrayList
              extended byorg.alltimeflashdreamer.filelister.FileLister
All Implemented Interfaces:
Cloneable, Collection, List, RandomAccess, Serializable

public class FileLister
extends ArrayList

Title: FileLister

Description: This class is the core of the FileLister application. It searches the file system downwards, starting with the root directory defined in the FileListerConfig object. The found files (which may be directories too, of course) are collected, if they match the search string's restrictions.

Organization: All Time Flash Dreamer

Version:
0.5.1
Author:
Copyright (c) 2002-2004 by Florian Steinsiepe
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.AbstractList
 
Field Summary
(package private) static boolean ISWINDOWS
          often used value to find out whether the platform is Windows or not
static String VERSIONNUMBER
          Defines the version number of the FileLister (is shown in the JSP output)
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
(package private) FileLister(FileListerConfig fileListerConfig, boolean bQuietMode)
          If it's the directory input mode, it's checked whether the researching of the given directory is allowed again or not, depending on the index aging parameter of the property file, compared with the "last indexed" value and the current time.
 
Method Summary
(package private)  int getChildCount(FileListerEntry fileListerEntry)
          If the given FileListerEntry represents a file, 0 is returned, else the index is queried for the child count of the given directory.
(package private)  ArrayList getFileListerEntriesForZip()
          Returns an list containing the selected FileListerEntries within the FileLister or null, if none are selected.
(package private)  long getLastIndexed()
          Returns the indexing time (as long) of the directory node entry of the user's search directory.
(package private) static String getRealPath(File dir)
          Returns either the canonical path or, in case of a windows drive letter, the absolute path of the given directory.
 int getResultCount()
          Returns the total result count of the query that initialized the current instance of FileLister.
(package private)  int getTotalDumpedEntryCount()
          Returns the total amount of dumped FileListerEntry objects.
 FileListerEntry[] getVisibleFileListerEntries()
          Returns the sublist of visible FileListerEntry objects (in the GUI) in of the whole result set received from the underlying query.
(package private)  void prepareEntries(int iStartIndex)
          Makes sure that there are enough entries buffered in the memory to allow easy navigation, with only a few reloads.
(package private)  void processMultiSelectForZip(String sZipMode)
          Loops over all lists stored in this class and over all FileListerEntry instances within those lists and selects or unselects all the entries at once, but only if the given string equals "selectall" or "deselectall".
(package private)  void reloadIndex()
          Reloads the index from the database, very much like during construction.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Field Detail

VERSIONNUMBER

public static final String VERSIONNUMBER
Defines the version number of the FileLister (is shown in the JSP output)

See Also:
Constant Field Values

ISWINDOWS

static final boolean ISWINDOWS
often used value to find out whether the platform is Windows or not

Constructor Detail

FileLister

FileLister(FileListerConfig fileListerConfig,
           boolean bQuietMode)
     throws FileListerException
If it's the directory input mode, it's checked whether the researching of the given directory is allowed again or not, depending on the index aging parameter of the property file, compared with the "last indexed" value and the current time. If the researching is allowed, it's processed.
The database is queried (anyway, even after a rescan of the file system) for the entry with the id of the directory to be searched (which is retrieved first). If this entry isn't defined, the initial archiving process hasn't been done yet which leads to an exception.
The found files and/or directories are stored in the ArrayList itself, each represented by a FileListerEntry instance (strictly performance-oriented!).

Parameters:
fileListerConfig - the previously initialized config object
bQuietMode - whether to print messages to the System.out or not (true means "print no messages at all")
Throws:
FileListerException - each possible exception that may occur during the listing-of-files process
Method Detail

getRealPath

static String getRealPath(File dir)
                   throws IOException
Returns either the canonical path or, in case of a windows drive letter, the absolute path of the given directory.

Parameters:
dir - the directory to get the real path of
Returns:
the real path, as described above
Throws:
IOException - thrown on canonical file access

reloadIndex

void reloadIndex()
           throws FileListerException
Reloads the index from the database, very much like during construction. This method is helpful for using sort capabilities of the SQL server which need a full re-exectution of the underlying query, but with different sort criteria.

Throws:
FileListerException - if some problem occurred during reloading

getLastIndexed

long getLastIndexed()
Returns the indexing time (as long) of the directory node entry of the user's search directory. This value is representative for the whole tree down the search directory, although each directory has its own indexing time.

Returns:
the time to be shown to the client in the results site as the indexing time

getResultCount

public int getResultCount()
Returns the total result count of the query that initialized the current instance of FileLister. This value is received by one initial query on the result count (if necessary, i.e. if too many results were found).

Returns:
the result count of the initial query

getVisibleFileListerEntries

public FileListerEntry[] getVisibleFileListerEntries()
Returns the sublist of visible FileListerEntry objects (in the GUI) in of the whole result set received from the underlying query.

Returns:
the FileListerEntry[] containing all the currently visible search results

prepareEntries

void prepareEntries(int iStartIndex)
              throws FileListerException
Makes sure that there are enough entries buffered in the memory to allow easy navigation, with only a few reloads.

Parameters:
iStartIndex - the start index of the position where the user wants to see entries; this start index is used to load the files
Throws:
FileListerException - thrown if there were problems loading files into the list

getFileListerEntriesForZip

ArrayList getFileListerEntriesForZip()
Returns an list containing the selected FileListerEntries within the FileLister or null, if none are selected.

Returns:
an list of selected FileListerEntry objects for zip or null

getChildCount

int getChildCount(FileListerEntry fileListerEntry)
            throws FileListerException
If the given FileListerEntry represents a file, 0 is returned, else the index is queried for the child count of the given directory.

Parameters:
fileListerEntry - the entry to get the child count of
Returns:
0, if a file, else the database value
Throws:
FileListerException - wrapped SQLException, in case

getTotalDumpedEntryCount

int getTotalDumpedEntryCount()
Returns the total amount of dumped FileListerEntry objects. This number is always reset during creation of a new SimpleList (and of a new FileLister, of course).

Returns:
the total number of dumped entries

processMultiSelectForZip

void processMultiSelectForZip(String sZipMode)
Loops over all lists stored in this class and over all FileListerEntry instances within those lists and selects or unselects all the entries at once, but only if the given string equals "selectall" or "deselectall".

Parameters:
sZipMode - the string describing whether to select or unselect all the registered entries