jregex
Class RETokenizer

java.lang.Object
  |
  +--jregex.RETokenizer
All Implemented Interfaces:
java.util.Enumeration

public class RETokenizer
extends java.lang.Object
implements java.util.Enumeration

The Tokenizer class suggests a methods to break a text into tokens using occurences of a pattern as delimiters. There are two ways to obtain a text tokenizer for some pattern:

 Pattern p=new Pattern("\\s+"); //any number of space characters
 String text="blah blah blah";
 //by factory method
 RETokenizer tok1=p.tokenizer(text);
 //or by constructor
 RETokenizer tok2=new RETokenizer(p,text);
 
Now the one way is to use the tokenizer as a token enumeration/iterator:
 while(tok1.hasMore()) System.out.println(tok1.nextToken());
 
and another way is to split it into a String array:
 
 String[] arr=tok2.split();
 for(int i=0;i

See Also:
Pattern.tokenizer(java.lang.String)

Constructor Summary
RETokenizer(Matcher m, boolean emptyEnabled)
           
RETokenizer(Pattern pattern, char[] chars, int off, int len)
           
RETokenizer(Pattern pattern, java.io.Reader r, int len)
           
RETokenizer(Pattern pattern, java.lang.String text)
           
 
Method Summary
 boolean hasMore()
           
 boolean hasMoreElements()
           
 boolean isEmptyEnabled()
           
static void main(java.lang.String[] args)
           
 java.lang.Object nextElement()
           
 java.lang.String nextToken()
           
 void reset()
           
 void setEmptyEnabled(boolean b)
           
 java.lang.String[] split()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RETokenizer

public RETokenizer(Pattern pattern,
                   java.lang.String text)

RETokenizer

public RETokenizer(Pattern pattern,
                   char[] chars,
                   int off,
                   int len)

RETokenizer

public RETokenizer(Pattern pattern,
                   java.io.Reader r,
                   int len)
            throws java.io.IOException

RETokenizer

public RETokenizer(Matcher m,
                   boolean emptyEnabled)
Method Detail

setEmptyEnabled

public void setEmptyEnabled(boolean b)

isEmptyEnabled

public boolean isEmptyEnabled()

hasMore

public boolean hasMore()

nextToken

public java.lang.String nextToken()

split

public java.lang.String[] split()

reset

public void reset()

hasMoreElements

public boolean hasMoreElements()
Specified by:
hasMoreElements in interface java.util.Enumeration

nextElement

public java.lang.Object nextElement()
Specified by:
nextElement in interface java.util.Enumeration
Returns:
a next token as a String

main

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