Class SortTool
java.lang.Object
java.util.Observable
com.nomagic.magicreport.engine.Tool
com.nomagic.magicreport.engine.tools.SortTool
- All Implemented Interfaces:
ITool,IVariable,Serializable,Cloneable
- Direct Known Subclasses:
SorterTool,SortTable
This class is use to sort the collection in template report.
- Since:
- Jul 13, 2007
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classsort Collection in ascendingprotected static classsort Collection in descendingprotected static classsort Collection in first number ascendingprotected static classsort Collection in first number descendingprotected static classSort Collection in ascending.protected static classsort Collection in descending.Nested classes/interfaces inherited from interface com.nomagic.magicreport.engine.ITool
ITool.HTMLString, ITool.RetainedString, ITool.Void -
Field Summary
FieldsFields inherited from class com.nomagic.magicreport.engine.Tool
context, properties -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondefaultSort(Collection collection) protected StringgetNextToken(String str, int offset, int len) Return a next token of string from starting offset.protected ObjectLook up a object value by property name.Collection<?> humanSort(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.Collection<?> humanSort(Collection<?> collection, boolean isCaseInsensitive) 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.Collection<?> humanSort(Collection<?> collection, 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.Collection<?> humanSort(Collection<?> collection, String propertyName, boolean isCaseInsensitive) 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.Collection<?> humanSort(Collection<?> collection, Collection<String> propertyNames) Special sorting function with human order.Collection<?> humanSort(Collection<?> collection, Collection<String> propertyNames, String direction) Special sorting function with human order.Collection<?> humanSort(Collection<?> collection, Collection<String> propertyNames, String direction, boolean isCaseInsensitive) 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.booleanvoidsetForceNumber(boolean forceNumber) sort(Collection collection) Sort function for template report.sort(Collection collection, String propertyName) Sort function for template report.sort(Collection collection, String propertyName, boolean isCaseInsensitive) Sort function for template report.sort(Collection collection, Collection<String> propertyNames) Sort function for template report.sort(Collection collection, Collection<String> propertyNames, String direction) Sort function for template report.sort(Collection collection, Collection<String> propertyNames, String direction, boolean isCaseInsensitive) Sort function for template report.sortByFirstNumber(Collection<?> collection) Sort function with special text ordering.sortByFirstNumber(Collection<?> collection, String propertyName) Sort function with special text ordering.sortByFirstNumber(Collection<?> collection, Collection<String> propertyNames) Sort function with special text ordering.sortByFirstNumber(Collection<?> collection, Collection<String> propertyNames, String direction) Sort function with special text ordering.sortByLocale(Collection<?> collection, String locale) Sort the given collection by specified country code.sortByLocale(Collection<?> collection, String propertyName, String locale) Sort the given collection by specified country code.Methods inherited from class com.nomagic.magicreport.engine.Tool
clone, getContext, getProperties, getProperty, getProperty, notifyObservers, setContext, setPropertiesMethods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged
-
Field Details
-
CONTEXT_NAME
Contains a context name.- See Also:
-
-
Constructor Details
-
SortTool
public SortTool()
-
-
Method Details
-
isForceNumber
public boolean isForceNumber() -
setForceNumber
public void setForceNumber(boolean forceNumber) -
defaultSort
-
sort
Sort function for template report. Context name of this class is "sorter". Public functions of this class are able to access via template by using$sorter
For example:<code> #foreach ($rel in $sorter.sort($package)) $rel.name #end </code>- $package is collection to sort
- Parameters:
collection- collection collection to be sort- Returns:
- sorted collection
-
sort
Sort function for template report. Context name of this class is "sorter". Public functions of this class are able to access via template by using$sorter. This function will sort case-insensitive by default
For example:<code> #foreach ($rel in $sorter.sort($package, "name:desc")) $rel.name #end </code>- $package is collection to sort
- "name:desc" separate by ":" in 2 part
- first part to identify the property name to sorting
- second part is option to identify type of sorting.
- if type of sorting is not identified, the default value is ascending
- Parameters:
collection- collection to be sortpropertyName- identify property name to sorting and type of sorting- Returns:
- sorted collection
-
sort
Sort function for template report.- Parameters:
collection- collection to be sortpropertyNames- collection of property name to sorting- Returns:
- sorted collection
-
sort
Sort function for template report.- Parameters:
collection- collection to be sortpropertyNames- collection of property name to sortingdirection- type of sorting- Returns:
- sorted collection
-
sort
Sort function for template report. Context name of this class is "sorter". Public functions of this class are able to access via template by using$sorter
For example:<code> #foreach ($rel in $sorter.sort($package, "name:desc")) $rel.name #end </code>- $package is collection to sort
- "name:desc" separate by ":" in 2 part
- first part to identify the property name to sorting
- second part is option to identify type of sorting.
- if type of sorting is not identified, the default value is ascending
- Parameters:
collection- collection to be sortpropertyName- identify property name to sorting and type of sortingisCaseInsensitive- true to compare case-insensitive- Returns:
- sorted collection
-
sort
public Collection sort(Collection collection, Collection<String> propertyNames, String direction, boolean isCaseInsensitive) Sort function for template report.- Parameters:
collection- collection to be sortdirection- type of sorting (asc, desc)isCaseInsensitive- true to compare case-insensitivepropertyName- property name to sorting and type of sorting- Returns:
- sorted collection
-
sortByLocale
Sort the given collection by specified country code.For example:
<code> #foreach ($rel in $sorter.sortByLocale($package, "DE")) $rel.name #end </code>- $package is collection to sort
- "DE" is the country argument for GERMANY (ISO Country Code)
- Parameters:
collection- collection collection to be sortlocale- identified country name- Returns:
- sorted collection
-
sortByLocale
public Collection<Object> sortByLocale(Collection<?> collection, String propertyName, String locale) Sort the given collection by specified country code.For example:
<code> #foreach ($rel in $sorter.sortByLocale($package, "DE")) $rel.name #end </code>- $package is collection to sort
- "DE" is the country argument for GERMANY (ISO Country Code)
- Parameters:
collection- collection collection to be sortpropertyName- identify property name to sortinglocale- identified country name- Returns:
- sorted collection
-
humanSort
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. This makes "foo10" sort after "foo2"- Parameters:
collection- collection collection to be sort- Returns:
- sorted collection
-
humanSort
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. This makes "foo10" sort after "foo2"- Parameters:
collection- collection collection to be sortisCaseInsensitive- true to sort case-insensitive- Returns:
- sorted collection
-
humanSort
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. This makes "foo10" sort after "foo2"- Parameters:
collection- collection collection to be sortpropertyName- property name to sorting and type of sorting- Returns:
- sorted collection
-
humanSort
Special sorting function with human order.- Parameters:
collection- collection collection to be sortpropertyNames- collection of property name to sorting- Returns:
- sorted collection
-
humanSort
public Collection<?> humanSort(Collection<?> collection, Collection<String> propertyNames, String direction) Special sorting function with human order.- Parameters:
collection- collection collection to be sortpropertyNames- collection of property name to sortingdirection- type of sorting (asc, desc)- Returns:
- sorted collection
-
humanSort
public Collection<?> humanSort(Collection<?> collection, String propertyName, boolean isCaseInsensitive) 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. This makes "foo10" sort after "foo2"- Parameters:
collection- collection collection to be sortpropertyName- identify property name to sorting and type of sortingisCaseInsensitive- true to sort case-insensitive- Returns:
- sorted collection
-
humanSort
public Collection<?> humanSort(Collection<?> collection, Collection<String> propertyNames, String direction, boolean isCaseInsensitive) 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. This makes "foo10" sort after "foo2"- Parameters:
collection- collection collection to be sortpropertyNames- collection of property name to sortingdirection- type of sorting (asc, desc)isCaseInsensitive- true to sort case-insensitive- Returns:
- sorted collection
-
sortByFirstNumber
Sort function with special text ordering. This function will sort the collection by give the priority to first digit found in String.For example:
<code> ["1abc", "2abc", "a1bc", "a2bc"] </code>
The output order will be:<code> ["1abc", "a1bc", "2abc", "a2bc"] </code>
- Parameters:
collection- collection collection to be sort- Returns:
- sorted collection
-
sortByFirstNumber
public Collection<Object> sortByFirstNumber(Collection<?> collection, Collection<String> propertyNames) Sort function with special text ordering. This function will sort the collection by give the priority to first digit found in String.- Parameters:
propertyNames- collection of property name- Returns:
- sorted collection
-
sortByFirstNumber
Sort function with special text ordering. This function will sort the collection by give the priority to first digit found in String.For example:
<code> ["1abc", "2abc", "a1bc", "a2bc"] </code>
The output order will be:<code> ["1abc", "a1bc", "2abc", "a2bc"] </code>
- Parameters:
collection- collection to be sortpropertyName- identify property name to sorting and type of sorting- Returns:
- sorted collection
-
sortByFirstNumber
public Collection<Object> sortByFirstNumber(Collection<?> collection, Collection<String> propertyNames, String direction) Sort function with special text ordering. This function will sort the collection by give the priority to first digit found in String.- Parameters:
collection- collection to be sortpropertyNames- collection of property name to be sort- Returns:
- sorted collection
-
getNextToken
Return a next token of string from starting offset.- Parameters:
str- input stringoffset- starting offsetlen- string length- Returns:
- next token.
-
getValue
Look up a object value by property name.- Parameters:
object- target object.propertyName- property name- Returns:
- the value.
-