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.
-
RegexTokenizer(String, Regex)
- Initialize the tokenizer with a Regex object.
-
RegexTokenizer(String, String)
- Initialize the tokenizer with a string of text and a pattern
-
allTokens()
- Returns all tokens in the String
-
countTokens()
- Determines the # of remaining tokens
-
hasMoreElements()
- Tells whether there are more tokens in the pattern.
-
hasMoreTokens()
- Tells whether there are more tokens in the pattern, but
in the fashion of StringTokenizer.
-
nextElement()
- This should always be cast to a String, as in StringTokenizer,
and as in StringTokenizer one can do this by calling
nextString().
-
nextToken()
- This is the equivalent (String)nextElement().
-
nextToken(Regex)
- This asks for the next token, and changes the pattern
being used at the same time.
-
nextToken(String)
- This asks for the next token, and changes the pattern
being used at the same time.
RegexTokenizer
public RegexTokenizer(String txt,
String ptrn)
- Initialize the tokenizer with a string of text and a pattern
RegexTokenizer
public RegexTokenizer(String txt,
Regex r)
- Initialize the tokenizer with a Regex object.
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().
nextToken
public String nextToken()
- This is the equivalent (String)nextElement().
nextToken
public String nextToken(String newpat)
- This asks for the next token, and changes the pattern
being used at the same time.
nextToken
public String nextToken(Regex nr)
- This asks for the next token, and changes the pattern
being used at the same time.
hasMoreElements
public boolean hasMoreElements()
- Tells whether there are more tokens in the pattern.
hasMoreTokens
public boolean hasMoreTokens()
- Tells whether there are more tokens in the pattern, but
in the fashion of StringTokenizer.
countTokens
public int countTokens()
- Determines the # of remaining tokens
allTokens
public String[] allTokens()
- Returns all tokens in the String
All Packages Class Hierarchy This Package Previous Next Index