org.clapper.util.io
Class FileNameComparator

java.lang.Object
  extended by org.clapper.util.io.FileNameComparator
All Implemented Interfaces:
java.util.Comparator<java.lang.Object>

public class FileNameComparator
extends java.lang.Object
implements java.util.Comparator<java.lang.Object>

FileNameComparator implements a Comparator class that compares file names (expressed either as String or File objects) for sorting. The comparison can be case-sensitive or case-insensitive, and can apply to the entire path (if available) or just the file name part.

Version:
$Revision: 6735 $
Author:
Copyright © 2004-2007 Brian M. Clapper

Constructor Summary
FileNameComparator()
          Construct a new FileNameComparator with the default settings.
FileNameComparator(boolean foldCase, boolean entirePath)
          Construct a new FileNameComparator.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares its two arguments for order.
 boolean equals(java.lang.Object o)
          Indicates whether some other object is "equal to" this Comparator.
 int hashCode()
          Get the hash code for this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileNameComparator

public FileNameComparator()
Construct a new FileNameComparator with the default settings. The default settings are: Calling this constructor is equivalent to:
Comparator cmp = new FileNameComparator (false, false);


FileNameComparator

public FileNameComparator(boolean foldCase,
                          boolean entirePath)
Construct a new FileNameComparator.

Parameters:
foldCase - true for case-insensitive comparison, false for case-sensitive comparison
entirePath - true to compare the entire path (where available, false to use just the name.
Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Specified by:
compare in interface java.util.Comparator<java.lang.Object>
Parameters:
o1 - the first object to be compared
o2 - the second object to be compared
Returns:
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

equals

public boolean equals(java.lang.Object o)

Indicates whether some other object is "equal to" this Comparator.

Specified by:
equals in interface java.util.Comparator<java.lang.Object>
Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare
Returns:
true only if the pecified object is also a comparator and it imposes the same ordering as this comparator.

hashCode

public int hashCode()
Get the hash code for this object.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code


Copyright © 2004-2007 Brian M. Clapper. All Rights Reserved.