edu.vt.middleware.dictionary
Class AbstractWordList

java.lang.Object
  extended by edu.vt.middleware.dictionary.AbstractWordList
All Implemented Interfaces:
WordList
Direct Known Subclasses:
ArrayWordList, FileWordList

public abstract class AbstractWordList
extends java.lang.Object
implements WordList

Provides common operations implementations for word lists.

Version:
$Revision: 1252 $ $Date: 2010-04-16 17:24:23 -0400 (Fri, 16 Apr 2010) $
Author:
Middleware Services

Field Summary
protected  java.util.Comparator<java.lang.String> comparator
          Word comparator.
 
Constructor Summary
AbstractWordList()
           
 
Method Summary
protected  void checkIsString(java.lang.Object o)
          Throws a ClassCastException if the supplied object is not an instance of String.
protected  void checkRange(int index)
          Throws a IndexOutOfBoundsException if the supplied index is less than 0 or greater than or equal to the size of this word list.
 java.util.Comparator<java.lang.String> getComparator()
          Gets the comparator that should be used to compare a search term with candidate words in the list.
 java.util.Iterator<java.lang.String> iterator()
          Gets an iterator to traverse this word list from the 0th index.
 java.util.Iterator<java.lang.String> medianIterator()
          Gets an iterator to traverse this word list from the median.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.vt.middleware.dictionary.WordList
get, size
 

Field Detail

comparator

protected java.util.Comparator<java.lang.String> comparator
Word comparator.

Constructor Detail

AbstractWordList

public AbstractWordList()
Method Detail

getComparator

public java.util.Comparator<java.lang.String> getComparator()
Gets the comparator that should be used to compare a search term with candidate words in the list. The comparator naturally respects ordering and case sensitivity of the word list.

Specified by:
getComparator in interface WordList
Returns:
Comparator for words in the list.

iterator

public java.util.Iterator<java.lang.String> iterator()
Gets an iterator to traverse this word list from the 0th index.

Specified by:
iterator in interface WordList
Returns:
Iterator for this word list

medianIterator

public java.util.Iterator<java.lang.String> medianIterator()
Gets an iterator to traverse this word list from the median.

Specified by:
medianIterator in interface WordList
Returns:
Iterator for this word list

checkRange

protected void checkRange(int index)
Throws a IndexOutOfBoundsException if the supplied index is less than 0 or greater than or equal to the size of this word list.

Parameters:
index - int

checkIsString

protected void checkIsString(java.lang.Object o)
Throws a ClassCastException if the supplied object is not an instance of String.

Parameters:
o - Object


Copyright © 2003-2010 Virginia Tech. All Rights Reserved.