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

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

public class NameComparator
extends Object
implements Comparator

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


Field Summary
protected  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(Collection context)
          Constructor used to make a comparator which will compare TopicNameIFs and VariantNameIFs using the context provided.
 
Method Summary
 int compare(Object o1, Object o2)
          Compares two TopicNameIFs / VariantNameIFs.
protected  String getName(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 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(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 String getName(Object obj)
                  throws 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:
ClassCastException

compare

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

Specified by:
compare in interface Comparator


Copyright © 2000-2012 Ontopia.