public class PageSorter extends Object implements Comparator
Note - this class is deliberately not null safe. Never call any of the methods with a null argument!
Modifier and Type | Field and Description |
---|---|
protected static String |
PROP_PAGE_NAME_COMPARATOR |
Constructor and Description |
---|
PageSorter()
Default constructor uses Java "natural" ordering.
|
PageSorter(Comparator<String> comparator)
Construct with a particular comparator.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(Object o1,
Object o2)
Compare two page names (Object version).
|
int |
compare(String pageName1,
String pageName2)
Compare two page names (String version).
|
int |
compare(WikiPage page1,
WikiPage page2)
Compare two pages (WikiPage version).
|
boolean |
equals(Object o) |
void |
initialize(Properties props)
Called by WikiEngine to initialise this instance.
|
void |
sort(List<String> nameList)
Sorts the specified list into ascending order based on the
PageNameComparator.
|
void |
sort(String[] nameArray)
Sorts the specified array into ascending order based on the
PageNameComparator.
|
void |
sortPages(List<Object> pageList)
Sorts the specified list into ascending order based on the
PageNameComparator.
|
void |
sortPages(Object[] pageArray)
Sorts the specified array into ascending order based on the
PageNameComparator.
|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
protected static final String PROP_PAGE_NAME_COMPARATOR
public PageSorter()
public PageSorter(Comparator<String> comparator)
comparator
- the Comparator to usepublic int compare(Object o1, Object o2)
compare
in interface Comparator
IllegalArgumentException
- if incorrect argument types.Comparator.compare(java.lang.Object, java.lang.Object)
public int compare(String pageName1, String pageName2)
pageName1
- the first page namepageName2
- the second page nameComparator.compare(java.lang.Object, java.lang.Object)
public int compare(WikiPage page1, WikiPage page2)
page1
- the first pagepage2
- the second pageComparator.compare(java.lang.Object, java.lang.Object)
public boolean equals(Object o)
equals
in interface Comparator
equals
in class Object
public void initialize(Properties props)
props
- this WikiEngine's properties.public void sort(List<String> nameList)
Collections.sort()
.nameList
- the page names to be sortedpublic void sort(String[] nameArray)
Arrays.sort()
.nameArray
- the page names to be sortedpublic void sortPages(List<Object> pageList)
Collections.sort()
.pageList
- the pages to be sortedCopyright © 2001-2018 The Apache Software Foundation. All rights reserved.