|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectinfo.informatica.text.TokenParser
public final class TokenParser
A StringTokenizer replacement with an Iterator
interface and more flexibility.
Separates a String in tokens separated by sep, but grouped by
delim.
Example: a,b,"c,d",e,f gives 5 tokens with default
constructor.
If the separator contains white space ' ', consecutive separators are ignored.
| Constructor Summary | |
|---|---|
TokenParser(String line)
Separates a String in tokens separated by commas, and grouped by double quotes. |
|
TokenParser(String line,
String separator)
Separates a String in tokens separated by separator, and
grouped by double quotes. |
|
TokenParser(String line,
String separator,
String delimiters)
Separates a String in tokens separated by separator, and
grouped by delimiters. |
|
| Method Summary | |
|---|---|
void |
findNext()
|
char |
getLastSeparator()
|
char |
getNextSeparator()
|
boolean |
hasMoreTokens()
|
boolean |
hasNext()
|
Object |
next()
|
String |
nextToken()
|
void |
remove()
|
static String[] |
tokenize(String l,
String sep,
char[] delim,
int init_size)
Tokenizes a string l using sep as a token
separator, while delim[] delimits a single token. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TokenParser(String line)
line - the String to separate in tokens
public TokenParser(String line,
String separator)
separator, and
grouped by double quotes.
line - the String to separate in tokensseparator - the separator String
public TokenParser(String line,
String separator,
String delimiters)
separator, and
grouped by delimiters.
line - the String to separate in tokensseparator - the separator Stringdelimiters - a String of token delimiters.| Method Detail |
|---|
public boolean hasNext()
hasNext in interface Iteratorpublic boolean hasMoreTokens()
public Object next()
next in interface Iteratorpublic String nextToken()
public void remove()
remove in interface Iteratorpublic void findNext()
public char getLastSeparator()
public char getNextSeparator()
public static String[] tokenize(String l,
String sep,
char[] delim,
int init_size)
l using sep as a token
separator, while delim[] delimits a single token.
Example: a,b,"c,d",e,f gives 5 tokens.
Warning: to preserve backwards-compatibility, this static method does not behave exactly as the (newer) Iterator version (see comment below).
l - the input line to tokenize.sep - the separator. In order to be compatible with legacy
applications, this static version of the class handles sep as
a separator which can be multiple-character.delim - the delimiter (generally {'"'}).init_size - a guess of the number of tokens to be found, used to set the
initial size of the array.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||