com.digitalsanctuary.atg.util
Class StringLengthReverseComparator

java.lang.Object
  extended bycom.digitalsanctuary.atg.util.StringLengthReverseComparator
All Implemented Interfaces:
java.util.Comparator

public class StringLengthReverseComparator
extends java.lang.Object
implements java.util.Comparator

This comparator can be used to Sort Strings based on their length. If used for sorting a collection of Strings it will order them from longest to shortest. Note: this comparator imposes orderings that are inconsistent with equals.

Author:
Devon Hillard devon@digitalsanctuary.com copyright 2008 DigitalSanctuary Inc. All Rights Reserved.

Constructor Summary
StringLengthReverseComparator()
           
 
Method Summary
 int compare(java.lang.Object pStringOne, java.lang.Object pStringTwo)
          This comparator can be used to Sort Strings based on their length.
 
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

StringLengthReverseComparator

public StringLengthReverseComparator()
Method Detail

compare

public int compare(java.lang.Object pStringOne,
                   java.lang.Object pStringTwo)
This comparator can be used to Sort Strings based on their length. Note: this comparator imposes orderings that are inconsistent with equals.

Specified by:
compare in interface java.util.Comparator
Parameters:
pStringOne - the first String to Compare.
pStringTwo - the second String to Compare.
Returns:
a negative integer, zero, or a positive integer as the first String is longer than than, equal to, or shorter than the second.
Throws:
java.lang.ClassCastException - if either argument cannot be cast to a String.
See Also:
Comparator.compare(java.lang.Object, java.lang.Object)