@OpenApiAll public class SortTool extends Tool
Modifier and Type | Class and Description |
---|---|
protected static class |
SortTool.HumanAscendingSort
Sort Collection in ascending.
|
protected static class |
SortTool.HumanDescendingSort
sort Collection in descending.
|
ITool.HTMLString, ITool.RetainedString, ITool.Void
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONTEXT_NAME
Contains a context name.
|
context, properties
Constructor and Description |
---|
SortTool() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
getNextToken(java.lang.String str,
int offset,
int len)
Return a next token of string from starting offset.
|
protected java.lang.Object |
getValue(java.lang.Object object,
java.lang.String propertyName)
Look up a object value by property name.
|
java.util.Collection<?> |
humanSort(java.util.Collection<?> collection)
Special sorting function with human order, which says to split the text to be sorted into numeric and
non-numeric chunks, then sort so that the numeric chunks are treated as numbers.
|
java.util.Collection<?> |
humanSort(java.util.Collection<?> collection,
java.lang.String propertyName)
Special sorting function with human order, which says to split the text to be sorted into numeric and
non-numeric chunks, then sort so that the numeric chunks are treated as numbers.
|
java.util.Collection |
sort(java.util.Collection collection)
Sort function for template report.
|
java.util.Collection |
sort(java.util.Collection collection,
java.lang.String propertyName)
Sort function for template report.
|
java.util.Collection<java.lang.Object> |
sortByFirstNumber(java.util.Collection<?> collection)
Sort function with special text ordering.
|
java.util.Collection<java.lang.Object> |
sortByFirstNumber(java.util.Collection<?> collection,
java.lang.String propertyName)
Sort function with special text ordering.
|
java.util.Collection<java.lang.Object> |
sortByLocale(java.util.Collection<?> collection,
java.lang.String locale)
Sort the given collection by specified country code.
|
java.util.Collection<java.lang.Object> |
sortByLocale(java.util.Collection<?> collection,
java.lang.String propertyName,
java.lang.String locale)
Sort the given collection by specified country code.
|
clone, getContext, getProperties, getProperty, getProperty, notifyObservers, setContext, setProperties
public static final java.lang.String CONTEXT_NAME
public java.util.Collection sort(java.util.Collection collection, java.lang.String propertyName)
$sorter
<code> #foreach ($rel in $sorter.sort($package, "name:desc")) $rel.name #end </code>
collection
- collection to be sortpropertyName
- identify property name to sorting and type of sortingpublic java.util.Collection sort(java.util.Collection collection)
$sorter
<code> #foreach ($rel in $sorter.sort($package)) $rel.name #end </code>
collection
- collection collection to be sortpublic java.util.Collection<java.lang.Object> sortByLocale(java.util.Collection<?> collection, java.lang.String locale)
For example:
<code> #foreach ($rel in $sorter.sortByLocale($package, "DE")) $rel.name #end </code>
collection
- collection collection to be sortlocale
- identified country namepublic java.util.Collection<java.lang.Object> sortByLocale(java.util.Collection<?> collection, java.lang.String propertyName, java.lang.String locale)
For example:
<code> #foreach ($rel in $sorter.sortByLocale($package, "DE")) $rel.name #end </code>
collection
- collection collection to be sortpropertyName
- identify property name to sortinglocale
- identified country namepublic java.util.Collection<?> humanSort(java.util.Collection<?> collection)
collection
- collection collection to be sortpublic java.util.Collection<?> humanSort(java.util.Collection<?> collection, java.lang.String propertyName)
collection
- collection collection to be sortpropertyName
- identify property name to sorting and type of sortingpublic java.util.Collection<java.lang.Object> sortByFirstNumber(java.util.Collection<?> collection)
For example:
<code> ["1abc", "2abc", "a1bc", "a2bc"] </code>The output order will be:
<code> ["1abc", "a1bc", "2abc", "a2bc"] </code>
collection
- collection collection to be sortpublic java.util.Collection<java.lang.Object> sortByFirstNumber(java.util.Collection<?> collection, java.lang.String propertyName)
For example:
<code> ["1abc", "2abc", "a1bc", "a2bc"] </code>The output order will be:
<code> ["1abc", "a1bc", "2abc", "a2bc"] </code>
collection
- collection to be sortpropertyName
- identify property name to sorting and type of sortingprotected java.lang.Object getValue(java.lang.Object object, java.lang.String propertyName)
object
- target object.propertyName
- property nameprotected java.lang.String getNextToken(java.lang.String str, int offset, int len)
str
- input stringoffset
- starting offsetlen
- string lengthCopyright © 2010 - No Magic Asia