|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfedora.utilities.FileComparator
public class FileComparator
Comparator for sorting files and directories in a deterministic manner. The sort order can be case-sensitive (default) or case-insensitive, ascending (default) or descending, with directories occurring before (if ascending) or after files within the same directory. The default behavior has the convenient property that it sorts in the same order as would be done when performing a pre-order traversal of the filesystem.
Example input: afile file1 file2 dir1/ FILE3 dir1/file4 dir2/file5 dir2/file10 dir2/ file6 Example output (with default behavior: case-sensitive, ascending): dir1 dir1\file4 dir2 dir2\file10 dir2\file5 FILE3 afile file1 file2 file6
| Constructor Summary | |
|---|---|
FileComparator()
Construct a case-sensitive comparator that sorts in ascending order. |
|
FileComparator(boolean useDescendingOrder)
Construct a case-sensitive comparator that sorts in the specified order. |
|
FileComparator(boolean useDescendingOrder,
boolean ignoreCase)
Construct a comparator that sorts in the specified order using the specified case sensitivity. |
|
| Method Summary | |
|---|---|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
|
boolean |
descends()
Does this comparator work for descending sorts? |
boolean |
equals(java.lang.Object o)
|
boolean |
ignoresCase()
Does this comparator ignore case? |
static void |
main(java.lang.String[] args)
Command-line entry point for simple testing of this class. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileComparator()
public FileComparator(boolean useDescendingOrder)
public FileComparator(boolean useDescendingOrder,
boolean ignoreCase)
| Method Detail |
|---|
public int compare(java.lang.Object o1,
java.lang.Object o2)
compare in interface java.util.Comparatorpublic boolean descends()
public boolean ignoresCase()
public boolean equals(java.lang.Object o)
equals in interface java.util.Comparatorequals in class java.lang.Objectpublic static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||