Class pat.RegexTokenizer
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class pat.RegexTokenizer

java.lang.Object
   |
   +----pat.RegexTokenizer

public class RegexTokenizer
extends Object
implements Enumeration
Shareware: package pat Copyright 1996, Steven R. Brandt

The RegexTokenizer is similar to the StringTokenizer class provided with java, but allows one to tokenize using regular expressions, rather than a simple list of characters. Tokens are any strings between the supplied regular expression, as well as any backreferences (things in parenthesis) contained within the regular expression.


Constructor Index

 o RegexTokenizer(String, Regex)
Initialize the tokenizer with a Regex object.
 o RegexTokenizer(String, String)
Initialize the tokenizer with a string of text and a pattern

Method Index

 o allTokens()
Returns all tokens in the String
 o countTokens()
Determines the # of remaining tokens
 o hasMoreElements()
Tells whether there are more tokens in the pattern.
 o hasMoreTokens()
Tells whether there are more tokens in the pattern, but in the fashion of StringTokenizer.
 o nextElement()
This should always be cast to a String, as in StringTokenizer, and as in StringTokenizer one can do this by calling nextString().
 o nextToken()
This is the equivalent (String)nextElement().
 o nextToken(Regex)
This asks for the next token, and changes the pattern being used at the same time.
 o nextToken(String)
This asks for the next token, and changes the pattern being used at the same time.

Constructors

 o RegexTokenizer
  public RegexTokenizer(String txt,
                        String ptrn)
Initialize the tokenizer with a string of text and a pattern
 o RegexTokenizer
  public RegexTokenizer(String txt,
                        Regex r)
Initialize the tokenizer with a Regex object.

Methods

 o nextElement
  public Object nextElement()
This should always be cast to a String, as in StringTokenizer, and as in StringTokenizer one can do this by calling nextString().
 o nextToken
  public String nextToken()
This is the equivalent (String)nextElement().
 o nextToken
  public String nextToken(String newpat)
This asks for the next token, and changes the pattern being used at the same time.
 o nextToken
  public String nextToken(Regex nr)
This asks for the next token, and changes the pattern being used at the same time.
 o hasMoreElements
  public boolean hasMoreElements()
Tells whether there are more tokens in the pattern.
 o hasMoreTokens
  public boolean hasMoreTokens()
Tells whether there are more tokens in the pattern, but in the fashion of StringTokenizer.
 o countTokens
  public int countTokens()
Determines the # of remaining tokens
 o allTokens
  public String[] allTokens()
Returns all tokens in the String

All Packages  Class Hierarchy  This Package  Previous  Next  Index