|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.mucommander.file.util.FileComparator
public class FileComparator
FileComparator compares AbstractFile instances using a comparison criterion order (ascending or descending).
Directories can either be mixed with regular files (compared just as regular files), or always precede regular files.
FileComparator extends Comparator and thus can be used wherever a Comparator is accepted. In particular, it
can be used with java.util.Arrays sort methods to easily sort an array of files.
The following criteria are available:
NAME_CRITERION: compares filenames returned by AbstractFile.getName()
SIZE_CRITERION: compares file sizes returned by AbstractFile.getSize(). Note: size for
directories is always considered as 0, even if AbstractFile.getSize() returns something else.
DATE_CRITERION: compares file dates returned by AbstractFile.getDate()
EXTENSION_CRITERION: compares file extensions returned by AbstractFile.getExtension()
PERMISSIONS_CRITERION: compares file permissions returned by AbstractFile.getPermissions()
| Field Summary | |
|---|---|
static int |
DATE_CRITERION
Criterion for file date comparison. |
static int |
EXTENSION_CRITERION
Criterion for file extension comparison. |
static int |
GROUP_CRITERION
Criterion for group comparison. |
static int |
NAME_CRITERION
Criterion for filename comparison. |
static int |
OWNER_CRITERION
Criterion for owner comparison. |
static int |
PERMISSIONS_CRITERION
Criterion for file permissions comparison. |
static int |
SIZE_CRITERION
Criterion for file size comparison. |
| Constructor Summary | |
|---|---|
FileComparator(int criterion,
boolean ascending,
boolean directoriesFirst)
Creates a new FileComparator using the specified comparison criterion, order (ascending or descending) and directory handling rule. |
|
| Method Summary | |
|---|---|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
|
boolean |
equals(java.lang.Object o)
Returns true only if the given object is a FileComparator using the same criterion and ascending/descending order. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int NAME_CRITERION
public static final int SIZE_CRITERION
public static final int DATE_CRITERION
public static final int EXTENSION_CRITERION
public static final int PERMISSIONS_CRITERION
public static final int OWNER_CRITERION
public static final int GROUP_CRITERION
| Constructor Detail |
|---|
public FileComparator(int criterion,
boolean ascending,
boolean directoriesFirst)
criterion - comparison criterion, see constant fieldsascending - if true, ascending order will be used, descending order otherwisedirectoriesFirst - specifies whether directories should precede files or be handled as regular files| Method Detail |
|---|
public int compare(java.lang.Object o1,
java.lang.Object o2)
compare in interface java.util.Comparatorpublic boolean equals(java.lang.Object o)
equals in interface java.util.Comparatorequals in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard