net.sf.mmm.util.lang.base
Class AbstractCharIterator

java.lang.Object
  extended by net.sf.mmm.util.lang.base.AbstractCharIterator
All Implemented Interfaces:
CharIterator

public abstract class AbstractCharIterator
extends Object
implements CharIterator

This is an abstract base implementation of the CharIterator interface. It allows to implement a lookahead CharIterator easier:
Simply extend this class and implement findNext(). From your constructor or initializer call findFirst().
ATTENTION:
Do NOT forget to call findFirst() from your constructor or your iterator will always be empty.

Since:
1.0.2
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Field Summary
private  char next
          The next char to iterate.
 
Fields inherited from interface net.sf.mmm.util.lang.api.CharIterator
END_OF_ITERATOR
 
Constructor Summary
AbstractCharIterator()
          The constructor.
 
Method Summary
protected  void findFirst()
          This method has to be called from the constructor of the implementing class.
protected abstract  char findNext()
          This method tries to find the next element.
 boolean hasNext()
          This method determines whether there is a next char available or the end of this iterator has been reached.
 char next()
          This method returns the next character to iterate or CharIterator.END_OF_ITERATOR if the end of this iterator has been reached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

next

private char next
The next char to iterate.

Constructor Detail

AbstractCharIterator

public AbstractCharIterator()
The constructor.

Method Detail

findFirst

protected final void findFirst()
This method has to be called from the constructor of the implementing class.


findNext

protected abstract char findNext()
This method tries to find the next element.

Returns:
the next element or null if done.

hasNext

public boolean hasNext()
This method determines whether there is a next char available or the end of this iterator has been reached.

Specified by:
hasNext in interface CharIterator
Returns:
true if there is at least one next char available, or false if the end of this iterator has been reached and further calls of CharIterator.next() will return CharIterator.END_OF_ITERATOR.
See Also:
CharIterator.next(), Iterator.hasNext()

next

public char next()
This method returns the next character to iterate or CharIterator.END_OF_ITERATOR if the end of this iterator has been reached. If CharIterator.END_OF_ITERATOR is returned further calls will always return CharIterator.END_OF_ITERATOR.

Specified by:
next in interface CharIterator
Returns:
the next character or CharIterator.END_OF_ITERATOR if the end of this iterator has been reached.
See Also:
Iterator.next()


Copyright © 2001-2010 mmm-Team. All Rights Reserved.