org.jargp
Class StringTracker

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

public class StringTracker
extends java.lang.Object

String tracker for processing an array of strings. This is effectively a specialized iterator for processing an array of strings one at a time.

Version:
1.0
Author:
Dennis M. Sosnoski

Constructor Summary
StringTracker(java.lang.String[] source, int offset)
          Constructor
 
Method Summary
 boolean hasNext()
          Check if another string is available.
 int length()
          Get length of array.
 java.lang.String next()
          Get next string from array, advancing past that string.
 int nextOffset()
          Get position of next string in array.
 java.lang.String peek()
          Peek next string from array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringTracker

public StringTracker(java.lang.String[] source,
                     int offset)
Constructor

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

next

public java.lang.String next()
Get next string from array, advancing past that string.

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

peek

public java.lang.String peek()
Peek next string from array. Gets the next string without advancing the current string position.

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

hasNext

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

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

nextOffset

public int nextOffset()
Get position of next string in array.

Returns:
offset in array of next string

length

public int length()
Get length of array.

Returns:
total number of strings in array


Project Web Site