Class NameComparator
- java.lang.Object
-
- net.ontopia.topicmaps.nav.utils.comparators.NameComparator
-
- All Implemented Interfaces:
Comparator<NameIF>
- Direct Known Subclasses:
NameComparatorWithGenerality
public class NameComparator extends Object implements Comparator<NameIF>
INTERNAL: A Comparator for ordering TopicNameIFs and VariantNameIFs alphabetically (case-independent).
-
-
Field Summary
Fields Modifier and Type Field Description protected Collection<TopicIF>
scopes
protected VariantNameGrabber
sortNameGrabber
protected VariantNameGrabber
vnGrabber
-
Constructor Summary
Constructors Constructor Description NameComparator()
Empty constructor, used on application startup to initialise a "fast" comparator which will compare TopicNameIFs and VariantNameIFs using no context.NameComparator(Collection<TopicIF> context)
Constructor used to make a comparator which will compare TopicNameIFs and VariantNameIFs using the context provided.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(NameIF o1, NameIF o2)
Compares two TopicNameIFs / VariantNameIFs.protected String
getName(NameIF 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, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Field Detail
-
scopes
protected Collection<TopicIF> scopes
-
vnGrabber
protected VariantNameGrabber vnGrabber
-
sortNameGrabber
protected VariantNameGrabber sortNameGrabber
-
-
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<TopicIF> 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(NameIF obj)
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.
-
compare
public int compare(NameIF o1, NameIF o2)
Compares two TopicNameIFs / VariantNameIFs.- Specified by:
compare
in interfaceComparator<NameIF>
-
-