net.ontopia.topicmaps.nav.utils.comparators
Class NameComparator

java.lang.Object
  extended by net.ontopia.topicmaps.nav.utils.comparators.NameComparator
All Implemented Interfaces:
java.util.Comparator
Direct Known Subclasses:
NameComparatorWithGenerality

public class NameComparator
extends java.lang.Object
implements java.util.Comparator

INTERNAL: A Comparator for ordering TopicNameIFs and VariantNameIFs alphabetically (case-independent).


Field Summary
protected  java.util.Collection scopes
           
protected static URILocator SORT_LOCATOR
           
protected  VariantNameGrabber sortNameGrabber
           
protected  VariantNameGrabber vnGrabber
           
 
Constructor Summary
NameComparator()
          Empty constructor, used on application startup to initialise a "fast" comparator which will compare TopicNameIFs and VariantNameIFs using no context.
NameComparator(java.util.Collection context)
          Constructor used to make a comparator which will compare TopicNameIFs and VariantNameIFs using the context provided.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares two TopicNameIFs / VariantNameIFs.
protected  java.lang.String getName(java.lang.Object obj)
          INTERNAL: helper method which gets out of the object the base name or variant name value.
protected  void initSortNameGrabber(TMObjectIF tmObj)
          INTERNAL: setup variant sort name grabber.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

scopes

protected java.util.Collection scopes

vnGrabber

protected VariantNameGrabber vnGrabber

sortNameGrabber

protected VariantNameGrabber sortNameGrabber

SORT_LOCATOR

protected static final URILocator SORT_LOCATOR
Constructor Detail

NameComparator

public NameComparator()
Empty constructor, used on application startup to initialise a "fast" comparator which will compare TopicNameIFs and VariantNameIFs using no context.


NameComparator

public NameComparator(java.util.Collection context)
Constructor used to make a comparator which will compare TopicNameIFs and VariantNameIFs using the context provided.

Method Detail

initSortNameGrabber

protected final void initSortNameGrabber(TMObjectIF tmObj)
INTERNAL: setup variant sort name grabber. Attention: reuse same sort name grabber for this NameComparator object instance, so be sure all objects are in the same topicmap.


getName

protected java.lang.String getName(java.lang.Object obj)
                            throws java.lang.ClassCastException
INTERNAL: helper method which gets out of the object the base name or variant name value. If it's a basename try to retrieve the sort variant name for it.

Throws:
java.lang.ClassCastException

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compares two TopicNameIFs / VariantNameIFs.

Specified by:
compare in interface java.util.Comparator


Copyright © 2000-2012 Ontopia.