org.xbill.DNS.utils
Class MyStringTokenizer

java.lang.Object
  |
  +--org.xbill.DNS.utils.MyStringTokenizer

public class MyStringTokenizer
extends Object
implements Enumeration

A class similar to StringTokenizer, with a few differences making it more suitable. The \ character is used as an escape character, allowing delimiters to be escaped and \xxx decimal value to be used. Quoted strings (delimited by double quotes) are treated as one token.


Constructor Summary
MyStringTokenizer(String _s)
          Creates a new instance of MyStringTokenizer, with whitespace delimiters (space, tab, newline).
MyStringTokenizer(String _s, String _delim)
          Creates a new instance of MyStringTokenizer.
MyStringTokenizer(String _s, String _delim, boolean _returnTokens)
          Creates a new instance of MyStringTokenizer.
 
Method Summary
 boolean hasMoreDelimiters()
          Are there any more delimiters in the string? This should only be called if hasMoreTokens is false, to determine if the string contains trailing delimiters.
 boolean hasMoreElements()
          Are there any more tokens in the string
 boolean hasMoreTokens()
          Are there any more tokens in the string
static void main(String[] args)
           
 Object nextElement()
          Returns the next token
 String nextToken()
          Returns the next token
 void putBackToken(String s)
          Specifies a string to be added to the MyStringTokenizer object.
 String remainingTokens()
          Returns a concatenation of all remaining tokens
 void setNoEscapeCharacter()
          Turns off the escape character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyStringTokenizer

public MyStringTokenizer(String _s,
                         String _delim,
                         boolean _returnTokens)
Creates a new instance of MyStringTokenizer.
Parameters:
s - The string to be tokenized
delim - A string containing all delimiters
returnTokens - If true, return delimiters as tokens. This differs from StringTokenizer in that adjacent delimiters are returned in the same token.

MyStringTokenizer

public MyStringTokenizer(String _s,
                         String _delim)
Creates a new instance of MyStringTokenizer.
Parameters:
s - The string to be tokenized
delim - A string containing all delimiters

MyStringTokenizer

public MyStringTokenizer(String _s)
Creates a new instance of MyStringTokenizer, with whitespace delimiters (space, tab, newline).
Parameters:
s - The string to be tokenized
Method Detail

setNoEscapeCharacter

public void setNoEscapeCharacter()
Turns off the escape character. Useful when tokenizing the output of the tokenizer.

hasMoreTokens

public boolean hasMoreTokens()
Are there any more tokens in the string

hasMoreElements

public boolean hasMoreElements()
Are there any more tokens in the string
Specified by:
hasMoreElements in interface Enumeration

hasMoreDelimiters

public boolean hasMoreDelimiters()
Are there any more delimiters in the string? This should only be called if hasMoreTokens is false, to determine if the string contains trailing delimiters.

nextToken

public String nextToken()
Returns the next token

nextElement

public Object nextElement()
Returns the next token
Specified by:
nextElement in interface Enumeration

putBackToken

public void putBackToken(String s)
Specifies a string to be added to the MyStringTokenizer object. The next call to nextToken() will return this string.

remainingTokens

public String remainingTokens()
Returns a concatenation of all remaining tokens

main

public static void main(String[] args)
                 throws IOException