org.norther.tammi.acorn.io
Class FileNameComparator

java.lang.Object
  extended by org.norther.tammi.acorn.io.FileNameComparator
All Implemented Interfaces:
Serializable, Comparator
Direct Known Subclasses:
PathNameComparator

public class FileNameComparator
extends Object
implements Comparator, Serializable

A comparator for file names. The path is ignored.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
FileNameComparator()
          Constructs a new comparator.
FileNameComparator(boolean ign)
          Constructs a new comparator with suffix ignored.
 
Method Summary
protected  int compare(File file1, File file2)
          Compares two file names in ascending order.
 int compare(Object file1, Object file2)
          Compares two file names.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

FileNameComparator

public FileNameComparator()
Constructs a new comparator.


FileNameComparator

public FileNameComparator(boolean ign)
Constructs a new comparator with suffix ignored.

Parameters:
ign - true for ignored suffix.
Method Detail

compare

public int compare(Object file1,
                   Object file2)
Compares two file names.

Specified by:
compare in interface Comparator
Parameters:
file1 - the first file to be compared.
file2 - the second file to be compared.
Returns:
-1, 0 or 1 based on comparison.
Throws:
NullPointerException - for null files.
ClassCastException - if parameters are not files.

compare

protected int compare(File file1,
                      File file2)
Compares two file names in ascending order.

Parameters:
file1 - the first file to be compared.
file2 - the second file to be compared.
Returns:
-1, 0 or 1 based on comparison.
Throws:
NullPointerException - for null files.


Copyright © 2004 The Norther Organization. All rights reserved.