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

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

public class SpaceNormalizingCharIterator
extends Object
implements CharIterator

This is an implementation of the CharIterator interface that adapts a CharIterator such that spaces are normalized.

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

Field Summary
private  CharIterator delegate
          The underlying CharIterator to delegate to.
private  boolean nextCalled
          true if next() has already been called, initially false.
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
          SpaceNormalizingCharIterator(CharIterator, CharFilter, boolean)
private  boolean trim
          SpaceNormalizingCharIterator(CharIterator, CharFilter, boolean)
 
Fields inherited from interface net.sf.mmm.util.lang.api.CharIterator
END_OF_ITERATOR
 
Constructor Summary
SpaceNormalizingCharIterator(CharIterator delegate)
          The constructor.
SpaceNormalizingCharIterator(CharIterator delegate, CharFilter spaceFilter, boolean trim)
          The constructor.
 
Method Summary
 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

delegate

private final CharIterator delegate
The underlying CharIterator to delegate to.


spaceFilter

private final CharFilter spaceFilter
SpaceNormalizingCharIterator(CharIterator, CharFilter, boolean)


trim

private final boolean trim
SpaceNormalizingCharIterator(CharIterator, CharFilter, boolean)


nextCalled

private boolean nextCalled
true if next() has already been called, initially false.


nextNonSpace

private char nextNonSpace
A buffer for the next non-space char if lookahead went to far, or ' ' if no char is buffered.

Constructor Detail

SpaceNormalizingCharIterator

public SpaceNormalizingCharIterator(CharIterator delegate)
The constructor.

Parameters:
delegate - is the CharIterator to adapt.

SpaceNormalizingCharIterator

public SpaceNormalizingCharIterator(CharIterator delegate,
                                    CharFilter spaceFilter,
                                    boolean trim)
The constructor.

Parameters:
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.
Method Detail

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.