Class SorterTool
- java.lang.Object
-
- java.util.Observable
-
- com.nomagic.magicreport.engine.Tool
-
- com.nomagic.magicreport.engine.tools.SortTool
-
- com.nomagic.magicdraw.magicreport.tools.SorterTool
-
- All Implemented Interfaces:
com.nomagic.magicreport.engine.ITool,com.nomagic.magicreport.IVariable,java.io.Serializable,java.lang.Cloneable
@OpenApiAll public class SorterTool extends com.nomagic.magicreport.engine.tools.SortToolThe sort tool specific for MagicDraw.- Since:
- Jun 13, 2008
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.nomagic.magicreport.engine.tools.SortTool
com.nomagic.magicreport.engine.tools.SortTool.AscendingSort, com.nomagic.magicreport.engine.tools.SortTool.DescendingSort, com.nomagic.magicreport.engine.tools.SortTool.FirstNumberAscendingSort, com.nomagic.magicreport.engine.tools.SortTool.FirstNumberDescendingSort, com.nomagic.magicreport.engine.tools.SortTool.HumanAscendingSort, com.nomagic.magicreport.engine.tools.SortTool.HumanDescendingSort
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONTEXT_NAMEContains a context name.
-
Constructor Summary
Constructors Constructor Description SorterTool()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.CollectioncontainmentTreeSort(java.util.Collection collection)Sorter for sorting elements that they would look same as in browser tree.java.lang.StringgetBlankValue()Return the value for blank field.protected java.lang.ObjectgetValue(java.lang.Object object, java.lang.String propertyName)Look up a object value by property name.java.util.CollectionhumanSort(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.voidsetProperties(java.util.Properties properties)This method is invoked by the template engine runtime, after class has been initializing, to set the template properties.java.util.Collectionsort(java.util.Collection collection)Sort function for template report.java.util.CollectiontagSort(java.util.Collection collection, Stereotype stereotype, java.lang.String tagName)Sort element by tag name of specific stereotype.java.util.CollectiontagSort(java.util.Collection collection, Stereotype stereotype, java.lang.String tagName, boolean forceNumber)Sort element by tag name of specific stereotype.java.util.CollectiontagSort(java.util.Collection collection, java.lang.String stereotypeName, java.lang.String tagName)Sort element by tag name of specific stereotype name.java.util.CollectiontagSort(java.util.Collection collection, java.lang.String stereotypeName, java.lang.String tagName, boolean forceNumber)Sort element by tag name of specific stereotype name.java.util.CollectiontreeSort(java.util.Collection collection)Special sorting function with human order for containment tree elements, 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.-
Methods inherited from class com.nomagic.magicreport.engine.tools.SortTool
defaultSort, getNextToken, humanSort, humanSort, humanSort, humanSort, humanSort, humanSort, isForceNumber, setForceNumber, sort, sort, sort, sort, sort, sortByFirstNumber, sortByFirstNumber, sortByFirstNumber, sortByFirstNumber, sortByLocale, sortByLocale
-
Methods inherited from class com.nomagic.magicreport.engine.Tool
clone, getContext, getProperties, getProperty, getProperty, notifyObservers, setContext
-
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged
-
-
-
-
Field Detail
-
CONTEXT_NAME
public static final java.lang.String CONTEXT_NAME
Contains a context name.- See Also:
- Constant Field Values
-
-
Method Detail
-
setProperties
public void setProperties(java.util.Properties properties)
This method is invoked by the template engine runtime, after class has been initializing, to set the template properties. Override current properties will not affect with the engine.- Specified by:
setPropertiesin interfacecom.nomagic.magicreport.engine.ITool- Overrides:
setPropertiesin classcom.nomagic.magicreport.engine.Tool- Parameters:
properties- template engine properties
-
getBlankValue
public java.lang.String getBlankValue()
Return the value for blank field.- Returns:
- value for blank field
-
sort
public java.util.Collection sort(java.util.Collection collection)
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$sorterFor example:
<code> #foreach ($rel in $sorter.sort($package)) $rel.name #end </code>This method will sort object in collection by default MagicDraw model ordering ('name' when input is a collection of NamedElement).
- Overrides:
sortin classcom.nomagic.magicreport.engine.tools.SortTool- Parameters:
collection- collection to be sort- Returns:
- sorted collection
-
humanSort
public 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. This makes "foo10" sort after "foo2"This method will sort object in collection by default MagicDraw model ordering. ('name' when input is a collection of NamedElement).
- Overrides:
humanSortin classcom.nomagic.magicreport.engine.tools.SortTool- Parameters:
collection- collection collection to be sort- Returns:
- sorted collection
-
tagSort
public java.util.Collection tagSort(java.util.Collection collection, Stereotype stereotype, java.lang.String tagName)Sort element by tag name of specific stereotype.- Parameters:
collection- elements to be sortedstereotype- specific stereotypetagName- tagName- Returns:
- sorted collection
-
tagSort
public java.util.Collection tagSort(java.util.Collection collection, java.lang.String stereotypeName, java.lang.String tagName)Sort element by tag name of specific stereotype name.- Parameters:
collection- elements to be sortedstereotypeName- specific stereotype nametagName- tagName- Returns:
- sorted collection
-
tagSort
public java.util.Collection tagSort(java.util.Collection collection, Stereotype stereotype, java.lang.String tagName, boolean forceNumber)Sort element by tag name of specific stereotype.- Parameters:
collection- elements to be sortedstereotype- specific stereotypeforceNumber- try to compare by numbertagName- tagName- Returns:
- sorted collection
-
tagSort
public java.util.Collection tagSort(java.util.Collection collection, java.lang.String stereotypeName, java.lang.String tagName, boolean forceNumber)Sort element by tag name of specific stereotype name.- Parameters:
collection- elements to be sortedstereotypeName- specific stereotype nameforceNumber- try to compare by numbertagName- tagName- Returns:
- sorted collection
-
treeSort
public java.util.Collection treeSort(java.util.Collection collection)
Special sorting function with human order for containment tree elements, 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"This method will sort object in collection by default MagicDraw model ordering. ('name' when input is a collection of NamedElement).
- Parameters:
collection- collection collection to be sort- Returns:
- sorted collection
-
containmentTreeSort
public java.util.Collection containmentTreeSort(java.util.Collection collection)
Sorter for sorting elements that they would look same as in browser tree.- Parameters:
collection- collection collection to be sort- Returns:
- sorted collection
-
getValue
protected java.lang.Object getValue(java.lang.Object object, java.lang.String propertyName)Look up a object value by property name.- Overrides:
getValuein classcom.nomagic.magicreport.engine.tools.SortTool- Parameters:
object- target object.propertyName- property name- Returns:
- the value.
-
-