net.sf.sfac.string
Class AbstractCharIterator

java.lang.Object
  extended by net.sf.sfac.string.AbstractCharIterator
All Implemented Interfaces:
CharIterator
Direct Known Subclasses:
StringCharIterator

public abstract class AbstractCharIterator
extends Object
implements CharIterator

Abstract implementation of a CharIterator where the chars are found in a set of Strings.
The way the string are stored/organized is defined by the concrete subclass (implementing getFirstString() and getNextString()).

Rem: Subclasses have to call reset() in their constructor to correctly initialize the iterator state.

Author:
Olivier Berlanger

Constructor Summary
AbstractCharIterator()
           
 
Method Summary
protected abstract  String getFirstString()
          Get the first String available for iteration.
protected abstract  String getNextString()
          Get the next String available for iteration.
 String getNormalizedString()
          Get the content of this char iterator as a normalized string.
protected  boolean isFinished()
           
 char nextChar()
          Get the next non-normalised char.
 char nextNormalizedChar()
          Get the next char of this iterator.
 void reset()
          Reset the iterator state so it points to it's first char.
protected  void setFinished()
          Notify this class that no more character are available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCharIterator

public AbstractCharIterator()
Method Detail

reset

public void reset()
Reset the iterator state so it points to it's first char.

Specified by:
reset in interface CharIterator

getFirstString

protected abstract String getFirstString()
Get the first String available for iteration.

Returns:
the first String available for iteration.

getNextString

protected abstract String getNextString()
Get the next String available for iteration.
If no next string is available, implementing classes have to call setFinished() (then the return value is ignored).

Returns:
the next String available for iteration.

setFinished

protected void setFinished()
Notify this class that no more character are available.


isFinished

protected boolean isFinished()

nextNormalizedChar

public char nextNormalizedChar()
Get the next char of this iterator.
The returned char are normalized as explained in CharIterator interface javadoc comment. When no more characters are available, an zero char ('\0') is returned.

Specified by:
nextNormalizedChar in interface CharIterator
Returns:
the next char of this iterator or '\0' if no more characters are availbale.

nextChar

public char nextChar()
Get the next non-normalised char.
If the end of the current string is reached, this method will query the next one with getNextString().

Specified by:
nextChar in interface CharIterator
Returns:
the next non-normalised char or '\0' if no more characters are availbale.

getNormalizedString

public String getNormalizedString()
Get the content of this char iterator as a normalized string.
The result will be:

Specified by:
getNormalizedString in interface CharIterator
Returns:
The content of this char iterator as a normalized string.


Copyright © 2012. All Rights Reserved.