Class JlsTokenizer
- java.lang.Object
-
- org.hortonmachine.gears.io.grasslegacy.utils.JlsTokenizer
-
public class JlsTokenizer extends Object
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcountTokens()Calculates the number of times that this tokenizer'snextTokenmethod can be called before it generates an exception.booleanhasMoreElements()Returns the same value as thehasMoreTokensmethod.booleanhasMoreTokens()Tests if there are more tokens available from this tokenizer's string.ObjectnextElement()Returns the same value as thenextTokenmethod, except that its declared return value isObjectrather thanString.StringnextToken()Returns the next token from this string tokenizer.StringremainingToken()Returns the rest of the string.
-
-
-
Constructor Detail
-
JlsTokenizer
public JlsTokenizer(String str)
Constructs a string tokenizer for the specified string. The tokenizer uses the default delimiter set, which is" \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.- Parameters:
str- a string to be parsed.
-
JlsTokenizer
public JlsTokenizer(String str, String delim)
Constructs a string tokenizer for the specified string. The characters in thedelimargument are the delimiters for separating tokens. Delimiter characters themselves will not be treated as tokens.- Parameters:
str- a string to be parsed.delim- the delimiters.
-
-
Method Detail
-
hasMoreTokens
public boolean hasMoreTokens()
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.- Returns:
trueif and only if there is at least one token in the string after the current position;falseotherwise.
-
nextToken
public String nextToken()
Returns the next token from this string tokenizer.- Returns:
- the next token from this string tokenizer.
- Throws:
NoSuchElementException- if there are no more tokens in this tokenizer's string.
-
remainingToken
public String remainingToken()
Returns the rest of the string.- Returns:
- the rest of the string.
- Throws:
NoSuchElementException- if there are no more tokens in this tokenizer's string.
-
hasMoreElements
public boolean hasMoreElements()
Returns the same value as thehasMoreTokensmethod. It exists so that this class can implement theEnumerationinterface.- Returns:
trueif there are more tokens;falseotherwise.
-
nextElement
public Object nextElement()
Returns the same value as thenextTokenmethod, except that its declared return value isObjectrather thanString. It exists so that this class can implement theEnumerationinterface.- Returns:
- the next token in the string.
- Throws:
NoSuchElementException- if there are no more tokens in this tokenizer's string.
-
countTokens
public int countTokens()
Calculates the number of times that this tokenizer'snextTokenmethod can be called before it generates an exception. The current position is not advanced.- Returns:
- the number of tokens remaining in the string using the current delimiter set.
- See Also:
uk.org.skeet.util.JlsTokenizer#nextToken()
-
-