com.atlassian.confluence.pages
Class NaturalStringComparator

java.lang.Object
  extended by com.atlassian.confluence.pages.NaturalStringComparator
All Implemented Interfaces:
java.util.Comparator<java.lang.String>

public class NaturalStringComparator
extends java.lang.Object
implements java.util.Comparator<java.lang.String>

A comparator makes string comparisons based on their natural order. The logic used to perform the natrual comparison is taken from the original page tree macro, the complete source can be found here: https://svn.atlassian.com/svn/public/contrib/confluence/pagetree-plugin/tags/pagetree-plugin-1.6/src/main/java/com/eekboom/utils/Strings.java A google search revealed that this class was probably taken from this blog post: http://weblogs.java.net/blog/skelvin/archive/2006/01/natural_string.html I refactored the original static util class into a comparator because static util classes are bad.


Constructor Summary
NaturalStringComparator()
          Constructs a comparator for the default system locale.
NaturalStringComparator(java.util.Locale locale)
          Constructs a comparator using the specified locale.
 
Method Summary
 int compare(java.lang.String arg0, java.lang.String arg1)
           
 
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

NaturalStringComparator

public NaturalStringComparator()
Constructs a comparator for the default system locale.

See Also:
Collator.getInstance()

NaturalStringComparator

public NaturalStringComparator(java.util.Locale locale)
Constructs a comparator using the specified locale.

See Also:
Collator.getInstance(Locale)
Method Detail

compare

public int compare(java.lang.String arg0,
                   java.lang.String arg1)
Specified by:
compare in interface java.util.Comparator<java.lang.String>


Copyright © 2003-2014 Atlassian. All Rights Reserved.