edu.mit.jwi.data.compare
Class IndexLineComparator

java.lang.Object
  extended by edu.mit.jwi.data.compare.IndexLineComparator
All Implemented Interfaces:
ILineComparator, java.util.Comparator<java.lang.String>

public class IndexLineComparator
extends java.lang.Object
implements ILineComparator

A comparator that captures the ordering of lines in Wordnet index files (e.g., index.adv or adv.idx files). These files are ordered alphabetically.

This class follows a singleton design pattern, and is not intended to be instantiated directly; rather, call the getInstance() method to get the singleton instance.

Since:
JWI 1.0
Version:
2.4.0
Author:
Mark A. Finlayson

Constructor Summary
protected IndexLineComparator(CommentComparator detector)
          This constructor is marked protected so that the class may be sub-classed, but not directly instantiated.
 
Method Summary
 int compare(java.lang.String s1, java.lang.String s2)
           
 ICommentDetector getCommentDetector()
          Returns the comment detector instance associated with this line comparator, or null if one does not exist.
static IndexLineComparator getInstance()
          Returns the singleton instance of this class, instantiating it if necessary.
 
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
 

Constructor Detail

IndexLineComparator

protected IndexLineComparator(CommentComparator detector)
This constructor is marked protected so that the class may be sub-classed, but not directly instantiated. Obtain instances of this class via the static getInstance() method.

Parameters:
detector - the comment detector for this line comparator, or null if there is none
Throws:
java.lang.NullPointerException - if the specified comment comparator is null
Since:
JWI 1.0
Method Detail

getInstance

public static IndexLineComparator getInstance()
Returns the singleton instance of this class, instantiating it if necessary. The singleton instance will not be null.

Returns:
the non-null singleton instance of this class, instantiating it if necessary.
Since:
JWI 2.0.0

compare

public int compare(java.lang.String s1,
                   java.lang.String s2)
Specified by:
compare in interface java.util.Comparator<java.lang.String>

getCommentDetector

public ICommentDetector getCommentDetector()
Description copied from interface: ILineComparator
Returns the comment detector instance associated with this line comparator, or null if one does not exist.

Specified by:
getCommentDetector in interface ILineComparator
Returns:
the comment detector associated with this line comparator, or null if there is none


Copyright © 2007-2013 Massachusetts Institute of Technology. All Rights Reserved.