IMC Epclient 5.0.3

at.spardat.enterprise.util
Class StringSplitter

java.lang.Object
  extended byat.spardat.enterprise.util.StringSplitter

public class StringSplitter
extends java.lang.Object

Extracts substrings, that are delimited by a provided delimiter-character, from a given String.

hasMoreTokens may be used to check if there are more tokens left, nextToken returns the next String-token. Example: Suppose, you want to iterate over the substrings that are separated by a comma in the String 'a,b,,c', then successive calls to nextToken return

 "a", "b", "", "c"
 
Empty strings are returned if two delimiter-characters follow up (or are at the beginning or at the end of the string).

An optional escape-character may be specified (that's the feature that makes this class worth using). For example, using the percent character as escape-character and a comma as delimiter, then

 StringSplitter           ss = new StringSplitter ("aa,bb,cc,%,%,", ',', '%');
 
yields the substrings
 "aa", "bb", "cc", ",,"
 

Author:
YSD

Constructor Summary
StringSplitter(java.lang.String str, char delimiter)
          Constructor where no escape character is set.
StringSplitter(java.lang.String str, char delimiter, char escapeCharacter)
          Constructor.
 
Method Summary
 java.lang.String getString()
          Returns the input string set at construction time.
 boolean hasMoreTokens()
          Returns true if nextToken() will yield a token
static void main(java.lang.String[] args)
           
 java.lang.String nextToken()
          Returns the next token.
 java.lang.String peekNextToken()
          See the next token without advancing the counter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringSplitter

public StringSplitter(java.lang.String str,
                      char delimiter)
Constructor where no escape character is set.

Parameters:
str - the input string
delimiter - separator character

StringSplitter

public StringSplitter(java.lang.String str,
                      char delimiter,
                      char escapeCharacter)
Constructor.

Parameters:
str - the input string
delimiter - delimiter character
escapeCharacter - escape character used
Method Detail

hasMoreTokens

public boolean hasMoreTokens()
Returns true if nextToken() will yield a token


nextToken

public java.lang.String nextToken()
Returns the next token. Must not be called if !hasMoreTokens().


peekNextToken

public java.lang.String peekNextToken()
See the next token without advancing the counter.


getString

public java.lang.String getString()
Returns the input string set at construction time.


main

public static void main(java.lang.String[] args)

IMC Epclient 5.0.3