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:

  1. Compare the number of matching themes for each of the objects. The more matching themes, the higher ranked.
  2. Compare by number of themes specified on objects. The fewer themes, the higher ranked.
  3. If subcomparator doesn't exist they're ranked equally.
  4. Use subcomparator to compare them.
  • Field Details

  • Constructor Details

    • ScopedIFComparator

      public ScopedIFComparator()
    • ScopedIFComparator

      public ScopedIFComparator(Collection<TopicIF> scope)
    • ScopedIFComparator

      public ScopedIFComparator(Collection<TopicIF> scope, Comparator<? super T> subcomparator)
  • Method Details

    • 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 interface Comparator<T extends ScopedIF>
      Parameters:
      obj1 - An object implementing ScopedIF.
      obj2 - An object implementing ScopedIF.
      Returns:
      See Comparator.compare(Object,Object)