In the .text package (not for 2.1):

- Javadoc nits: missing tags, wrong name in @param, "." in 1st line.
- Refactored magic number "32" into static final "CAPACITY".
- Removed extra C-style "return (expr)" in return expressions.


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@160943 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2005-04-11 20:11:40 +00:00
parent fdaa1eb25a
commit 887d935024
4 changed files with 37 additions and 20 deletions

View File

@ -33,7 +33,7 @@ public Interpolation() {
}
/**
* <p>Interpolates a String to replace variables of the form <code>${...}</code>.</p>
* <p>Interpolates a String to replace variables of the form <code>${variable}</code>.</p>
*
* <p>This method is useful for enabling simple strings to be modified based
* on a map of data. A typical use case might be to add data from configuration
@ -110,7 +110,7 @@ public static String interpolate(String templateString, Map valuesMap) {
}
/**
* <p>Interpolates a String to replace variables of the form <code>${...}</code>
* <p>Interpolates a String to replace variables of the form <code>${variable}</code>
* where the replace strings may also contain variables to interpolate.</p>
*
* <p>This method is useful for enabling simple strings to be modified based

View File

@ -52,6 +52,7 @@ public class MappedMessageFormat {
* Constructs a new instance.
*/
public MappedMessageFormat() {
// no initialization.
}
/**

View File

@ -54,6 +54,11 @@
*/
public class StrBuilder implements Cloneable {
/**
* The extra capacity for new builders.
*/
static final int CAPACITY = 32;
/** Serialization lock. */
private static final long serialVersionUID = 7628716375283629643L;
@ -80,7 +85,7 @@ public StrBuilder() {
public StrBuilder(int initialCapacity) {
super();
if (initialCapacity <= 0) {
initialCapacity = 32;
initialCapacity = CAPACITY;
}
buf = new char[initialCapacity];
}
@ -209,7 +214,7 @@ public int size() {
/**
* Clears the string builder (convenience Collections API style method).
* <p>
* This method is the same as {@link #setLength(0)} and is provided to match the
* This method is the same as {@link #setLength(int)} and is provided to match the
* API of Collections.
*/
public void clear() {
@ -221,9 +226,10 @@ public void clear() {
* <p>
* This method is the same as checking {@link #length()} and is provided to match the
* API of Collections.
* @return <code>true</code> if the size is <code>0</code>.
*/
public boolean isEmpty() {
return (size == 0);
return size == 0;
}
//-----------------------------------------------------------------------
@ -324,7 +330,6 @@ public void getChars(int startIndex, int endIndex, char destination[], int desti
/**
* Appends the text representing <code>null</code> to the string builder.
*
* @param obj the object to append
* @return this, to enable chaining
*/
public StrBuilder appendNull() {
@ -491,7 +496,7 @@ public StrBuilder append(boolean value) {
/**
* Appends a char value to the string builder.
*
* @param value the value to append
* @param ch the value to append
* @return this, to enable chaining
*/
public StrBuilder append(char ch) {
@ -1090,7 +1095,7 @@ public boolean endsWith(String str) {
/**
* Extracts a portion of this string builder as a string.
*
* @param startIndex the start index, inclusive, must be valid
* @param start the start index, inclusive, must be valid
* @return the new string
* @throws StringIndexOutOfBoundsException if the index is invalid
*/
@ -1214,7 +1219,7 @@ public boolean contains(char ch) {
* @return true if the builder contains the string
*/
public boolean contains(String str) {
return (indexOf(str, 0) >= 0);
return indexOf(str, 0) >= 0;
}
//-----------------------------------------------------------------------

View File

@ -167,6 +167,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
* Constructor that creates a matcher from a set of characters.
*
* @param chars the characters to match, must not be null
* @return A new matcher for the given char[].
* @throws IllegalArgumentException if the character set is null or empty
*/
public static Matcher createCharSetMatcher(char[] chars) {
@ -183,6 +184,7 @@ public static Matcher createCharSetMatcher(char[] chars) {
* Constructor that creates a matcher from a string representing a set of characters.
*
* @param chars the characters to match, must not be null
* @return A new Matcher for the given characters.
* @throws IllegalArgumentException if the character set is null or empty
*/
public static Matcher createCharSetMatcher(String chars) {
@ -199,6 +201,7 @@ public static Matcher createCharSetMatcher(String chars) {
* Constructor that creates a matcher from a character.
*
* @param ch the character to match, must not be null
* @return A new Matcher for the given char.
*/
public static Matcher createCharMatcher(char ch) {
return new CharMatcher(ch);
@ -208,6 +211,7 @@ public static Matcher createCharMatcher(char ch) {
* Constructor that creates a matcher from a string.
*
* @param str the string to match, must not be null
* @return A new Matcher for the given String.
* @throws IllegalArgumentException if the string is null or empty
*/
public static Matcher createStringMatcher(String str) {
@ -226,9 +230,10 @@ public static Matcher createStringMatcher(String str) {
* the setTrimmer method).
* <p>
* You must call a "reset" method to set the string which you want to parse.
* @return a new tokenizer instance which parses Comma Seperated Value strings
*/
public static StrTokenizer getCSVInstance() {
return (StrTokenizer)(CSV_TOKENIZER_PROTOTYPE.clone());
return (StrTokenizer)CSV_TOKENIZER_PROTOTYPE.clone();
}
/**
@ -238,6 +243,7 @@ public static StrTokenizer getCSVInstance() {
* the setTrimmer method).
*
* @param input the text to parse
* @return a new tokenizer instance which parses Comma Seperated Value strings
*/
public static StrTokenizer getCSVInstance(String input) {
StrTokenizer tok = (StrTokenizer)(CSV_TOKENIZER_PROTOTYPE.clone());
@ -252,6 +258,7 @@ public static StrTokenizer getCSVInstance(String input) {
* the setTrimmer method).
*
* @param input the text to parse
* @return a new tokenizer instance which parses Comma Seperated Value strings
*/
public static StrTokenizer getCSVInstance(char[] input) {
StrTokenizer tok = (StrTokenizer)(CSV_TOKENIZER_PROTOTYPE.clone());
@ -265,9 +272,10 @@ public static StrTokenizer getCSVInstance(char[] input) {
* (which can be overriden with the setTrimmer method).
* <p>
* You must call a "reset" method to set the string which you want to parse.
* @return a new tokenizer instance which parses Tab Seperated Value strings.
*/
public static StrTokenizer getTSVInstance() {
return (StrTokenizer)(TSV_TOKENIZER_PROTOTYPE.clone());
return (StrTokenizer)TSV_TOKENIZER_PROTOTYPE.clone();
}
/**
@ -275,6 +283,7 @@ public static StrTokenizer getTSVInstance() {
* The default for CSV processing will be trim whitespace from both ends
* (which can be overriden with the setTrimmer method).
* @param input the string to parse
* @return a new tokenizer instance which parses Tab Seperated Value strings.
*/
public static StrTokenizer getTSVInstance(String input) {
StrTokenizer tok = (StrTokenizer)(TSV_TOKENIZER_PROTOTYPE.clone());
@ -287,6 +296,7 @@ public static StrTokenizer getTSVInstance(String input) {
* The default for CSV processing will be trim whitespace from both ends
* (which can be overriden with the setTrimmer method).
* @param input the string to parse
* @return a new tokenizer instance which parses Tab Seperated Value strings.
*/
public static StrTokenizer getTSVInstance(char[] input) {
StrTokenizer tok = (StrTokenizer)(TSV_TOKENIZER_PROTOTYPE.clone());
@ -542,7 +552,7 @@ public void reset(char [] input) {
*/
public boolean hasNext() {
tokenize();
return (tokenPos < tokens.length);
return tokenPos < tokens.length;
}
/**
@ -570,7 +580,7 @@ public int nextIndex() {
*/
public boolean hasPrevious() {
tokenize();
return (tokenPos > 0);
return tokenPos > 0;
}
/**
@ -588,7 +598,7 @@ public Object previous() {
* @return the previous token index
*/
public int previousIndex() {
return (tokenPos - 1);
return tokenPos - 1;
}
/**
@ -602,7 +612,7 @@ public void remove() {
/**
* Unsupported ListIterator operation.
*
* @param obj this parameter ignored.
* @throws UnsupportedOperationException always
*/
public void set(Object obj) {
@ -611,7 +621,7 @@ public void set(Object obj) {
/**
* Unsupported ListIterator operation.
*
* @param obj this parameter ignored.
* @throws UnsupportedOperationException always
*/
public void add(Object obj) {
@ -1073,8 +1083,9 @@ public String getContent() {
//-----------------------------------------------------------------------
/**
* Create a new instance of this Tokenizer.
* Creates a new instance of this Tokenizer.
* The new instance is reset so that it will be at the start of the token list.
* @return a new instance of this Tokenizer which has been reset.
*/
public Object clone() {
try {
@ -1145,7 +1156,7 @@ public CharSetMatcher(char chars[]) {
* @return the number of matching characters, zero for no match
*/
public int isMatch(char[] text, int textLen, int pos) {
return (Arrays.binarySearch(chars, text[pos]) >= 0 ? 1 : 0);
return Arrays.binarySearch(chars, text[pos]) >= 0 ? 1 : 0;
}
}
@ -1175,7 +1186,7 @@ static final class CharMatcher implements Matcher {
* @return the number of matching characters, zero for no match
*/
public int isMatch(char[] text, int textLen, int pos) {
return (ch == text[pos] ? 1 : 0);
return ch == text[pos] ? 1 : 0;
}
}
@ -1260,7 +1271,7 @@ static final class TrimMatcher implements Matcher {
* @return the number of matching characters, zero for no match
*/
public int isMatch(char[] text, int textLen, int pos) {
return (text[pos] <= 32 ? 1 : 0);
return text[pos] <= 32 ? 1 : 0;
}
}