de.kappich.pat.configBrowser.main
Class DataModelTreeModel.SortingListAdapter

java.lang.Object
  extended by de.kappich.pat.configBrowser.main.DataModelTreeModel.AbstractAdapter
      extended by de.kappich.pat.configBrowser.main.DataModelTreeModel.SortingListAdapter
All Implemented Interfaces:
DataModelTreeModel.Adapter, Comparator<SystemObject>
Direct Known Subclasses:
DataModelTreeModel.ObjectHierarchyListAdapter, DataModelTreeModel.SimpleTypeHierarchyListAdapter, DataModelTreeModel.TypeHierarchyListAdapter
Enclosing class:
DataModelTreeModel

static class DataModelTreeModel.SortingListAdapter
extends DataModelTreeModel.AbstractAdapter
implements DataModelTreeModel.Adapter, Comparator<SystemObject>


Field Summary
(package private)  Map<SystemObject,String> _compareStrings
           
protected  ArrayList<SystemObject> _list
           
 
Fields inherited from class de.kappich.pat.configBrowser.main.DataModelTreeModel.AbstractAdapter
_childs, _tag
 
Constructor Summary
DataModelTreeModel.SortingListAdapter(String nodeTag, List list)
           
 
Method Summary
 int compare(SystemObject o1, SystemObject o2)
          Compares its two arguments for order.
 DataModelTreeModel.Adapter createChild(int searchIndex)
           
 int getChildCount()
           
private  String getCompareString(SystemObject object)
          Liefert einen String der in Vergleichsfunktionen benutzt werden kann um die Sortierreihenfolge festzulegen.
 String getValue()
           
 boolean isLeaf()
           
 
Methods inherited from class de.kappich.pat.configBrowser.main.DataModelTreeModel.AbstractAdapter
createAdapter, getChild, getIndex, getTag, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.kappich.pat.configBrowser.main.DataModelTreeModel.Adapter
getChild, getIndex
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

_compareStrings

Map<SystemObject,String> _compareStrings

_list

protected ArrayList<SystemObject> _list
Constructor Detail

DataModelTreeModel.SortingListAdapter

DataModelTreeModel.SortingListAdapter(String nodeTag,
                                      List list)
Method Detail

createChild

public DataModelTreeModel.Adapter createChild(int searchIndex)
Overrides:
createChild in class DataModelTreeModel.AbstractAdapter

getChildCount

public int getChildCount()
Specified by:
getChildCount in interface DataModelTreeModel.Adapter
Specified by:
getChildCount in class DataModelTreeModel.AbstractAdapter

isLeaf

public boolean isLeaf()
Specified by:
isLeaf in interface DataModelTreeModel.Adapter
Overrides:
isLeaf in class DataModelTreeModel.AbstractAdapter

getValue

public String getValue()
Specified by:
getValue in class DataModelTreeModel.AbstractAdapter

compare

public int compare(SystemObject o1,
                   SystemObject o2)
Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that sgn(compare(x, y)) == -sgn(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementer must ensure that compare(x, y)==0 implies that sgn(compare(x, z))==sgn(compare(y, z)) for all z.

It is generally the case, but not strictly required that (compare(x, y)==0) == (x.equals(y)). Generally speaking, any comparator that violates this condition should clearly indicate this fact. The recommended language is "Note: this comparator imposes orderings that are inconsistent with equals."

Specified by:
compare in interface Comparator<SystemObject>
Parameters:
o1 - the first object to be compared.
o2 - the second object to be compared.
Returns:
a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
Throws:
ClassCastException - if the arguments' types prevent them from being compared by this Comparator.

getCompareString

private String getCompareString(SystemObject object)
Liefert einen String der in Vergleichsfunktionen benutzt werden kann um die Sortierreihenfolge festzulegen. Der String enthält den Namen, die Pid und die Id des Objekts mit zwei bzw. einem Leerzeichen getrennt. Die Leerzeichen zwischen Name, Pid und Id sorgen dafür, dass zuerst nach Name und nur bei Namensgleichheit nach Pid respektive Id sortiert wird. Zwischen Name und Pid werden zwei Leerzeichen benutzt, um eine falsche Sortierung zu vermeiden, wenn in den Namen selbst auch Leerzeichen vorkommen. Anstelle von leeren Namen und Pids wird das Pipezeichen "|" benutzt, das dafür sorgt, dass die Objekte mit leeren Namen bzw. leeren Pids hinter denen mit nicht leeren Namen respektive nicht leeren Pids einsortiert werden. Umlaute werden durch ihre Zweibuchstaben-Äquivalente ersetzt, damit Objekte die Umlaute enthalten an einer sinnvollen Stelle einsortiert werden. Die einmal berechneten Vergleichsstrings werden in einer HashMap gespeichert um die Sortierzeit dramatisch zu verbessern.

Parameters:
object - Systemobjekt für das ein Vergleichstring bestimmt werden soll.
Returns:
Vergleichsstring