public class SpaceNormalizingCharIterator extends Object implements CharIterator
CharIterator interface that adapts a CharIterator such that spaces
are normalized.| Modifier and Type | Field and Description |
|---|---|
private CharIterator |
delegate
The underlying
CharIterator to delegate to. |
private boolean |
nextCalled
|
private char |
nextNonSpace
A buffer for the next non-space char if lookahead went to far, or ' ' if no char is buffered.
|
private CharFilter |
spaceFilter
|
private boolean |
trim
|
END_OF_ITERATOR| Constructor and Description |
|---|
SpaceNormalizingCharIterator(CharIterator delegate)
The constructor.
|
SpaceNormalizingCharIterator(CharIterator delegate,
CharFilter spaceFilter,
boolean trim)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
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. |
private final CharIterator delegate
CharIterator to delegate to.private final CharFilter spaceFilter
private final boolean trim
private boolean nextCalled
private char nextNonSpace
public SpaceNormalizingCharIterator(CharIterator delegate)
delegate - is the CharIterator to adapt.public SpaceNormalizingCharIterator(CharIterator delegate, CharFilter spaceFilter, boolean trim)
delegate - is the CharIterator to adapt.spaceFilter - is the CharFilter that defines what is accepted as
space. It needs to accept at least ' '.trim - - if true leading and trailing spaces are entirely consumed.public boolean hasNext()
CharIteratornext char available or the end of this iterator has been
reached.hasNext in interface CharIteratortrue 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.CharIterator.next(),
Iterator.hasNext()public char next()
CharIteratorCharIterator.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.next in interface CharIteratorCharIterator.END_OF_ITERATOR if the end of this iterator has been reached.Iterator.next()Copyright © 2001–2016 mmm-Team. All rights reserved.