com.faunos.util.io.file
Class DirectoryOrdering

java.lang.Object
  extended by 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)

Nested Class Summary
static class DirectoryOrdering.Precedence
          Represents the ordering: directories first, or files first.
 
Field Summary
static DirectoryOrdering DIR_FIRST
          Directory precedence.
static DirectoryOrdering FILE_FIRST
          Ordinary file precedence.
 
Constructor Summary
DirectoryOrdering(DirectoryOrdering.Precedence type)
           
 
Method Summary
 int compare(File f1, File f2)
           
protected  int compareSameType(File f1, File f2)
          Hook for subclass refinement of ordering.
 boolean equals(Object obj)
           
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIR_FIRST

public static final DirectoryOrdering DIR_FIRST
Directory precedence.


FILE_FIRST

public static final DirectoryOrdering FILE_FIRST
Ordinary file precedence.

Constructor Detail

DirectoryOrdering

public DirectoryOrdering(DirectoryOrdering.Precedence type)
Method Detail

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


SourceForge.net Logo