|
JClass DesktopViews 6.3.0 API Documentation |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.klg.jclass.util.JCStringTokenizer
JCStringTokenizer controls simple linear tokenization
of a String. The set of delimiters, which defaults to common
whitespace characters, can be specified either during creation or on a
per-token basis.
It is similar to java.util.StringTokenizer, but delimiters can
be included as literals by preceding them with a backslash character (the
default).
It also fixes a known problem: if one delimiter immediately follows another, a null String is returned as the token instead of being skipped over.
Example usage:
String token, s = "this, is, a,, test";
JCStringTokenizer st = new JCStringTokenizer(s);
while (st.hasMoreTokens()) {
token = st.nextToken(',');
println(token);
}
This prints the following to the console:
this is a test
| Field Summary | |
protected char |
escape_char
|
boolean |
strip_esc
|
| Constructor Summary | |
JCStringTokenizer(String s)
Creates a tokenizer based on the specified String. |
|
JCStringTokenizer(String s,
boolean trim)
|
|
JCStringTokenizer(String s,
char delim)
|
|
| Method Summary | |
int |
countTokens(char delim)
Returns the next number of tokens in the String using the specified delimiter. |
char |
getEscapeChar()
Gets the escape char (default is \). |
int |
getPosition()
Returns the current scan position within the String. |
boolean |
hasMoreTokens()
Returns true if more tokens exist. |
String |
nextToken()
Gets the next whitespace-delimited token. |
String |
nextToken(char delim)
Gets the next token from delimited String. |
static String[] |
parse(String s,
char delim)
Parses the String using the specified delimiter. |
static String[] |
parse(String s,
char delim,
char escape_char)
Parses the String using the specified delimiter and escape char. |
static String[] |
parseWhitespaceDelim(String s,
char delim,
char escape_char)
|
void |
setEscapeChar(char c)
Sets the escape char (default is \). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public boolean strip_esc
protected char escape_char
| Constructor Detail |
public JCStringTokenizer(String s)
s -
public JCStringTokenizer(String s,
boolean trim)
public JCStringTokenizer(String s,
char delim)
| Method Detail |
public static String[] parse(String s,
char delim)
delim - s -
nextToken()
public static String[] parse(String s,
char delim,
char escape_char)
delim - escape_char - s -
setEscapeChar(char),
nextToken()
public static String[] parseWhitespaceDelim(String s,
char delim,
char escape_char)
public char getEscapeChar()
public void setEscapeChar(char c)
c - public String nextToken()
public String nextToken(char delim)
The delimeter can be "escaped" by a backslash character.
To include a backslash character, precede it by another backslash character.
delim -
public int countTokens(char delim)
delim - the delimiter
public boolean hasMoreTokens()
true if more tokens exist.
true if more tokens existpublic int getPosition()
|
Copyright © 2004 Quest Software Inc.. All rights reserved. |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||