Back to index

wims  3.65+svn20090927
Public Member Functions | Protected Member Functions | Package Functions | Package Attributes
rene.util.FileList Class Reference

This class parses a subtree for files that match a pattern. More...

Inheritance diagram for rene.util.FileList:
Inheritance graph
[legend]
Collaboration diagram for rene.util.FileList:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FileList (String dir, String filter, boolean recurse)
 FileList (String dir, String filter)
 FileList (String dir)
void setCase (boolean usecase)
void search ()
Enumeration files ()
 Return an Enumeration with the files.
Enumeration dirs ()
 Return an Enumeration with the directories.
int size ()
void sort ()
 Sort the result.
void sort (int type)
void stopIt ()
 This stops the search from other threads.
String getDir ()
 Returns a canonical version of the directory.

Protected Member Functions

boolean directory (File dir)
boolean file (File file)
void parsed (File dir)

Package Functions

void find (File dir, FileFilter filter)
boolean match (char filename[], int n, char filter[], int m)

Package Attributes

Vector V = new Vector()
Vector Vdir = new Vector()
boolean Stop
boolean Recurse
String Dir
String Filter
boolean UseCase = false

Detailed Description

This class parses a subtree for files that match a pattern.

The pattern may contain one or more * and ? as usual. The class delivers an enumerator for the files, or may be subclassed to handle the files directly. The routines directory and file can be used to return, if more scanning is necessary.

Definition at line 63 of file FileList.java.


Constructor & Destructor Documentation

rene.util.FileList.FileList ( String  dir,
String  filter,
boolean  recurse 
) [inline]

Definition at line 69 of file FileList.java.

       {      Stop=false;
              Recurse=recurse;
              Dir=dir;
              Filter=filter;
              if (Dir.equals("-"))
              {      Dir=".";
                     Recurse=false;
              }
              else if (Dir.startsWith("-"))
              {      Dir=Dir.substring(1);
                     Recurse=false;
              }
       }
rene.util.FileList.FileList ( String  dir,
String  filter 
) [inline]

Definition at line 83 of file FileList.java.

       {      this(dir,filter,true);
       }
rene.util.FileList.FileList ( String  dir) [inline]

Definition at line 86 of file FileList.java.

       {      this(dir,"*",true);
       }

Member Function Documentation

boolean rene.util.FileList.directory ( File  dir) [inline, protected]
Parameters:
fileThe directory that has been found.
Returns:
false if recursion should stop here. (i.e. that directory needs not be parsed).

Definition at line 183 of file FileList.java.

       {      return true;
       }

Here is the caller graph for this function:

Enumeration rene.util.FileList.dirs ( ) [inline]

Return an Enumeration with the directories.

Definition at line 149 of file FileList.java.

       {      return Vdir.elements();
       }

Here is the caller graph for this function:

boolean rene.util.FileList.file ( File  file) [inline, protected]
Parameters:
fileThe file that has been found.
Returns:
false if you need no more file at all.

Reimplemented in rene.dialogs.FileListFinder.

Definition at line 190 of file FileList.java.

       {      return true;
       }

Here is the caller graph for this function:

Enumeration rene.util.FileList.files ( ) [inline]

Return an Enumeration with the files.

Definition at line 143 of file FileList.java.

       {      return V.elements();
       }

Here is the caller graph for this function:

void rene.util.FileList.find ( File  dir,
FileFilter  filter 
) [inline, package]

Definition at line 98 of file FileList.java.

       {      if (!directory(dir)) return;
              String list[]=dir.list();
              loop : for (int i=0; i<list.length; i++)
              {      SortFile file=new SortFile(dir,list[i]);
                     if (file.isDirectory()) 
                     {      Vdir.addElement(file);
                            if (Recurse) find(file,filter);
                     }
                     else 
                     {      String filename=file.getName();
                            if (!UseCase) filename=filename.toLowerCase();
                            char fn[]=filename.toCharArray();
                            for (int j=0; j<filter.filterCount(); j++)
                            {      if (match(fn,0,filter.filter(j),0))
                                   {      Stop=!file(file);
                                          if (Stop) break loop;
                                          V.addElement(file);
                                   }
                            }
                     }
                     if (Stop) break;
              }
              parsed(dir);
       }

Here is the call graph for this function:

Here is the caller graph for this function:

String rene.util.FileList.getDir ( ) [inline]

Returns a canonical version of the directory.

Definition at line 208 of file FileList.java.

       {      File dir=new File(Dir);
              try
              {      return (dir.getCanonicalPath());
              }
              catch (Exception e)
              {      return "Dir does not exist!";
              }
       }
boolean rene.util.FileList.match ( char  filename[],
int  n,
char  filter[],
int  m 
) [inline, package]

Definition at line 123 of file FileList.java.

       {      if (filter==null) return true;
              if (m>=filter.length) return n>=filename.length;
              if (n>=filename.length) return m==filter.length-1 && filter[m]=='*';
              if (filter[m]=='?')
              {      return match(filename,n+1,filter,m+1);
              }
              if (filter[m]=='*')
              {      if (m==filter.length-1) return true;
                     for (int i=n; i<filename.length; i++)
                     {      if (match(filename,i,filter,m+1)) return true;
                     }
                     return false;
              }
              if (filter[m]==filename[n]) return match(filename,n+1,filter,m+1);
              return false;
       }

Here is the caller graph for this function:

void rene.util.FileList.parsed ( File  dir) [inline, protected]
Parameters:
parsedThe directory that has been parsed.

Definition at line 196 of file FileList.java.

       {
       }

Here is the caller graph for this function:

void rene.util.FileList.search ( ) [inline]

Definition at line 92 of file FileList.java.

       {      Stop=false;   
              File file=new File(Dir);
              if (!UseCase) Filter=Filter.toLowerCase();
              if (file.isDirectory()) find(file,new FileFilter(Filter));
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.util.FileList.setCase ( boolean  usecase) [inline]

Definition at line 89 of file FileList.java.

       {      UseCase=usecase;
       }

Here is the caller graph for this function:

int rene.util.FileList.size ( ) [inline]
Returns:
The number of files found.

Definition at line 155 of file FileList.java.

       {      return V.size();
       }
void rene.util.FileList.sort ( ) [inline]

Sort the result.

Definition at line 161 of file FileList.java.

       {      int i,n=V.size();
              SortObject v[]=new SortObject[n];
              for (i=0; i<n; i++) v[i]=(SortFile)V.elementAt(i);
              Sorter.sort(v);
              for (i=0; i<n; i++) V.setElementAt(v[i],i);
              n=Vdir.size();
              v=new SortObject[n];
              for (i=0; i<n; i++) v[i]=(SortFile)Vdir.elementAt(i);
              Sorter.sort(v);
              for (i=0; i<n; i++) Vdir.setElementAt(v[i],i);
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.util.FileList.sort ( int  type) [inline]

Definition at line 173 of file FileList.java.

       {      SortFile.SortBy=type;
              sort();
              SortFile.SortBy=SortFile.NAME;
       }

Here is the call graph for this function:

void rene.util.FileList.stopIt ( ) [inline]

This stops the search from other threads.

Definition at line 202 of file FileList.java.

       {      Stop=true;
       }

Here is the caller graph for this function:


Member Data Documentation

String rene.util.FileList.Dir [package]

Definition at line 67 of file FileList.java.

String rene.util.FileList.Filter [package]

Definition at line 67 of file FileList.java.

Definition at line 66 of file FileList.java.

Definition at line 65 of file FileList.java.

Definition at line 68 of file FileList.java.

Vector rene.util.FileList.V = new Vector() [package]

Definition at line 64 of file FileList.java.

Vector rene.util.FileList.Vdir = new Vector() [package]

Definition at line 64 of file FileList.java.


The documentation for this class was generated from the following file: