Package net.ontopia.topicmaps.utils
Class ScopedIFComparator<T extends ScopedIF>
- java.lang.Object
-
- net.ontopia.topicmaps.utils.ScopedIFComparator<T>
-
- All Implemented Interfaces:
Comparator<T>
- Direct Known Subclasses:
TopicNameComparator
public class ScopedIFComparator<T extends ScopedIF> extends Object implements Comparator<T>
INTERNAL: Comparator that compares ScopedIF objects based on their applicability in the specified scope. This comparator may only be used with objects that are implementations of ScopedIF. The default subcomparator is LexicalComparator.CASE_SENSITIVE. Technique:- Compare the number of matching themes for each of the objects. The more matching themes, the higher ranked.
- Compare by number of themes specified on objects. The fewer themes, the higher ranked.
- If subcomparator doesn't exist they're ranked equally.
- Use subcomparator to compare them.
-
-
Field Summary
Fields Modifier and Type Field Description protected TopicIF[]
scope
protected Comparator<? super T>
subcomparator
-
Constructor Summary
Constructors Constructor Description ScopedIFComparator()
ScopedIFComparator(Collection<TopicIF> scope)
ScopedIFComparator(Collection<TopicIF> scope, Comparator<? super T> subcomparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(T obj1, T obj2)
INTERNAL: Compares the two ScopedIF objects for their applicability in the scope specified in the constructor.-
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
-
scope
protected TopicIF[] scope
-
subcomparator
protected Comparator<? super T extends ScopedIF> subcomparator
-
-
Constructor Detail
-
ScopedIFComparator
public ScopedIFComparator()
-
ScopedIFComparator
public ScopedIFComparator(Collection<TopicIF> scope)
-
ScopedIFComparator
public ScopedIFComparator(Collection<TopicIF> scope, Comparator<? super T> subcomparator)
-
-
Method Detail
-
compare
public int compare(T obj1, T obj2)
INTERNAL: Compares the two ScopedIF objects for their applicability in the scope specified in the constructor.- Specified by:
compare
in interfaceComparator<T extends ScopedIF>
- Parameters:
obj1
- An object implementing ScopedIF.obj2
- An object implementing ScopedIF.- Returns:
- See
Comparator.compare(Object,Object)
-
-