<%bte.doc super="item.bte" %>
<%bte.tpl name=pageTitle%>String Tokenizer<%/bte.tpl%>
<%bte.tpl name=description%>A StringTokenizer replacement with enhancements.<%/bte.tpl%>
<%bte.tpl name=keywords%>stringtokenizer, string tokenizer, replacement stringtokenizer, java stringtokenizer<%/bte.tpl%>
<%bte.tpl name=content%>
<P>A drop in replacement for the java.util.StringTokenizer class.  Because Sun is introducing a regular expression package in the Merlin release of java, StringTokenizer has become a legacy class and they have stopped making enhancements to it.  This implementation of StringTokenizer tries to fix the following bugs:<ul>
    <li><b><a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4086845">Bug 4086845</a>, <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4140850">Bug 4140850</a>, <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4233089">Bug 4233089</a>, <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4287338">Bug 4287338</a> Report empty/null tokens</b> - It would be nice to have the string "one,two,,four" have four tokens.  This implementation has the option to return empty tokens as an empty string ("").</li>
    <li><b><a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4232593">Bug 4232593</a> Performance improvements</b> - StringTokenizer can be optimized for some common cases.  The optimizations that were implemented in java.util.StringTokenizer involving maximum characters from this suggestion have also been implemented here.  Also token count is cached between calls.</li>
    <li><b><a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4232770">Bug 4232770</a> Null parameter handling not specified</b> - The string to parse should not be null, but the delimiter lists may be null in this implementation.</li>
    <li><b><a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4229450">Bug 4229450</a> Add a String[] toArray method</b> - Convenience method added for returning all the tokens as an array of Strings.</li>
    <li><b><a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4391919">Bug 4391919</a> getPosition() method</b> - Exposes the internal state of the StringTokenizer.  In addition, other internal state variables are protected and well documented so this class can be easily sub-classed.</li>
    <li><b><a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4228047">Bug 4228047</a> Allow re-use to minimize heap activity</b> - A setText() method was added for this purpose.</li>
    <li><b><a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4238266">Bug 4238266</a>, <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4080058">Bug 4080058</a>, <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4280213">Bug 4280213</a>, <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4310962">Bug 4310962</a>, <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4338282">Bug 4338282</a>, <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4377004">Bug 4377004</a>, <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4359719">Bug 4359719</a> Fixed hasMoreElements() side-effect (no easy way to deal with code broken by this fix)</b> - hasMoreElements() had an unexpected side-effect.  Some people relied on this and the fix broke their code.  In the fixed version there was no good way to recover the functionality of the broken code.  Methods are introduced here to correct that (API taken from <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4359719">Bug 4359719</a>).</li>
    <li><b><a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4359719">Bug 4359719</a> token delimiters and nontoken delimiters</b> - Some delimiters may be returned as tokens and at the same time, other should not be returned.  This bug report contains code with a nice API that I have used for this implementation.</li>
    <li><b><a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4215241">Bug 4215241</a> restOfText() method</b> - Return the remaining un-tokenized portion of the string.</li>
    <li><b>Change delimiters without returning token</b> - Contains methods for changing the delimiters midstream while getting a token, counting tokens, or not associated with another action.</li>
    <li><b>Peek at the next token</b> - A peek() method is available for looking ahead at the next token.  (Inspired by <a href="http://www.gjt.org/servlets/JCVSlet/log/gjt/com/tinyplanet/docwiz/PeekStringTokenizer.java/0">com.tinyplanet.docwiz.PeekStringTokenizer</a>)</li>

</ul></p>

<p>[<a href="download.html">Download /w Source</a> |
<a href="http://www.gjt.org/servlets/JCVSlet/log/gjt/com/Ostermiller/util/StringTokenizer.java/0">Version History</a> | <a href="StringTokenizer.java.html">Browse Source</a> |
<a href="doc/com/Ostermiller/util/StringTokenizer.html">Documentation</a>]</p>

<%/bte.tpl%>
<%/bte.doc%>
