Remove cloning from char array methods

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137914 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2004-09-02 07:52:35 +00:00
parent fdfba0f580
commit 031b68ed6a

View File

@ -70,7 +70,7 @@
* @author Stephen Colebourne * @author Stephen Colebourne
* @author Gary D. Gregory * @author Gary D. Gregory
* @since 2.1 * @since 2.1
* @version $Id: Tokenizer.java,v 1.9 2004/08/28 11:46:19 scolebourne Exp $ * @version $Id: Tokenizer.java,v 1.10 2004/09/02 07:52:35 scolebourne Exp $
*/ */
public class Tokenizer implements ListIterator, Cloneable { public class Tokenizer implements ListIterator, Cloneable {
@ -229,8 +229,7 @@ public Tokenizer(String input) {
} }
/** /**
* Constructs a tokenizer splitting on space, tab, newline and formfeed * Constructs a tokenizer splitting on the specified delimiter character.
* as per StringTokenizer.
* *
* @param input the string which is to be parsed * @param input the string which is to be parsed
* @param delim the field delimiter character * @param delim the field delimiter character
@ -280,20 +279,27 @@ public Tokenizer(String input, Matcher delim, Matcher quote) {
/** /**
* Constructs a tokenizer splitting on space, tab, newline and formfeed * Constructs a tokenizer splitting on space, tab, newline and formfeed
* as per StringTokenizer. * as per StringTokenizer.
* <p>
* This method is designed for use when you are using a character array in
* your own code. The input is not cloned, so using the tokenizer in this way
* is not thread-safe.
* *
* @param input the string which is to be parsed, cloned * @param input the string which is to be parsed
*/ */
public Tokenizer(char[] input) { public Tokenizer(char[] input) {
super(); super();
this.text = null; this.text = null;
this.chars = (char[]) input.clone(); this.chars = input;
} }
/** /**
* Constructs a tokenizer splitting on space, tab, newline and formfeed * Constructs a tokenizer splitting on the specified delimiter character.
* as per StringTokenizer. * <p>
* This method is designed for use when you are using a character array in
* your own code. The input is not cloned, so using the tokenizer in this way
* is not thread-safe.
* *
* @param input the string which is to be parsed, cloned * @param input the string which is to be parsed
* @param delim the field delimiter character * @param delim the field delimiter character
*/ */
public Tokenizer(char[] input, char delim) { public Tokenizer(char[] input, char delim) {
@ -303,8 +309,12 @@ public Tokenizer(char[] input, char delim) {
/** /**
* Constructs a tokenizer splitting using the specified delimiter matcher. * Constructs a tokenizer splitting using the specified delimiter matcher.
* <p>
* This method is designed for use when you are using a character array in
* your own code. The input is not cloned, so using the tokenizer in this way
* is not thread-safe.
* *
* @param input the string which is to be parsed, cloned * @param input the string which is to be parsed
* @param delim the field delimiter matcher * @param delim the field delimiter matcher
*/ */
public Tokenizer(char[] input, Matcher delim) { public Tokenizer(char[] input, Matcher delim) {
@ -315,8 +325,12 @@ public Tokenizer(char[] input, Matcher delim) {
/** /**
* Constructs a tokenizer splitting on the specified delimiter character * Constructs a tokenizer splitting on the specified delimiter character
* and handling quotes using the specified quote character. * and handling quotes using the specified quote character.
* <p>
* This method is designed for use when you are using a character array in
* your own code. The input is not cloned, so using the tokenizer in this way
* is not thread-safe.
* *
* @param input the string which is to be parsed, cloned * @param input the string which is to be parsed
* @param delim the field delimiter character * @param delim the field delimiter character
* @param quote the field quoted string character * @param quote the field quoted string character
*/ */
@ -329,7 +343,7 @@ public Tokenizer(char[] input, char delim, char quote) {
* Constructs a tokenizer splitting using the specified delimiter matcher * Constructs a tokenizer splitting using the specified delimiter matcher
* and handling quotes using the specified quote matcher. * and handling quotes using the specified quote matcher.
* *
* @param input the string which is to be parsed, cloned * @param input the string which is to be parsed
* @param delim the field delimiter character * @param delim the field delimiter character
* @param quote the field quoted string character * @param quote the field quoted string character
*/ */
@ -413,13 +427,17 @@ public void reset(String input) {
* Reset this tokenizer, giving it a new input string to parse. * Reset this tokenizer, giving it a new input string to parse.
* In this manner you can re-use a tokenizer with the same settings * In this manner you can re-use a tokenizer with the same settings
* on multiple input lines. * on multiple input lines.
* <p>
* This method is designed for use when you are using a character array in
* your own code. The input is not cloned, so using the tokenizer in this way
* is not thread-safe.
* *
* @param input the new character array to tokenize, cloned * @param input the new character array to tokenize, cloned
*/ */
public void reset(char [] input) { public void reset(char [] input) {
reset(); reset();
this.text = null; this.text = null;
chars = (char[]) input.clone(); chars = input;
} }
// ListIterator // ListIterator