org.norther.tammi.acorn.io
Class PathNameComparator

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

public class PathNameComparator
extends FileNameComparator

A comparator for path names. The paths are considered equal if the shorter one is included in the longer one. Otherwise the path name is ignored in sorting.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
PathNameComparator()
          Constructs a new comparator.
PathNameComparator(boolean desc)
          Constructs a new comparator with order.
 
Method Summary
protected  int compare(File file1, File file2)
          Compares two file names in ascending order.
 
Methods inherited from class org.norther.tammi.acorn.io.FileNameComparator
compare
 
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

PathNameComparator

public PathNameComparator()
Constructs a new comparator.


PathNameComparator

public PathNameComparator(boolean desc)
Constructs a new comparator with order.

Parameters:
desc - true for descending order.
Method Detail

compare

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

Overrides:
compare in class FileNameComparator
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.