edu.mit.jwi.data
Class WordnetFile.LineIterator

java.lang.Object
  extended by edu.mit.jwi.data.WordnetFile.LineIterator
All Implemented Interfaces:
Iterator<String>
Direct Known Subclasses:
BinarySearchWordnetFile.BinarySearchLineIterator, DirectAccessWordnetFile.DirectLineIterator
Enclosing class:
WordnetFile<T>

protected abstract class WordnetFile.LineIterator
extends Object
implements Iterator<String>

Used to iterate over lines in a file. It is a look-ahead iterator. This iterator does not support the remove method; if that method is called, it throws an UnsupportedOperationException.

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

Field Summary
protected  ByteBuffer itrBuffer
           
protected  String next
           
protected  ByteBuffer parentBuffer
           
 
Constructor Summary
WordnetFile.LineIterator(ByteBuffer buffer, String key)
          Constructs a new line iterator over this buffer, starting at the specified key.
 
Method Summary
protected  void advance()
          Skips over comment lines to find the next line that would be returned by the iterator in a call to next().
protected abstract  void findFirstLine(String key)
          Advances the iterator the first line the iterator should return, based on the specified key.
 String getNextLine()
          Returns the line currently stored as the 'next' line, if any.
 boolean hasNext()
           
protected  boolean isComment(String line)
          Returns true if the specified line is a comment; false otherwise
 String next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parentBuffer

protected final ByteBuffer parentBuffer

itrBuffer

protected ByteBuffer itrBuffer

next

protected String next
Constructor Detail

WordnetFile.LineIterator

public WordnetFile.LineIterator(ByteBuffer buffer,
                                String key)
Constructs a new line iterator over this buffer, starting at the specified key.

Parameters:
buffer - the buffer over which the iterator should iterator; may not be null
key - the key of the line to start at; may be null
Throws:
NullPointerException - if the specified buffer is null
Since:
JWI 1.0
Method Detail

getNextLine

public String getNextLine()
Returns the line currently stored as the 'next' line, if any. Is a pure getter; does not increment the iterator.

Returns:
the next line that will be parsed and returned by this iterator, or null if none
Since:
JWI 2.2.0

findFirstLine

protected abstract void findFirstLine(String key)
Advances the iterator the first line the iterator should return, based on the specified key. If the key is not found in the file, it will advance the iterator past all lines.

Parameters:
key - the key indexed the first line to be returned by the iterator
Since:
JWI 1.0

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<String>

advance

protected void advance()
Skips over comment lines to find the next line that would be returned by the iterator in a call to next().

Since:
JWI 1.0

isComment

protected boolean isComment(String line)
Returns true if the specified line is a comment; false otherwise

Parameters:
line - the line to be tested
Returns:
true if the specified line is a comment; false otherwise
Since:
JWI 1.0

next

public String next()
Specified by:
next in interface Iterator<String>

remove

public final void remove()
Specified by:
remove in interface Iterator<String>


Copyright © 2011. All Rights Reserved.