edu.mit.jwi
Class RAMDictionary.HotSwappableIterator<E>

java.lang.Object
  extended by edu.mit.jwi.RAMDictionary.HotSwappableIterator<E>
Type Parameters:
E - the element type of the iterator
All Implemented Interfaces:
java.util.Iterator<E>
Direct Known Subclasses:
RAMDictionary.HotSwappableExceptionEntryIterator, RAMDictionary.HotSwappableIndexWordIterator, RAMDictionary.HotSwappableSenseEntryIterator, RAMDictionary.HotSwappableSynsetIterator
Enclosing class:
RAMDictionary

protected abstract class RAMDictionary.HotSwappableIterator<E>
extends java.lang.Object
implements java.util.Iterator<E>

An iterator that allows the dictionary to be loaded into memory while it is iterating.

Since:
JWI 2.2.0
Author:
Mark A. Finlayson

Constructor Summary
RAMDictionary.HotSwappableIterator(java.util.Iterator<E> itr, boolean checkForLoad)
          Constructs a new hot swappable iterator.
 
Method Summary
protected  void checkForLoad()
          Checks to see if the data has been loaded into memory; is so, replaces the original iterator with one that iterates over the in-memory data structures.
 boolean hasNext()
           
protected abstract  java.util.Iterator<E> makeIterator()
          Constructs the iterator that will iterate over the loaded data.
 E next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RAMDictionary.HotSwappableIterator

public RAMDictionary.HotSwappableIterator(java.util.Iterator<E> itr,
                                          boolean checkForLoad)
Constructs a new hot swappable iterator.

Parameters:
itr - the wrapped iterator
checkForLoad - if true, on each call the iterator checks to see if the dictionary has been loaded into memory, switching data sources if so
Throws:
java.lang.NullPointerException - if the specified iterator is null
Since:
JWI 2.2.0
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<E>

next

public E next()
Specified by:
next in interface java.util.Iterator<E>

checkForLoad

protected void checkForLoad()
Checks to see if the data has been loaded into memory; is so, replaces the original iterator with one that iterates over the in-memory data structures.

Since:
JWI 2.2.0

makeIterator

protected abstract java.util.Iterator<E> makeIterator()
Constructs the iterator that will iterate over the loaded data.

Returns:
the new iterator to be swapped in when loading is done
Since:
JWI 2.2.0

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<E>


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