org.cdlib.xtf.util
Class SubDirFilter

Object
  extended by SubDirFilter

public class SubDirFilter
extends Object

This class provides an efficient means to determine if a given subdirectory is "in" or "out" of the set of directories specified to index. Essentially, if a given directory has an ancestor or a descendant in the set, it qualifies. That is, ancestors and cousins of the set directories will be indexed, but not necessarily all the cousins, nephews, nieces, etc.


Field Summary
private  HashSet<String> ancestors
           
private  HashSet<String> targets
           
 
Constructor Summary
SubDirFilter()
           
 
Method Summary
 void add(File dirFile)
          Adds a directory to the set.
private  ArrayList<String> ancestorOrSelf(File dir)
          Make a list of the directory and all its ancestors.
 boolean approve(File dirFile)
          Checks if the given directory is in the set, where "in" is defined as having an ancestor or descendant within the set.
 boolean approve(String dir)
          Checks if the given directory is in the set, where "in" is defined as having an ancestor or descendant within the set.
 List<String> getTargets()
          Get a list of all targets in lexicographic order.
 boolean isEmpty()
          Tell if nothing has been added yet
 int size()
          Returns the number of targets that have been added to the filter.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

targets

private HashSet<String> targets

ancestors

private HashSet<String> ancestors
Constructor Detail

SubDirFilter

public SubDirFilter()
Method Detail

isEmpty

public boolean isEmpty()
Tell if nothing has been added yet


add

public void add(File dirFile)
Adds a directory to the set.


size

public int size()
Returns the number of targets that have been added to the filter.


getTargets

public List<String> getTargets()
Get a list of all targets in lexicographic order.


approve

public boolean approve(String dir)
Checks if the given directory is in the set, where "in" is defined as having an ancestor or descendant within the set.


approve

public boolean approve(File dirFile)
Checks if the given directory is in the set, where "in" is defined as having an ancestor or descendant within the set.


ancestorOrSelf

private ArrayList<String> ancestorOrSelf(File dir)
Make a list of the directory and all its ancestors.