Change constructors to take Matcher, not CharSetMatcher

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137902 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2004-08-28 09:14:21 +00:00
parent 11ed4603c2
commit d3d0778c07

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.6 2004/02/19 21:04:03 fredrik Exp $ * @version $Id: Tokenizer.java,v 1.7 2004/08/28 09:14:21 scolebourne Exp $
*/ */
public class Tokenizer implements ListIterator, Cloneable { public class Tokenizer implements ListIterator, Cloneable {
@ -152,17 +152,16 @@ public class Tokenizer implements ListIterator, Cloneable {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* Get a tokenizer instance which parses Comma Seperated Value * Gets a new tokenizer instance which parses Comma Seperated Value strings.
* strings. You must call a "reset" method to set the string which * You must call a "reset" method to set the string which you want to parse.
* you want to parse.
*/ */
public static final Tokenizer getCSVInstance() { public static final Tokenizer getCSVInstance() {
return (Tokenizer)(CSV_TOKENIZER_PROTOTYPE.clone()); return (Tokenizer)(CSV_TOKENIZER_PROTOTYPE.clone());
} }
/** /**
* Get a tokenizer instance which parses Comma Seperated Value * Gets a new tokenizer instance which parses Comma Seperated Value strings
* strings, initializing it with the given input. * initializing it with the given input.
* *
* @param input the string to parse * @param input the string to parse
*/ */
@ -173,8 +172,8 @@ public static final Tokenizer getCSVInstance(String input) {
} }
/** /**
* Get a tokenizer instance which parses Comma Seperated Value * Gets a new tokenizer instance which parses Comma Seperated Value strings
* strings, initializing it with the given input. * initializing it with the given input.
* *
* @param input the text to parse * @param input the text to parse
*/ */
@ -185,17 +184,16 @@ public static final Tokenizer getCSVInstance(char[] input) {
} }
/** /**
* Get a tokenizer instance which parses Tab Seperated Value * Gets a new tokenizer instance which parses Tab Seperated Value strings.
* strings. You must call a "reset" method to set the string which * You must call a "reset" method to set the string which you want to parse.
* you want to parse.
*/ */
public static final Tokenizer getTSVInstance() { public static final Tokenizer getTSVInstance() {
return (Tokenizer)(TSV_TOKENIZER_PROTOTYPE.clone()); return (Tokenizer)(TSV_TOKENIZER_PROTOTYPE.clone());
} }
/** /**
* Get a tokenizer instance which parses Tab Seperated Value * Gets a new tokenizer instance which parses Tab Seperated Value strings
* strings, initializing it with the given input. * initializing it with the given input.
* *
* @param input the string to parse * @param input the string to parse
*/ */
@ -206,8 +204,8 @@ public static final Tokenizer getTSVInstance(String input) {
} }
/** /**
* Get a tokenizer instance which parses Tab Seperated Value * Gets a new tokenizer instance which parses Tab Seperated Value strings
* strings, initializing it with the given input. * initializing it with the given input.
* *
* @param input the text to parse * @param input the text to parse
*/ */
@ -243,20 +241,19 @@ public Tokenizer(String input, char delim) {
} }
/** /**
* Constructs a tokenizer splitting on space, tab, newline and formfeed * Constructs a tokenizer splitting using the specified delimiter matcher.
* 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 matcher
*/ */
public Tokenizer(String input, CharSetMatcher delim) { public Tokenizer(String input, Matcher delim) {
this(input); this(input);
setDelimiterMatcher(delim); setDelimiterMatcher(delim);
} }
/** /**
* Constructs a tokenizer splitting on space, tab, newline and formfeed * Constructs a tokenizer splitting on the specified delimiter character
* as per StringTokenizer. * and handling quotes using the specified quote character.
* *
* @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
@ -268,14 +265,14 @@ public Tokenizer(String input, char delim, char quote) {
} }
/** /**
* Constructs a tokenizer splitting on space, tab, newline and formfeed * Constructs a tokenizer splitting using the specified delimiter matcher
* as per StringTokenizer. * and handling quotes using the specified quote matcher.
* *
* @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 matcher
* @param quote the field quoted string character * @param quote the field quoted string matcher
*/ */
public Tokenizer(String input, CharSetMatcher delim, CharSetMatcher quote) { public Tokenizer(String input, Matcher delim, Matcher quote) {
this(input, delim); this(input, delim);
setQuoteMatcher(quote); setQuoteMatcher(quote);
} }
@ -305,20 +302,19 @@ public Tokenizer(char[] input, char delim) {
} }
/** /**
* Constructs a tokenizer splitting on space, tab, newline and formfeed * Constructs a tokenizer splitting using the specified delimiter matcher.
* as per StringTokenizer.
* *
* @param input the string which is to be parsed, cloned * @param input the string which is to be parsed, cloned
* @param delim the field delimiter character * @param delim the field delimiter matcher
*/ */
public Tokenizer(char[] input, CharSetMatcher delim) { public Tokenizer(char[] input, Matcher delim) {
this(input); this(input);
setDelimiterMatcher(delim); setDelimiterMatcher(delim);
} }
/** /**
* Constructs a tokenizer splitting on space, tab, newline and formfeed * Constructs a tokenizer splitting on the specified delimiter character
* as per StringTokenizer. * and handling quotes using the specified quote character.
* *
* @param input the string which is to be parsed, cloned * @param input the string which is to be parsed, cloned
* @param delim the field delimiter character * @param delim the field delimiter character
@ -330,14 +326,14 @@ public Tokenizer(char[] input, char delim, char quote) {
} }
/** /**
* Constructs a tokenizer splitting on space, tab, newline and formfeed * Constructs a tokenizer splitting using the specified delimiter matcher
* as per StringTokenizer. * 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, cloned
* @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
*/ */
public Tokenizer(char[] input, CharSetMatcher delim, CharSetMatcher quote) { public Tokenizer(char[] input, Matcher delim, Matcher quote) {
this(input, delim); this(input, delim);
setQuoteMatcher(quote); setQuoteMatcher(quote);
} }
@ -642,7 +638,7 @@ private int readQuoted(int start, char cbuf[], StringBuffer token) {
// Quoting mode can occur several times throughout // Quoting mode can occur several times throughout
// a given string, so must switch between quoting // a given string, so must switch between quoting
// and non-quoting until we encounter a non-quoted // and non-quoting until we encounter a non-quoted
// delimiter, or end of string, which inidicates end // delimiter, or end of string, which indicates end
// of token. // of token.
if (quoting) { if (quoting) {
// If we've found a quote character, see if it's // If we've found a quote character, see if it's