net.ontopia.topicmaps.utils
Class ScopedIFComparator

java.lang.Object
  extended by net.ontopia.topicmaps.utils.ScopedIFComparator
All Implemented Interfaces:
java.util.Comparator
Direct Known Subclasses:
BaseNameComparator, TopicNameComparator

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

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 Summary
protected  TopicIF[] scope
           
protected  java.util.Comparator subcomparator
           
 
Constructor Summary
ScopedIFComparator()
           
ScopedIFComparator(java.util.Collection scope)
           
ScopedIFComparator(java.util.Collection scope, java.util.Comparator subcomparator)
           
 
Method Summary
 int compare(java.lang.Object obj1, java.lang.Object 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
 

Field Detail

scope

protected TopicIF[] scope

subcomparator

protected java.util.Comparator subcomparator
Constructor Detail

ScopedIFComparator

public ScopedIFComparator()

ScopedIFComparator

public ScopedIFComparator(java.util.Collection scope)

ScopedIFComparator

public ScopedIFComparator(java.util.Collection scope,
                          java.util.Comparator subcomparator)
Method Detail

compare

public int compare(java.lang.Object obj1,
                   java.lang.Object obj2)
INTERNAL: Compares the two ScopedIF objects for their applicability in the scope specified in the constructor.

Specified by:
compare in interface java.util.Comparator
Parameters:
obj1 - An object implementing ScopedIF.
obj2 - An object implementing ScopedIF.
Returns:
See Comparator.compare(Object,Object)


Copyright © 2000-2012 Ontopia.