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, Serializable, Cloneable

@OpenApiAll public class SorterTool extends com.nomagic.magicreport.engine.tools.SortTool
The sort tool specific for MagicDraw.
Since:
Jun 13, 2008
See Also:
  • 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

    Nested classes/interfaces inherited from interface com.nomagic.magicreport.engine.ITool

    com.nomagic.magicreport.engine.ITool.HTMLString, com.nomagic.magicreport.engine.ITool.RetainedString, com.nomagic.magicreport.engine.ITool.Void
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Contains a context name.

    Fields inherited from class com.nomagic.magicreport.engine.Tool

    context, properties

    Fields inherited from interface com.nomagic.magicreport.engine.ITool

    VOID
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Sorter for sorting elements that they would look same as in browser tree.
    Return the value for blank field.
    protected Object
    getValue(Object object, String propertyName)
    Look up a object value by property name.
    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.
    void
    This method is invoked by the template engine runtime, after class has been initializing, to set the template properties.
    sort(Collection collection)
    Sort function for template report.
    tagSort(Collection collection, Stereotype stereotype, String tagName)
    Sort element by tag name of specific stereotype.
    tagSort(Collection collection, Stereotype stereotype, String tagName, boolean forceNumber)
    Sort element by tag name of specific stereotype.
    tagSort(Collection collection, String stereotypeName, String tagName)
    Sort element by tag name of specific stereotype name.
    tagSort(Collection collection, String stereotypeName, String tagName, boolean forceNumber)
    Sort element by tag name of specific stereotype name.
    treeSort(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.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.nomagic.magicreport.engine.ITool

    clearTool
  • Field Details

  • Constructor Details

    • SorterTool

      public SorterTool()
  • Method Details

    • setProperties

      public void setProperties(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:
      setProperties in interface com.nomagic.magicreport.engine.ITool
      Overrides:
      setProperties in class com.nomagic.magicreport.engine.Tool
      Parameters:
      properties - template engine properties
    • getBlankValue

      public String getBlankValue()
      Return the value for blank field.
      Returns:
      value for blank field
    • sort

      public Collection sort(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 $sorter

      For 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:
      sort in class com.nomagic.magicreport.engine.tools.SortTool
      Parameters:
      collection - collection to be sort
      Returns:
      sorted collection
    • humanSort

      public 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. 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:
      humanSort in class com.nomagic.magicreport.engine.tools.SortTool
      Parameters:
      collection - collection collection to be sort
      Returns:
      sorted collection
    • tagSort

      public Collection tagSort(Collection collection, Stereotype stereotype, String tagName)
      Sort element by tag name of specific stereotype.
      Parameters:
      collection - elements to be sorted
      stereotype - specific stereotype
      tagName - tagName
      Returns:
      sorted collection
    • tagSort

      public Collection tagSort(Collection collection, String stereotypeName, String tagName)
      Sort element by tag name of specific stereotype name.
      Parameters:
      collection - elements to be sorted
      stereotypeName - specific stereotype name
      tagName - tagName
      Returns:
      sorted collection
    • tagSort

      public Collection tagSort(Collection collection, Stereotype stereotype, String tagName, boolean forceNumber)
      Sort element by tag name of specific stereotype.
      Parameters:
      collection - elements to be sorted
      stereotype - specific stereotype
      forceNumber - try to compare by number
      tagName - tagName
      Returns:
      sorted collection
    • tagSort

      public Collection tagSort(Collection collection, String stereotypeName, String tagName, boolean forceNumber)
      Sort element by tag name of specific stereotype name.
      Parameters:
      collection - elements to be sorted
      stereotypeName - specific stereotype name
      forceNumber - try to compare by number
      tagName - tagName
      Returns:
      sorted collection
    • treeSort

      public Collection treeSort(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 Collection containmentTreeSort(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 Object getValue(Object object, String propertyName)
      Look up a object value by property name.
      Overrides:
      getValue in class com.nomagic.magicreport.engine.tools.SortTool
      Parameters:
      object - target object.
      propertyName - property name
      Returns:
      the value.