com.faunos.util.io.file
Class DirectoryOrdering
java.lang.Object
com.faunos.util.io.file.DirectoryOrdering
- All Implemented Interfaces:
- Comparator<File>
public class DirectoryOrdering
- extends Object
- implements Comparator<File>
Represent 2 types of file orderings by differentiating ordinary files
from directories. The implementation is used to prioritize how
files or directories are visited first by a FileSystemTraverser instance.
- Author:
- Babak Farhang
- See Also:
AbstractTraverser.setSiblingOrder(Comparator)
DIR_FIRST
public static final DirectoryOrdering DIR_FIRST
- Directory precedence.
FILE_FIRST
public static final DirectoryOrdering FILE_FIRST
- Ordinary file precedence.
DirectoryOrdering
public DirectoryOrdering(DirectoryOrdering.Precedence type)
compare
public int compare(File f1,
File f2)
- Specified by:
compare
in interface Comparator<File>
compareSameType
protected int compareSameType(File f1,
File f2)
- Hook for subclass refinement of ordering. Invoked when the 2 files being
compared are either both directories,
or both ordinary files. The default implementation just uses the natural
ordering of Files.
- Returns:
- f1.
compareTo
(f2)
equals
public final boolean equals(Object obj)
- Specified by:
equals
in interface Comparator<File>
- Overrides:
equals
in class Object
hashCode
public final int hashCode()
- Overrides:
hashCode
in class Object