Sharkysoft home

lava.io
Class PathSet

java.lang.Object
  |
  +--lava.io.PathSet

public class PathSet
extends java.lang.Object

Unique file list manager.

Details: PathSet is an ordered file set manager designed to help you generate a file list from user-supplied arguments. It allows you to add and subtract sets of files either by naming the individual files or by naming directories that can be searched recursively.

PathSet detects duplicate entries and automatically keeps them out of the set. PathSet even detects when two apparently different paths represent the same path due to "symlink magic." PathSet also preserves the order in which the files were added. When two equivalent paths are added, the first path added gets priority, unless the first is removed before the second is added.

After a set is formed, iterator methods can be used to walk through the ordered list of files.

Since:
2000.07.08
Version:
2001.03.09
Author:
Sharky

Constructor Summary
PathSet(boolean dirs_allowed)
          Initializes empty set.
 
Method Summary
 void add(java.io.File file)
          Convenience method.
 void add(Path path)
          Appends path to set.
 void addRecursively(java.io.File file)
          Convenience method.
 void addRecursively(Path path)
          Appends directory to set.
 java.util.Enumeration enumerate()
          Enumerates set.
 void remove(java.io.File file)
          Convenience method.
 void remove(Path path)
          Removes path from set.
 void removeRecursively(java.io.File file)
          Convenience method.
 void removeRecursively(Path path)
          Removes directory from set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathSet

public PathSet(boolean dirs_allowed)
Initializes empty set.

Details: This constructor initializes an empty set and determines whether directory paths (as opposed to actual files) can be added to the set. If dirs_allowed is true, the set will accept directory paths. Otherwise, directory paths will be automatically discarded when added.

Parameters:
dirs_allowed -  
Method Detail

add

public void add(Path path)
         throws java.io.IOException
Appends path to set.

Details: add appends the given path (path) to the end of the set if the path is not already a member of the set. path will not be retained in the set if it is a directory and dirs_allowed is false.

Polymorphism warning: This method is called by add(String) and addRecursively(Path).

Parameters:
path - the path to add
Throws:
java.io.IOException - if file examination fails

add

public final void add(java.io.File file)
               throws java.io.IOException
Convenience method.

Details: This convenience method converts the given File to a Path and calls add(Path).


addRecursively

public void addRecursively(Path path)
                    throws java.io.IOException
Appends directory to set.

Details: addRecursively appends the given Path and, if it is a directory, all of the Paths underneath it, recursively, to the set. Some paths may not be added if they represent directories and allow_dirs is false.

Polymorphism warnings: This method calls add(Path) for each individual path added to the set. This method is called by addRecursively(String).

Parameters:
path - the path to add
Throws:
java.io.IOException - if file examination fails

addRecursively

public final void addRecursively(java.io.File file)
                          throws java.io.IOException
Convenience method.

Details: This convenience method converts the given File to a Path and calls addRecursively(Path).


remove

public void remove(Path path)
            throws java.io.IOException
Removes path from set.

Details: remove removes the given Path (path) from this set if it is currently in the set. If path is not in the set, this method has no effect.

Polymorphism warning: This method is called by remove(String) and removeRecursively(Path)

Parameters:
path - the path to remove

remove

public void remove(java.io.File file)
            throws java.io.IOException
Convenience method.

Details: This convenience method converts the given File to a Path and calls remove(Path).


removeRecursively

public void removeRecursively(Path path)
                       throws java.io.IOException
Removes directory from set.

Details: remove removes the given Path (path) and, if it is a directory, all of the Paths underneath it, recursively, from this set.

Polymorphism warnings: This method calls remove(Path) for each individual Path to be removed from the set. This method is called by removeRecursively(String).

Parameters:
path - the path to remove

removeRecursively

public void removeRecursively(java.io.File file)
                       throws java.io.IOException
Convenience method.

Details: This convenience method converts the given File to a Path and calls removeRecursively(Path).


enumerate

public java.util.Enumeration enumerate()
Enumerates set.

Details: enumerate returns and Enumeration that lists every Path currently in this set.

Returns:
the Enumeration
Since:
2001.03.09

Sharkysoft home