Class PageSorter

java.lang.Object
org.apache.wiki.pages.PageSorter
All Implemented Interfaces:
Comparator<String>

public class PageSorter
extends Object
implements Comparator<String>
Wrapper class for managing and using the PageNameComparator.

Note - this class is deliberately not null safe. Never call any of the methods with a null argument!

  • Field Details

  • Constructor Details

    • PageSorter

      public PageSorter()
      Default constructor uses Java "natural" ordering.
    • PageSorter

      public PageSorter​(Comparator<String> comparator)
      Construct with a particular comparator.
      Parameters:
      comparator - the Comparator to use
  • Method Details

    • compare

      public int compare​(String pageName1, String pageName2)
      Compare two page names (String version).
      Specified by:
      compare in interface Comparator<String>
      Parameters:
      pageName1 - the first page name
      pageName2 - the second page name
      Returns:
      see java.util.Comparator
      See Also:
      Comparator.compare(java.lang.Object, java.lang.Object)
    • equals

      public boolean equals​(Object o)
      Specified by:
      equals in interface Comparator<String>
      Overrides:
      equals in class Object
    • initialize

      public void initialize​(Properties props)
      Called by Engine to initialise this instance. Tries to use class given by the PROP_PAGE_NAME_COMPARATOR property as the page name comparator. Uses a default comparator if this property is not set or there is any problem loading the specified class.
      Parameters:
      props - this Engine's properties.
    • sort

      public void sort​(List<String> nameList)
      Sorts the specified list into ascending order based on the PageNameComparator. The actual sort is done using List.sort().
      Parameters:
      nameList - the page names to be sorted
    • sort

      public void sort​(String[] nameArray)
      Sorts the specified array into ascending order based on the PageNameComparator. The actual sort is done using Arrays.sort().
      Parameters:
      nameArray - the page names to be sorted