org.jargp
Class CharTracker

java.lang.Object
  |
  +--org.jargp.CharTracker

public class CharTracker
extends java.lang.Object

Character tracker for processing text. This is effectively a specialized iterator for processing characters in a string one at a time.

Version:
1.0
Author:
Dennis M. Sosnoski

Constructor Summary
CharTracker(java.lang.String source, int offset)
          Constructor
 
Method Summary
 boolean hasNext()
          Check if another character is available.
 char next()
          Get next character from string, advancing past that character.
 char peek()
          Peek next character from string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CharTracker

public CharTracker(java.lang.String source,
                   int offset)
Constructor

Parameters:
source - string supplying character data
offset - initial character position within source string
Method Detail

next

public char next()
Get next character from string, advancing past that character.

Returns:
next character from string
Throws:
java.lang.ArrayIndexOutOfBoundsException - if past end of text

peek

public char peek()
Peek next character from string. Gets the next character without advancing the current character position.

Returns:
next character from string
Throws:
java.lang.ArrayIndexOutOfBoundsException - if past end of text

hasNext

public boolean hasNext()
Check if another character is available.

Returns:
true if a character is available, false if at end


Project Web Site