/** * Test if there are more tokens which can be returned. */ public boolean hasMoreTokens() { if (lookahead == null) lookahead = getNextToken(); return lookahead != null; }
/** * Test if there are more tokens which can be returned. */ public boolean hasMoreTokens() { if (lookahead == null) lookahead = getNextToken(); return lookahead != null; }
/** * Return the next token. * @throws java.util.NoSuchElementException if there are no more tokens available */ public String nextToken() { String result = null; if (lookahead != null) { result = lookahead; lookahead = null; } else { result = getNextToken(); } if (result == null) { throw new NoSuchElementException("No more elements in tokenized string"); } if (!returnDelims) { if (result.length() == 1) { char c = result.charAt(0); if (delim.indexOf(c) != -1 || literalDelim.indexOf(c) != -1) { return nextToken(); } } } return result; }
/** * Return the next token. * @throws java.util.NoSuchElementException if there are no more tokens available */ public String nextToken() { String result = null; if (lookahead != null) { result = lookahead; lookahead = null; } else { result = getNextToken(); } if (result == null) { throw new NoSuchElementException("No more elements in tokenized string"); } if (!returnDelims) { if (result.length() == 1) { char c = result.charAt(0); if (delim.indexOf(c) != -1 || literalDelim.indexOf(c) != -1) { return nextToken(); } } } return result; }