git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137724 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2003-12-15 01:17:49 +00:00
parent e8058a5417
commit 23aba54dfb
1 changed files with 31 additions and 6 deletions

View File

@ -92,6 +92,7 @@
* *
* @author Matthew Inger * @author Matthew Inger
* @author Stephen Colebourne * @author Stephen Colebourne
* @author Gary D. Gregory
*/ */
public class Tokenizer implements ListIterator { public class Tokenizer implements ListIterator {
// TODO: Constructors // TODO: Constructors
@ -712,7 +713,7 @@ public void setIgnoredMatcher(Matcher ignored) {
* This character is ignored when parsing the String, unless it is * This character is ignored when parsing the String, unless it is
* within a quoted region. * within a quoted region.
* *
* @param quote the ignored character to use * @param ignored the ignored character to use
*/ */
public void setIgnoredChar(char ignored) { public void setIgnoredChar(char ignored) {
setIgnoredMatcher(new CharMatcher(ignored)); setIgnoredMatcher(new CharMatcher(ignored));
@ -733,7 +734,7 @@ public boolean isEmptyTokenAsNull() {
* Sets whether the tokenizer should return empty tokens as null. * Sets whether the tokenizer should return empty tokens as null.
* The default for this property is false. * The default for this property is false.
* *
* @return emptyAsNull whether empty tokens are returned as null * @param emptyAsNull whether empty tokens are returned as null
*/ */
public void setEmptyTokenAsNull(boolean emptyAsNull) { public void setEmptyTokenAsNull(boolean emptyAsNull) {
this.emptyAsNull = emptyAsNull; this.emptyAsNull = emptyAsNull;
@ -754,7 +755,7 @@ public boolean isIgnoreEmptyTokens() {
* Sets whether the tokenizer should ignore and not return empty tokens. * Sets whether the tokenizer should ignore and not return empty tokens.
* The default for this property is false. * The default for this property is false.
* *
* @return ignoreEmptyTokens whether empty tokens are not returned * @param ignoreEmptyTokens whether empty tokens are not returned
*/ */
public void setIgnoreEmptyTokens(boolean ignoreEmptyTokens) { public void setIgnoreEmptyTokens(boolean ignoreEmptyTokens) {
this.ignoreEmptyTokens = ignoreEmptyTokens; this.ignoreEmptyTokens = ignoreEmptyTokens;
@ -810,8 +811,14 @@ public char[] getChars() {
return (char[]) chars.clone(); return (char[]) chars.clone();
} }
public boolean isMatch(char c) { /**
return (Arrays.binarySearch(chars, c) >= 0); * Returns whether or not the given charatcer matches.
*
* @param ch the character to match.
* @return whether or not the given charatcer matches.
*/
public boolean isMatch(char ch) {
return (Arrays.binarySearch(chars, ch) >= 0);
} }
} }
@ -825,7 +832,7 @@ public static final class CharMatcher implements Matcher {
/** /**
* Constructor that creates a matcher that matches a single character. * Constructor that creates a matcher that matches a single character.
* *
* @param chars the character to match * @param ch the character to match
*/ */
public CharMatcher(char ch) { public CharMatcher(char ch) {
super(); super();
@ -841,6 +848,12 @@ public char getChar() {
return this.ch; return this.ch;
} }
/**
* Returns whether or not the given charatcer matches.
*
* @param ch the character to match.
* @return whether or not the given charatcer matches.
*/
public boolean isMatch(char ch) { public boolean isMatch(char ch) {
return (this.ch == ch); return (this.ch == ch);
} }
@ -856,6 +869,12 @@ static final class NoMatcher implements Matcher {
super(); super();
} }
/**
* Always returns <code>false</code>.
*
* @param ch the character to match.
* @return Always returns <code>false</code>.
*/
public boolean isMatch(char ch) { public boolean isMatch(char ch) {
return false; return false;
} }
@ -871,6 +890,12 @@ static final class TrimMatcher implements Matcher {
super(); super();
} }
/**
* Returns whether or not the given charatcer matches.
*
* @param ch the character to match.
* @return whether or not the given charatcer matches.
*/
public boolean isMatch(char ch) { public boolean isMatch(char ch) {
return (ch <= 32); return (ch <= 32);
} }