edu.umd.cfar.lamp.viper.util.reader
Class CountingStringTokenizer

java.lang.Object
  extended byjava.util.StringTokenizer
      extended byedu.umd.cfar.lamp.viper.util.reader.CountingStringTokenizer
All Implemented Interfaces:
java.util.Enumeration

public class CountingStringTokenizer
extends java.util.StringTokenizer

This class extends the StringTokenizer to also maintain a character index of each new token for error reporting.


Constructor Summary
CountingStringTokenizer(java.lang.String str)
          Constructs a new string tokenizer with the default delimiters and does not return them as tokens.
CountingStringTokenizer(java.lang.String str, java.lang.String delim)
          Constructs a new tokenizer with the given string and tokens.
CountingStringTokenizer(java.lang.String str, java.lang.String delim, boolean returnTokens)
          Constructs a new tokenizer with the given string and tokens, while allowing the delimiters to be returned as tokens.
 
Method Summary
 int countTokens()
          Unsupported operation.
 int getEnd()
          Get the index into the parent string of the last character of the most recently returned token.
 int getStart()
          Get the index into the parent string of the first character of the most recently returned token.
 boolean hasMoreElements()
          Tests to see if more tokens remain.
 boolean hasMoreTokens()
          Tests to see if more tokens remain.
 java.lang.Object nextElement()
          Gets the next token
 java.lang.String nextToken()
          Gets the next token
 java.lang.String nextToken(java.lang.String delim)
          Unsupported operation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CountingStringTokenizer

public CountingStringTokenizer(java.lang.String str)
Constructs a new string tokenizer with the default delimiters and does not return them as tokens.

Parameters:
str - the string to chop up

CountingStringTokenizer

public CountingStringTokenizer(java.lang.String str,
                               java.lang.String delim)
Constructs a new tokenizer with the given string and tokens.

Parameters:
str - the string to chop up
delim - the characters to use as delimiters

CountingStringTokenizer

public CountingStringTokenizer(java.lang.String str,
                               java.lang.String delim,
                               boolean returnTokens)
Constructs a new tokenizer with the given string and tokens, while allowing the delimiters to be returned as tokens.

Parameters:
str - the string to chop up
delim - the characters to use as delimiters
returnTokens - true if you would like all characters to be returned, not just non-delims
Method Detail

getEnd

public int getEnd()
Get the index into the parent string of the last character of the most recently returned token.

Returns:
index of first char, will be 0 is no token has been taken

getStart

public int getStart()
Get the index into the parent string of the first character of the most recently returned token.

Returns:
index of first char, will be -1 is no token has been taken

countTokens

public int countTokens()
Unsupported operation.

Returns:
Throws:
java.lang.UnsupportedOperationException

hasMoreElements

public boolean hasMoreElements()
Tests to see if more tokens remain.

Returns:
true if next returns an element, instead of throwing an exception.

hasMoreTokens

public boolean hasMoreTokens()
Tests to see if more tokens remain.

Returns:
true if next returns an element, instead of throwing an exception.

nextElement

public java.lang.Object nextElement()
Gets the next token

Returns:
the next token, if it exists
Throws:
java.util.NoSuchElementException

nextToken

public java.lang.String nextToken()
Gets the next token

Returns:
the next token, if it exists
Throws:
java.util.NoSuchElementException

nextToken

public java.lang.String nextToken(java.lang.String delim)
Unsupported operation

Parameters:
delim - the delimiters to switch to
Returns:
the next token, if it exists
Throws:
java.util.NoSuchElementException
java.lang.UnsupportedOperationException