equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1994, 2004, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
187 * |
187 * |
188 * @param str a string to be parsed. |
188 * @param str a string to be parsed. |
189 * @param delim the delimiters. |
189 * @param delim the delimiters. |
190 * @param returnDelims flag indicating whether to return the delimiters |
190 * @param returnDelims flag indicating whether to return the delimiters |
191 * as tokens. |
191 * as tokens. |
192 * @exception NullPointerException if str is {@code null} |
192 * @throws NullPointerException if str is {@code null} |
193 */ |
193 */ |
194 public StringTokenizer(String str, String delim, boolean returnDelims) { |
194 public StringTokenizer(String str, String delim, boolean returnDelims) { |
195 currentPosition = 0; |
195 currentPosition = 0; |
196 newPosition = -1; |
196 newPosition = -1; |
197 delimsChanged = false; |
197 delimsChanged = false; |
213 * resulting {@code StringTokenizer} may result in a |
213 * resulting {@code StringTokenizer} may result in a |
214 * {@code NullPointerException}. |
214 * {@code NullPointerException}. |
215 * |
215 * |
216 * @param str a string to be parsed. |
216 * @param str a string to be parsed. |
217 * @param delim the delimiters. |
217 * @param delim the delimiters. |
218 * @exception NullPointerException if str is {@code null} |
218 * @throws NullPointerException if str is {@code null} |
219 */ |
219 */ |
220 public StringTokenizer(String str, String delim) { |
220 public StringTokenizer(String str, String delim) { |
221 this(str, delim, false); |
221 this(str, delim, false); |
222 } |
222 } |
223 |
223 |
228 * the tab character, the newline character, the carriage-return character, |
228 * the tab character, the newline character, the carriage-return character, |
229 * and the form-feed character. Delimiter characters themselves will |
229 * and the form-feed character. Delimiter characters themselves will |
230 * not be treated as tokens. |
230 * not be treated as tokens. |
231 * |
231 * |
232 * @param str a string to be parsed. |
232 * @param str a string to be parsed. |
233 * @exception NullPointerException if str is {@code null} |
233 * @throws NullPointerException if str is {@code null} |
234 */ |
234 */ |
235 public StringTokenizer(String str) { |
235 public StringTokenizer(String str) { |
236 this(str, " \t\n\r\f", false); |
236 this(str, " \t\n\r\f", false); |
237 } |
237 } |
238 |
238 |
326 |
326 |
327 /** |
327 /** |
328 * Returns the next token from this string tokenizer. |
328 * Returns the next token from this string tokenizer. |
329 * |
329 * |
330 * @return the next token from this string tokenizer. |
330 * @return the next token from this string tokenizer. |
331 * @exception NoSuchElementException if there are no more tokens in this |
331 * @throws NoSuchElementException if there are no more tokens in this |
332 * tokenizer's string. |
332 * tokenizer's string. |
333 */ |
333 */ |
334 public String nextToken() { |
334 public String nextToken() { |
335 /* |
335 /* |
336 * If next position already computed in hasMoreElements() and |
336 * If next position already computed in hasMoreElements() and |
361 * advanced beyond the recognized token. The new delimiter set |
361 * advanced beyond the recognized token. The new delimiter set |
362 * remains the default after this call. |
362 * remains the default after this call. |
363 * |
363 * |
364 * @param delim the new delimiters. |
364 * @param delim the new delimiters. |
365 * @return the next token, after switching to the new delimiter set. |
365 * @return the next token, after switching to the new delimiter set. |
366 * @exception NoSuchElementException if there are no more tokens in this |
366 * @throws NoSuchElementException if there are no more tokens in this |
367 * tokenizer's string. |
367 * tokenizer's string. |
368 * @exception NullPointerException if delim is {@code null} |
368 * @throws NullPointerException if delim is {@code null} |
369 */ |
369 */ |
370 public String nextToken(String delim) { |
370 public String nextToken(String delim) { |
371 delimiters = delim; |
371 delimiters = delim; |
372 |
372 |
373 /* delimiter string specified, so set the appropriate flag. */ |
373 /* delimiter string specified, so set the appropriate flag. */ |
396 * except that its declared return value is {@code Object} rather than |
396 * except that its declared return value is {@code Object} rather than |
397 * {@code String}. It exists so that this class can implement the |
397 * {@code String}. It exists so that this class can implement the |
398 * {@code Enumeration} interface. |
398 * {@code Enumeration} interface. |
399 * |
399 * |
400 * @return the next token in the string. |
400 * @return the next token in the string. |
401 * @exception NoSuchElementException if there are no more tokens in this |
401 * @throws NoSuchElementException if there are no more tokens in this |
402 * tokenizer's string. |
402 * tokenizer's string. |
403 * @see java.util.Enumeration |
403 * @see java.util.Enumeration |
404 * @see java.util.StringTokenizer#nextToken() |
404 * @see java.util.StringTokenizer#nextToken() |
405 */ |
405 */ |
406 public Object nextElement() { |
406 public Object nextElement() { |