public class JlsTokenizer extends Object
x,,yyields a blank token between x and y, whereas with StringTokenizer it is swallowed.
,a,yields a blank token both before and after a, whereas with StringTokenizer both are swallowed.
This class is deliberately not a subclass of StringTokenizer as the behaviour is significantly different. It can, however, be used in many places where StringTokenizer is appropriate.
Constructor and Description |
---|
JlsTokenizer(String str)
Constructs a string tokenizer for the specified string.
|
JlsTokenizer(String str,
String delim)
Constructs a string tokenizer for the specified string.
|
Modifier and Type | Method and Description |
---|---|
int |
countTokens()
Calculates the number of times that this tokenizer's
nextToken method can be
called before it generates an exception. |
boolean |
hasMoreElements()
Returns the same value as the
hasMoreTokens method. |
boolean |
hasMoreTokens()
Tests if there are more tokens available from this tokenizer's string.
|
Object |
nextElement()
Returns the same value as the
nextToken method, except that its declared return
value is Object rather than String . |
String |
nextToken()
Returns the next token from this string tokenizer.
|
String |
remainingToken()
Returns the rest of the string.
|
public JlsTokenizer(String str)
" \t\n\r\f"
: the space character,
the tab character, the newline character, the carriage-return character, and the form-feed
character. Delimiter characters themselves will not be treated as tokens.str
- a string to be parsed.public JlsTokenizer(String str, String delim)
delim
argument are the delimiters for separating tokens. Delimiter characters themselves
will not be treated as tokens.str
- a string to be parsed.delim
- the delimiters.public boolean hasMoreTokens()
true
if and only if there is at least one token in the string after the
current position; false
otherwise.public String nextToken()
NoSuchElementException
- if there are no more tokens in this tokenizer's string.public String remainingToken()
NoSuchElementException
- if there are no more tokens in this tokenizer's string.public boolean hasMoreElements()
hasMoreTokens
method. It exists so that this class
can implement the Enumeration
interface.true
if there are more tokens; false
otherwise.public Object nextElement()
nextToken
method, except that its declared return
value is Object
rather than String
. It exists so that this class
can implement the Enumeration
interface.NoSuchElementException
- if there are no more tokens in this tokenizer's string.public int countTokens()
nextToken
method can be
called before it generates an exception. The current position is not advanced.uk.org.skeet.util.JlsTokenizer#nextToken()
Copyright © 1996–2023 Geotools. All rights reserved.