org.clapper.util.io
Class FileNameComparator
- java.lang.Object
-
- 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.
-
-
Constructor Summary
Constructors Constructor and Description FileNameComparator()Construct a new FileNameComparator with the default settings.FileNameComparator(boolean foldCase, boolean entirePath)Construct a new FileNameComparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intcompare(java.lang.Object o1, java.lang.Object o2)Compares its two arguments for order.booleanequals(java.lang.Object o)Indicates whether some other object is "equal to" this Comparator.inthashCode()Get the hash code for this object.
-
-
-
Constructor Detail
-
FileNameComparator
public FileNameComparator()
Construct a new FileNameComparator with the default settings. The default settings are:- Compare only file names, not paths
- Use case-sensitive comparison
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 comparisonentirePath- 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:
comparein interfacejava.util.Comparator<java.lang.Object>- Parameters:
o1- the first object to be comparedo2- 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:
equalsin interfacejava.util.Comparator<java.lang.Object>- Overrides:
equalsin classjava.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:
hashCodein classjava.lang.Object- Returns:
- the hash code
-
-
DMelt 3.0 © DataMelt by jWork.ORG