com.digitalsanctuary.atg.util
Class StringLengthComparator

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

public class StringLengthComparator
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 shortest to longest. Note: this comparator imposes orderings that are inconsistent with equals.

Author:
Devon Hillard

Constructor Summary
StringLengthComparator()
           
 
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

StringLengthComparator

public StringLengthComparator()
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 shorter than, equal to, or longer 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)