commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r160943 - in jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text: Interpolation.java MappedMessageFormat.java StrBuilder.java StrTokenizer.java
Date Mon, 11 Apr 2005 20:11:42 GMT
Author: ggregory
Date: Mon Apr 11 13:11:40 2005
New Revision: 160943

URL: http://svn.apache.org/viewcvs?view=rev&rev=160943
Log:
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.

Modified:
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/Interpolation.java
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/MappedMessageFormat.java
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrBuilder.java
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/Interpolation.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/Interpolation.java?view=diff&r1=160942&r2=160943
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/Interpolation.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/Interpolation.java
Mon Apr 11 13:11:40 2005
@@ -33,7 +33,7 @@
     }
 
     /**
-     * <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 @@
     }
 
     /**
-     * <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

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/MappedMessageFormat.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/MappedMessageFormat.java?view=diff&r1=160942&r2=160943
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/MappedMessageFormat.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/MappedMessageFormat.java
Mon Apr 11 13:11:40 2005
@@ -52,6 +52,7 @@
      * Constructs a new instance.
      */
     public MappedMessageFormat() {
+        // no initialization.
     }
     
     /**

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrBuilder.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrBuilder.java?view=diff&r1=160942&r2=160943
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrBuilder.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrBuilder.java
Mon Apr 11 13:11:40 2005
@@ -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(int initialCapacity) {
         super();
         if (initialCapacity <= 0) {
-            initialCapacity = 32;
+            initialCapacity = CAPACITY;
         }
         buf = new char[initialCapacity];
     }
@@ -209,7 +214,7 @@
     /**
      * 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 @@
      * <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 @@
     /**
      * 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 @@
     /**
      * 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 @@
     /**
      * 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 @@
      * @return true if the builder contains the string
      */
     public boolean contains(String str) {
-        return (indexOf(str, 0) >= 0);
+        return indexOf(str, 0) >= 0;
     }
 
     //-----------------------------------------------------------------------

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java?view=diff&r1=160942&r2=160943
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java
Mon Apr 11 13:11:40 2005
@@ -167,6 +167,7 @@
      * 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 @@
      * 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 @@
      * 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 @@
      * 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 @@
      * 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 @@
      * 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 @@
      * 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 @@
      * (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 @@
      * 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 @@
      * 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 boolean hasNext() {
         tokenize();
-        return (tokenPos < tokens.length);
+        return tokenPos < tokens.length;
     }
 
     /**
@@ -570,7 +580,7 @@
      */
     public boolean hasPrevious() {
         tokenize();
-        return (tokenPos > 0);
+        return tokenPos > 0;
     }
 
     /**
@@ -588,7 +598,7 @@
      * @return the previous token index
      */
     public int previousIndex() {
-        return (tokenPos - 1);
+        return tokenPos - 1;
     }
 
     /**
@@ -602,7 +612,7 @@
 
     /**
      * Unsupported ListIterator operation.
-     *
+     * @param obj this parameter ignored.
      * @throws UnsupportedOperationException always
      */
     public void set(Object obj) {
@@ -611,7 +621,7 @@
 
     /**
      * Unsupported ListIterator operation.
-     *
+     * @param obj this parameter ignored.
      * @throws UnsupportedOperationException always
      */
     public void add(Object obj) {
@@ -1073,8 +1083,9 @@
 
     //-----------------------------------------------------------------------
     /**
-     * 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 @@
          * @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 @@
          * @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 @@
          * @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;
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message