|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.pentaho.di.core.SimpleTokenizer
public class SimpleTokenizer
The SimpleTokenizer class is used to break a string into tokens.
The delimiter can be used in one of two ways, depending on how the singleDelimiter flag is set:
The total number of tokens in the text is equal to the number of delimeters found plus one. An empty token is returned when:
You can use the tokenizer like the StringTokenizer:
SimpleTokenizer st = new SimpleTokenizer("this is a test", " ");
while (st.hasMoreTokens())
println(st.nextToken());
Or, you can use the tokenizer like the String.split(...) method:
SimpleTokenizer st = new SimpleTokenizer("this is a test", " ");
List list = st.getAllTokens();
for (java.util.Iterator it = list.iterator(); it.hasNext();)
println(it.next());
StringTokenizer,
String.split(java.lang.String, int)| Constructor Summary | |
|---|---|
SimpleTokenizer(String text,
String delimiter)
Constructs a tokenizer for the specified string. |
|
SimpleTokenizer(String text,
String delimiter,
boolean singleDelimiter)
Constructs a tokenizer for the specified string. |
|
| Method Summary | |
|---|---|
List<String> |
getAllTokens()
Tokenize the remaining text and return all the tokens |
String |
getRemainder()
Get the text that has not yet been tokenized. |
boolean |
hasMoreTokens()
Tests if there are more tokens available from this tokenizer. |
String |
nextToken()
Returns the next token from this tokenizer. |
String |
nextToken(int tokenCount)
Returns the nth token from the current position of this tokenizer. |
void |
setDelimiter(String delimiter)
Set the delimiter(s) used to parse the text. |
void |
setText(String text)
Set the text to be tokenized. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleTokenizer(String text,
String delimiter)
text - a string to be tokenized.delimiter - the delimiter.
public SimpleTokenizer(String text,
String delimiter,
boolean singleDelimiter)
If the singleDelmiter flag is true, then the delimiter string is used as a single delimiter. If the flag is false, the each character in the delimiter is treated as a delimiter.
text - a string to be tokenized.delimiter - the delimiter(s).multipleDelimiters - treat each character as a delimiter.| Method Detail |
|---|
public void setText(String text)
text - a string to be tokenized.public void setDelimiter(String delimiter)
delimiter - the delimiter.public boolean hasMoreTokens()
true when there is at least one token remaining;
false otherwise.public String nextToken()
NoSuchElementException - if there are no more tokenspublic String nextToken(int tokenCount)
tokenCount - the relative position of the token requested
NoSuchElementException - if there are no more tokenspublic String getRemainder()
public List<String> getAllTokens()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||