Java Doc for StringTokenizer.java in  » Template-Engine » ostermillerutils » com » Ostermiller » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Template Engine » ostermillerutils » com.Ostermiller.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.Ostermiller.util.StringTokenizer

StringTokenizer
public class StringTokenizer implements java.util.Enumeration<String>,java.util.Iterator<String>(Code)
The string tokenizer class allows an application to break a string into tokens. More information about this class is available from ostermiller.org.

The tokenization method is much simpler than the one used by the StreamTokenizer class. The StringTokenizer methods do not distinguish among identifiers, numbers, and quoted strings, nor do they recognize and skip comments.

The set of delimiters (the characters that separate tokens) may be specified either at creation time or on a per-token basis.

There are two kinds of delimiters: token delimiters and non-token delimiters. A token is either one token delimiter character, or a maximal sequence of consecutive characters that are not delimiters.

A StringTokenizer object internally maintains a current position within the string to be tokenized. Some operations advance this current position past the characters processed.

The implementation is not thread safe; if a StringTokenizer object is intended to be used in multiple threads, an appropriate wrapper must be provided.

The following is one example of the use of the tokenizer. It also demonstrates the usefulness of having both token and non-token delimiters in one StringTokenizer.

The code:

String s = "  (   aaa \t  * (b+c1 ))";
StringTokenizer tokenizer = new StringTokenizer(s, " \t\n\r\f", "()+*");
while (tokenizer.hasMoreTokens()) {
    System.out.println(tokenizer.nextToken());
};

prints the following output:

(
aaa

(
b
+
c1
)
)

Compatibility with java.util.StringTokenizer

In the original version of java.util.StringTokenizer, the method nextToken() left the current position after the returned token, and the method hasMoreTokens() moved (as a side effect) the current position before the beginning of the next token. Thus, the code:

String s = "x=a,b,c";
java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(s,"=");
System.out.println(tokenizer.nextToken());
while (tokenizer.hasMoreTokens()) {
    System.out.println(tokenizer.nextToken(","));
};

prints the following output:

x
a
b
c

The Java SDK 1.3 implementation removed the undesired side effect of hasMoreTokens method: now, it does not advance current position. However, after these changes the output of the above code was:

x
=a
b
c

and there was no good way to produce a second token without "=".

To solve the problem, this implementation introduces a new method skipDelimiters(). To produce the original output, the above code should be modified as:

String s = "x=a,b,c";
StringTokenizer tokenizer = new StringTokenizer(s,"=");
System.out.println(tokenizer.nextToken());
tokenizer.skipDelimiters();
while (tokenizer.hasMoreTokens()) {
    System.out.println(tokenizer.nextToken(","));
};

author:
   Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities
since:
   ostermillerutils 1.00.00


Field Summary
protected  intdelimsChangedPosition
     Indicates at which position the delimiters last changed.
protected  booleanemptyReturned
     One of two variables used to maintain state through the tokenizing process.
protected  charmaxDelimChar
     Stores the value of the delimiter character with the highest value.
protected  StringnontokenDelims
     The set of non-token delimiters.
protected  intposition
     One of two variables used to maintain state through the tokenizing process.
protected  booleanreturnEmptyTokens
     Whether empty tokens should be returned.
protected  intstrLength
     The length of the text. Cached for performance.
protected  Stringtext
     The string to be tokenized.
protected  inttokenCount
     A cache of the token count.
protected  StringtokenDelims
     The set of token delimiters.

Constructor Summary
public  StringTokenizer(String text, String nontokenDelims, String tokenDelims)
     Constructs a string tokenizer for the specified string.
public  StringTokenizer(String text, String nontokenDelims, String tokenDelims, boolean returnEmptyTokens)
     Constructs a string tokenizer for the specified string.
public  StringTokenizer(String text, String delims, boolean delimsAreTokens)
     Constructs a string tokenizer for the specified string.
public  StringTokenizer(String text, String nontokenDelims)
     Constructs a string tokenizer for the specified string.
public  StringTokenizer(String text)
     Constructs a string tokenizer for the specified string.

Method Summary
public  intcountTokens()
     Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception.
public  intcountTokens(String delims)
     Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception using the given set of (non-token) delimiters.
public  intcountTokens(String delims, boolean delimsAreTokens)
     Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception using the given set of delimiters.
public  intcountTokens(String nontokenDelims, String tokenDelims)
     Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception using the given set of delimiters.
public  intcountTokens(String nontokenDelims, String tokenDelims, boolean returnEmptyTokens)
     Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception using the given set of delimiters.
public  intgetCurrentPosition()
     Get the the index of the character immediately following the end of the last token.
public  booleanhasMoreElements()
     Returns the same value as the hasMoreTokens() method.
public  booleanhasMoreTokens()
     Tests if there are more tokens available from this tokenizer's string.
public  booleanhasNext()
     Returns the same value as the hasMoreTokens() method.
public  Stringnext()
     Returns the same value as the nextToken() method, except that its declared return value is Object rather than String.
public  StringnextElement()
     Returns the same value as the nextToken() method, except that its declared return value is Object rather than String.
public  StringnextToken()
     Returns the next token from this string tokenizer.
public  StringnextToken(String nontokenDelims, String tokenDelims)
     Returns the next token in this string tokenizer's string.

First, the sets of token and non-token delimiters are changed to be the tokenDelims and nontokenDelims, respectively. Then the next token (with respect to new delimiters) in the string after the current position is returned.

The current position is set after the token returned.

The new delimiter sets remains the used ones after this call.
Parameters:
  nontokenDelims - the new set of non-token delimiters.
Parameters:
  tokenDelims - the new set of token delimiters.

public  StringnextToken(String nontokenDelims, String tokenDelims, boolean returnEmptyTokens)
     Returns the next token in this string tokenizer's string.

First, the sets of token and non-token delimiters are changed to be the tokenDelims and nontokenDelims, respectively; and whether or not to return empty tokens is set. Then the next token (with respect to new delimiters) in the string after the current position is returned.

The current position is set after the token returned.

The new delimiter set remains the one used for this call and empty tokens are returned in the future as they are in this call.
Parameters:
  nontokenDelims - the new set of non-token delimiters.
Parameters:
  tokenDelims - the new set of token delimiters.
Parameters:
  returnEmptyTokens - true if empty tokens may be returned; false otherwise.

public  StringnextToken(String delims, boolean delimsAreTokens)
     Returns the next token in this string tokenizer's string.

Is equivalent to:

  • If the second parameter is false -- nextToken(delimiters, null)
  • If the second parameter is true -- nextToken(null, delimiters)


Parameters:
  delims - the new set of token or non-token delimiters.
Parameters:
  delimsAreTokens - flag indicating whether the first parameter specifies token ornon-token delimiters: false -- the first parameterspecifies non-token delimiters, the set of token delimiters isempty; true -- the first parameter specifies tokendelimiters, the set of non-token delimiters is empty.

public  StringnextToken(String nontokenDelims)
     Returns the next token in this string tokenizer's string.

Is equivalent to nextToken(delimiters, null).
Parameters:
  nontokenDelims - the new set of non-token delimiters (the set oftoken delimiters will be empty).

public  Stringpeek()
     Returns the same value as nextToken() but does not alter the internal state of the Tokenizer.
public  voidremove()
     This implementation always throws UnsupportedOperationException.
public  StringrestOfText()
     Retrieves the rest of the text as a single token.
public  voidsetDelimiters(String delims)
     Set the delimiters used to this set of (non-token) delimiters.
public  voidsetDelimiters(String delims, boolean delimsAreTokens)
     Set the delimiters used to this set of delimiters.
public  voidsetDelimiters(String nontokenDelims, String tokenDelims)
     Set the delimiters used to this set of delimiters.
public  voidsetDelimiters(String nontokenDelims, String tokenDelims, boolean returnEmptyTokens)
     Set the delimiters used to this set of delimiters.
public  voidsetReturnEmptyTokens(boolean returnEmptyTokens)
     Set whether empty tokens should be returned from this point in in the tokenizing process onward.

Empty tokens occur when two delimiters are next to each other or a delimiter occurs at the beginning or end of a string.

public  voidsetText(String text)
     Set the text to be tokenized in this StringTokenizer.
public  booleanskipDelimiters()
     Advances the current position so it is before the next token.
public  String[]toArray()
     Retrieve all of the remaining tokens in a String array.

Field Detail
delimsChangedPosition
protected int delimsChangedPosition(Code)
Indicates at which position the delimiters last changed. This will effect how null tokens are returned. Any time that delimiters are changed, the string will be treated as if it is being parsed from position zero, for example, null strings are possible at the very beginning.
since:
   ostermillerutils 1.00.00



emptyReturned
protected boolean emptyReturned(Code)
One of two variables used to maintain state through the tokenizing process.

true if and only if is found that an empty token should be returned or if empty token was the last thing returned.

If returnEmptyTokens in false, then this variable will always be false.
since:
   ostermillerutils 1.00.00




maxDelimChar
protected char maxDelimChar(Code)
Stores the value of the delimiter character with the highest value. It is used to optimize the detection of delimiter characters. The common case will be that the int values of delimiters will be less than that of most characters in the string (, or space less than any letter for example). Given this, we can check easily check to see if a character is not a delimiter by comparing it to the max delimiter. If it is greater than the max delimiter, then it is no a delimiter otherwise we have to do some more in depth analysis. (for example search the delimiter string.) This will reduce the running time of the algorithm not to depend on the length of the delimiter string for the common case.
since:
   ostermillerutils 1.00.00



nontokenDelims
protected String nontokenDelims(Code)
The set of non-token delimiters.
since:
   ostermillerutils 1.00.00



position
protected int position(Code)
One of two variables used to maintain state through the tokenizing process.

Represents the position at which we should start looking for the next token(the position of the character immediately following the end of the last token, or 0 to start), or -1 if the entire string has been examined.
since:
   ostermillerutils 1.00.00




returnEmptyTokens
protected boolean returnEmptyTokens(Code)
Whether empty tokens should be returned. for example, if "" should be returned when text starts with a delimiter, has two delimiters next to each other, or ends with a delimiter.
since:
   ostermillerutils 1.00.00



strLength
protected int strLength(Code)
The length of the text. Cached for performance. This should be set whenever the string we are working with is changed.
since:
   ostermillerutils 1.00.00



text
protected String text(Code)
The string to be tokenized. The code relies on this to never be null.
since:
   ostermillerutils 1.00.00



tokenCount
protected int tokenCount(Code)
A cache of the token count. This variable should be -1 if the token have not yet been counted. It should be greater than or equal to zero if the tokens have been counted.
since:
   ostermillerutils 1.00.00



tokenDelims
protected String tokenDelims(Code)
The set of token delimiters.
since:
   ostermillerutils 1.00.00




Constructor Detail
StringTokenizer
public StringTokenizer(String text, String nontokenDelims, String tokenDelims)(Code)
Constructs a string tokenizer for the specified string. Both token and non-token delimiters are specified.

The current position is set at the beginning of the string.
Parameters:
  text - a string to be parsed.
Parameters:
  nontokenDelims - the non-token delimiters, i.e. the delimiters that only separatetokens and are not returned as separate tokens.
Parameters:
  tokenDelims - the token delimiters, i.e. delimiters that both separate tokens,and are themselves returned as tokens.
throws:
  NullPointerException - if text is null.
since:
   ostermillerutils 1.00.00




StringTokenizer
public StringTokenizer(String text, String nontokenDelims, String tokenDelims, boolean returnEmptyTokens)(Code)
Constructs a string tokenizer for the specified string. Both token and non-token delimiters are specified and whether or not empty tokens are returned is specified.

Empty tokens are tokens that are between consecutive delimiters.

It is a primary constructor (i.e. all other constructors are defined in terms of it.)

The current position is set at the beginning of the string.
Parameters:
  text - a string to be parsed.
Parameters:
  nontokenDelims - the non-token delimiters, i.e. the delimiters that only separatetokens and are not returned as separate tokens.
Parameters:
  tokenDelims - the token delimiters, i.e. delimiters that both separate tokens,and are themselves returned as tokens.
Parameters:
  returnEmptyTokens - true if empty tokens may be returned; false otherwise.
throws:
  NullPointerException - if text is null.
since:
   ostermillerutils 1.00.00




StringTokenizer
public StringTokenizer(String text, String delims, boolean delimsAreTokens)(Code)
Constructs a string tokenizer for the specified string. Either token or non-token delimiters are specified.

Is equivalent to:

  • If the third parameter is false -- StringTokenizer(text, delimiters, null)
  • If the third parameter is true -- StringTokenizer(text, null, delimiters)

Parameters:
  text - a string to be parsed.
Parameters:
  delims - the delimiters.
Parameters:
  delimsAreTokens - flag indicating whether the second parameter specifies token ornon-token delimiters: false -- the second parameterspecifies non-token delimiters, the set of token delimiters isempty; true -- the second parameter specifies tokendelimiters, the set of non-token delimiters is empty.
throws:
  NullPointerException - if text is null.
since:
   ostermillerutils 1.00.00



StringTokenizer
public StringTokenizer(String text, String nontokenDelims)(Code)
Constructs a string tokenizer for the specified string. The characters in the nontokenDelims argument are the delimiters for separating tokens. Delimiter characters themselves will not be treated as tokens.

Is equivalent to StringTokenizer(text,nontokenDelims, null).
Parameters:
  text - a string to be parsed.
Parameters:
  nontokenDelims - the non-token delimiters.
throws:
  NullPointerException - if text is null.
since:
   ostermillerutils 1.00.00




StringTokenizer
public StringTokenizer(String text)(Code)
Constructs a string tokenizer for the specified string. The tokenizer uses " \t\n\r\f" as a delimiter set of non-token delimiters, and an empty token delimiter set.

Is equivalent to StringTokenizer(text, " \t\n\r\f", null);
Parameters:
  text - a string to be parsed.
throws:
  NullPointerException - if text is null.
since:
   ostermillerutils 1.00.00





Method Detail
countTokens
public int countTokens()(Code)
Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception. The current position is not advanced. the number of tokens remaining in the string using the currentdelimiter set.
See Also:   StringTokenizer.nextToken()
since:
   ostermillerutils 1.00.00



countTokens
public int countTokens(String delims)(Code)
Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception using the given set of (non-token) delimiters. The delimiters given will be used for future calls to nextToken() unless new delimiters are given. The current position is not advanced.
Parameters:
  delims - the new set of non-token delimiters (the set of token delimiters will be empty). the number of tokens remaining in the string using the newdelimiter set.
See Also:   StringTokenizer.countTokens()
since:
   ostermillerutils 1.00.00



countTokens
public int countTokens(String delims, boolean delimsAreTokens)(Code)
Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception using the given set of delimiters. The delimiters given will be used for future calls to nextToken() unless new delimiters are given. The current position is not advanced.
Parameters:
  delims - the new set of delimiters.
Parameters:
  delimsAreTokens - flag indicating whether the first parameter specifiestoken or non-token delimiters: false -- the first parameter specifies non-tokendelimiters, the set of token delimiters is empty; true -- the first parameterspecifies token delimiters, the set of non-token delimiters is empty. the number of tokens remaining in the string using the newdelimiter set.
See Also:   StringTokenizer.countTokens()
since:
   ostermillerutils 1.00.00



countTokens
public int countTokens(String nontokenDelims, String tokenDelims)(Code)
Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception using the given set of delimiters. The delimiters given will be used for future calls to nextToken() unless new delimiters are given. The current position is not advanced.
Parameters:
  nontokenDelims - the new set of non-token delimiters.
Parameters:
  tokenDelims - the new set of token delimiters. the number of tokens remaining in the string using the newdelimiter set.
See Also:   StringTokenizer.countTokens()
since:
   ostermillerutils 1.00.00



countTokens
public int countTokens(String nontokenDelims, String tokenDelims, boolean returnEmptyTokens)(Code)
Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception using the given set of delimiters. The delimiters given will be used for future calls to nextToken() unless new delimiters are given. The current position is not advanced.
Parameters:
  nontokenDelims - the new set of non-token delimiters.
Parameters:
  tokenDelims - the new set of token delimiters.
Parameters:
  returnEmptyTokens - true if empty tokens may be returned; false otherwise. the number of tokens remaining in the string using the newdelimiter set.
See Also:   StringTokenizer.countTokens()
since:
   ostermillerutils 1.00.00



getCurrentPosition
public int getCurrentPosition()(Code)
Get the the index of the character immediately following the end of the last token. This is the position at which this tokenizer will begin looking for the next token when a nextToken() method is invoked. the current position or -1 if the entire string has been tokenized.
since:
   ostermillerutils 1.00.00



hasMoreElements
public boolean hasMoreElements()(Code)
Returns the same value as the hasMoreTokens() method. It exists so that this class can implement the Enumeration interface. true if there are more tokens;false otherwise.
See Also:   java.util.Enumeration
See Also:   StringTokenizer.hasMoreTokens()
since:
   ostermillerutils 1.00.00



hasMoreTokens
public boolean hasMoreTokens()(Code)
Tests if there are more tokens available from this tokenizer's string. If this method returns true, then a subsequent call to nextToken with no argument will successfully return a token.

The current position is not changed. true if and only if there is at least one token in thestring after the current position; false otherwise.
since:
   ostermillerutils 1.00.00




hasNext
public boolean hasNext()(Code)
Returns the same value as the hasMoreTokens() method. It exists so that this class can implement the Iterator interface. true if there are more tokens;false otherwise.
See Also:   java.util.Iterator
See Also:   StringTokenizer.hasMoreTokens()
since:
   ostermillerutils 1.00.00



next
public String next()(Code)
Returns the same value as the nextToken() method, except that its declared return value is Object rather than String. It exists so that this class can implement the Iterator interface. the next token in the string.
throws:
  NoSuchElementException - if there are no more tokens in this tokenizer's string.
See Also:   java.util.Iterator
See Also:   StringTokenizer.nextToken()
since:
   ostermillerutils 1.00.00



nextElement
public String nextElement()(Code)
Returns the same value as the nextToken() method, except that its declared return value is Object rather than String. It exists so that this class can implement the Enumeration interface. the next token in the string.
throws:
  NoSuchElementException - if there are no more tokens in this tokenizer's string.
See Also:   java.util.Enumeration
See Also:   StringTokenizer.nextToken()
since:
   ostermillerutils 1.00.00



nextToken
public String nextToken()(Code)
Returns the next token from this string tokenizer.

The current position is set after the token returned. the next token from this string tokenizer.
throws:
  NoSuchElementException - if there are no more tokens in this tokenizer's string.
since:
   ostermillerutils 1.00.00




nextToken
public String nextToken(String nontokenDelims, String tokenDelims)(Code)
Returns the next token in this string tokenizer's string.

First, the sets of token and non-token delimiters are changed to be the tokenDelims and nontokenDelims, respectively. Then the next token (with respect to new delimiters) in the string after the current position is returned.

The current position is set after the token returned.

The new delimiter sets remains the used ones after this call.
Parameters:
  nontokenDelims - the new set of non-token delimiters.
Parameters:
  tokenDelims - the new set of token delimiters. the next token, after switching to the new delimiter set.
throws:
  NoSuchElementException - if there are no more tokens in this tokenizer's string.
See Also:   StringTokenizer.nextToken()
since:
   ostermillerutils 1.00.00




nextToken
public String nextToken(String nontokenDelims, String tokenDelims, boolean returnEmptyTokens)(Code)
Returns the next token in this string tokenizer's string.

First, the sets of token and non-token delimiters are changed to be the tokenDelims and nontokenDelims, respectively; and whether or not to return empty tokens is set. Then the next token (with respect to new delimiters) in the string after the current position is returned.

The current position is set after the token returned.

The new delimiter set remains the one used for this call and empty tokens are returned in the future as they are in this call.
Parameters:
  nontokenDelims - the new set of non-token delimiters.
Parameters:
  tokenDelims - the new set of token delimiters.
Parameters:
  returnEmptyTokens - true if empty tokens may be returned; false otherwise. the next token, after switching to the new delimiter set.
throws:
  NoSuchElementException - if there are no more tokens in this tokenizer's string.
See Also:   StringTokenizer.nextToken()
since:
   ostermillerutils 1.00.00




nextToken
public String nextToken(String delims, boolean delimsAreTokens)(Code)
Returns the next token in this string tokenizer's string.

Is equivalent to:

  • If the second parameter is false -- nextToken(delimiters, null)
  • If the second parameter is true -- nextToken(null, delimiters)


Parameters:
  delims - the new set of token or non-token delimiters.
Parameters:
  delimsAreTokens - flag indicating whether the first parameter specifies token ornon-token delimiters: false -- the first parameterspecifies non-token delimiters, the set of token delimiters isempty; true -- the first parameter specifies tokendelimiters, the set of non-token delimiters is empty. the next token, after switching to the new delimiter set.
throws:
  NoSuchElementException - if there are no more tokens in this tokenizer's string.
See Also:   StringTokenizer.nextToken(String,String)
since:
   ostermillerutils 1.00.00




nextToken
public String nextToken(String nontokenDelims)(Code)
Returns the next token in this string tokenizer's string.

Is equivalent to nextToken(delimiters, null).
Parameters:
  nontokenDelims - the new set of non-token delimiters (the set oftoken delimiters will be empty). the next token, after switching to the new delimiter set.
throws:
  NoSuchElementException - if there are no more tokens in thistokenizer's string.
See Also:   StringTokenizer.nextToken(String,String)
since:
   ostermillerutils 1.00.00




peek
public String peek()(Code)
Returns the same value as nextToken() but does not alter the internal state of the Tokenizer. Subsequent calls to peek() or a call to nextToken() will return the same token again. the next token from this string tokenizer.
throws:
  NoSuchElementException - if there are no more tokens in this tokenizer's string.
since:
   ostermillerutils 1.00.00



remove
public void remove()(Code)
This implementation always throws UnsupportedOperationException. It exists so that this class can implement the Iterator interface.
throws:
  UnsupportedOperationException - always is thrown.
See Also:   java.util.Iterator
since:
   ostermillerutils 1.00.00



restOfText
public String restOfText()(Code)
Retrieves the rest of the text as a single token. After calling this method hasMoreTokens() will always return false. any part of the text that has not yet been tokenized.
since:
   ostermillerutils 1.00.00



setDelimiters
public void setDelimiters(String delims)(Code)
Set the delimiters used to this set of (non-token) delimiters.
Parameters:
  delims - the new set of non-token delimiters (the set of token delimiters will be empty).
since:
   ostermillerutils 1.00.00



setDelimiters
public void setDelimiters(String delims, boolean delimsAreTokens)(Code)
Set the delimiters used to this set of delimiters.
Parameters:
  delims - the new set of delimiters.
Parameters:
  delimsAreTokens - flag indicating whether the first parameter specifiestoken or non-token delimiters: false -- the first parameter specifies non-tokendelimiters, the set of token delimiters is empty; true -- the first parameterspecifies token delimiters, the set of non-token delimiters is empty.
since:
   ostermillerutils 1.00.00



setDelimiters
public void setDelimiters(String nontokenDelims, String tokenDelims)(Code)
Set the delimiters used to this set of delimiters.
Parameters:
  nontokenDelims - the new set of non-token delimiters.
Parameters:
  tokenDelims - the new set of token delimiters.
since:
   ostermillerutils 1.00.00



setDelimiters
public void setDelimiters(String nontokenDelims, String tokenDelims, boolean returnEmptyTokens)(Code)
Set the delimiters used to this set of delimiters.
Parameters:
  nontokenDelims - the new set of non-token delimiters.
Parameters:
  tokenDelims - the new set of token delimiters.
Parameters:
  returnEmptyTokens - true if empty tokens may be returned; false otherwise.
since:
   ostermillerutils 1.00.00



setReturnEmptyTokens
public void setReturnEmptyTokens(boolean returnEmptyTokens)(Code)
Set whether empty tokens should be returned from this point in in the tokenizing process onward.

Empty tokens occur when two delimiters are next to each other or a delimiter occurs at the beginning or end of a string. If empty tokens are set to be returned, and a comma is the non token delimiter, the following table shows how many tokens are in each string.
StringNumber of tokens
"one,two"2 - normal case with no empty tokens.
"one,,three"3 including the empty token in the middle.
"one,"2 including the empty token at the end.
",two"2 including the empty token at the beginning.
","2 including the empty tokens at the beginning and the ends.
""1 - all strings will have at least one token if empty tokens are returned.

Parameters:
  returnEmptyTokens - true iff empty tokens should be returned.
since:
   ostermillerutils 1.00.00




setText
public void setText(String text)(Code)
Set the text to be tokenized in this StringTokenizer.

This is useful when for StringTokenizer re-use so that new string tokenizers do not have to be created for each string you want to tokenizer.

The string will be tokenized from the beginning of the string.
Parameters:
  text - a string to be parsed.
throws:
  NullPointerException - if text is null.
since:
   ostermillerutils 1.00.00




skipDelimiters
public boolean skipDelimiters()(Code)
Advances the current position so it is before the next token.

This method skips non-token delimiters but does not skip token delimiters.

This method is useful when switching to the new delimiter sets (see the second example in the class comment.) true if there are more tokens, false otherwise.
since:
   ostermillerutils 1.00.00




toArray
public String[] toArray()(Code)
Retrieve all of the remaining tokens in a String array. This method uses the options that are currently set for the tokenizer and will advance the state of the tokenizer such that hasMoreTokens() will return false. an array of tokens from this tokenizer.
since:
   ostermillerutils 1.00.00



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.