edu.mit.jwi.data.compare
Class CommentComparator

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

public class CommentComparator
extends java.lang.Object
implements java.util.Comparator<java.lang.String>, ICommentDetector

Default comment detector that is designed for comments found at the head of Wordnet dictionary files. It assumes that each comment line starts with two spaces, followed by a number that indicates the position of the comment line relative to the rest of the comment lines in the file.

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 CommentComparator()
          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)
           
static CommentComparator getInstance()
          Returns the singleton instance of this class, instantiating it if necessary.
 boolean isCommentLine(java.lang.String line)
          Returns true if the specified string is a comment line, false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommentComparator

protected CommentComparator()
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.

Since:
JWI 2.0.0
Method Detail

getInstance

public static CommentComparator 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>

isCommentLine

public boolean isCommentLine(java.lang.String line)
Description copied from interface: ICommentDetector
Returns true if the specified string is a comment line, false otherwise.

Specified by:
isCommentLine in interface ICommentDetector
Parameters:
line - the line to be analyzed
Returns:
true if the specified string is a comment line, false otherwise.


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