cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2004-12-17 Thread bayard
bayard  2004/12/17 18:48:01

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Bug in javadoc example as described in Bugzilla entry 32198.
  
  PR: 32198
  Submitted by: Ronald Wildenberg
  
  Revision  ChangesPath
  1.137 +2 -2  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.136
  retrieving revision 1.137
  diff -u -r1.136 -r1.137
  --- StringUtils.java  8 Oct 2004 00:11:22 -   1.136
  +++ StringUtils.java  18 Dec 2004 02:48:01 -  1.137
  @@ -3233,7 +3233,7 @@
* StringUtils.chomp(foobar, bar) = foo
* StringUtils.chomp(foobar, baz) = foobar
* StringUtils.chomp(foo, foo)= 
  - * StringUtils.chomp(foo , foo)   = foo
  + * StringUtils.chomp(foo , foo)   = foo 
* StringUtils.chomp( foo, foo)   =  
* StringUtils.chomp(foo, f)  = foo
* StringUtils.chomp(foo, )   = foo
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2004-10-07 Thread scolebourne
scolebourne2004/10/07 17:11:22

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add since tags for 2.1 and fix Javadoc
  
  Revision  ChangesPath
  1.136 +10 -8 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.135
  retrieving revision 1.136
  diff -u -r1.135 -r1.136
  --- StringUtils.java  2 Sep 2004 19:16:18 -   1.135
  +++ StringUtils.java  8 Oct 2004 00:11:22 -   1.136
  @@ -808,7 +808,7 @@
* @param ordinal  the n-th codesearchStr/code to find
* @return the n-th index of the search String,
*  code-1/code (codeINDEX_NOT_FOUND/code) if no match or 
codenull/code string input
  - * @since 2.?.?
  + * @since 2.1
*/
   public static int ordinalIndexOf(String str, String searchStr, int ordinal) {
   if (str == null || searchStr == null || ordinal = 0) {
  @@ -1948,7 +1948,7 @@
*
* pThe separator is not included in the returned String array.
* Adjacent separators are treated as one separator.
  - * For more control over the split use the Tokenizer class./p
  + * For more control over the split use the StrTokenizer class./p
*
* pA codenull/code input String returns codenull/code./p
*
  @@ -1973,7 +1973,7 @@
*
* pThe separator is not included in the returned String array.
* Adjacent separators are treated as one separator.
  - * For more control over the split use the Tokenizer class./p
  + * For more control over the split use the StrTokenizer class./p
*
* pA codenull/code input String returns codenull/code./p
*
  @@ -2003,7 +2003,7 @@
*
* pThe separator is not included in the returned String array.
* Adjacent separators are treated as one separator.
  - * For more control over the split use the Tokenizer class./p
  + * For more control over the split use the StrTokenizer class./p
*
* pA codenull/code input String returns codenull/code.
* A codenull/code separatorChars splits on whitespace./p
  @@ -2182,7 +2182,7 @@
*
* pThe separator is not included in the returned String array.
* Adjacent separators are treated as separators for empty tokens.
  - * For more control over the split use the Tokenizer class./p
  + * For more control over the split use the StrTokenizer class./p
*
* pA codenull/code input String returns codenull/code./p
*
  @@ -2209,7 +2209,7 @@
*
* pThe separator is not included in the returned String array.
* Adjacent separators are treated as separators for empty tokens.
  - * For more control over the split use the Tokenizer class./p
  + * For more control over the split use the StrTokenizer class./p
*
* pA codenull/code input String returns codenull/code./p
*
  @@ -2292,7 +2292,7 @@
*
* pThe separator is not included in the returned String array.
* Adjacent separators are treated as separators for empty tokens.
  - * For more control over the split use the Tokenizer class./p
  + * For more control over the split use the StrTokenizer class./p
*
* pA codenull/code input String returns codenull/code.
* A codenull/code separatorChars splits on whitespace./p
  @@ -2316,6 +2316,7 @@
* @param separatorChars  the characters used as the delimiters,
*  codenull/code splits on whitespace
* @return an array of parsed Strings, codenull/code if null String input
  + * @since 2.1
*/
   public static String[] splitPreserveAllTokens(String str, String 
separatorChars) {
   return splitWorker(str, separatorChars, -1, true);
  @@ -2355,6 +2356,7 @@
* @param max  the maximum number of elements to include in the
*  array. A zero or negative value implies no limit
* @return an array of parsed Strings, codenull/code if null String input
  + * @since 2.1
*/
   public static String[] splitPreserveAllTokens(String str, String 
separatorChars, int max) {
   return splitWorker(str, separatorChars, max, true);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2004-09-02 Thread fredrik
fredrik 2004/09/02 12:16:19

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Fixed a typo in javadoc.
  
  Revision  ChangesPath
  1.135 +2 -2  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.134
  retrieving revision 1.135
  diff -u -r1.134 -r1.135
  --- StringUtils.java  22 Aug 2004 03:40:27 -  1.134
  +++ StringUtils.java  2 Sep 2004 19:16:18 -   1.135
  @@ -4424,7 +4424,7 @@
   /**
* pReverses a String as per [EMAIL PROTECTED] StringBuffer#reverse()}./p
*
  - * pA codenull/code String returns codenull/code./p
  + * pA codenull/code String returns codenull/code./p
*
* pre
* StringUtils.reverse(null)  = null
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2004-08-15 Thread scolebourne
scolebourne2004/08/15 16:47:05

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add remove() methods to StringUtils
  
  Revision  ChangesPath
  1.61  +48 -2 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- StringUtilsTest.java  11 Jul 2004 16:49:07 -  1.60
  +++ StringUtilsTest.java  15 Aug 2004 23:47:05 -  1.61
  @@ -1322,5 +1322,51 @@
   assertEquals(StringUtils.removeEnd(domain.com, ), domain.com);   
   assertEquals(StringUtils.removeEnd(domain.com, null), domain.com);   
   }
  -}
   
  +public void testRemove_String() {
  +// StringUtils.remove(null, *)= null
  +assertEquals(null, StringUtils.remove(null, null));
  +assertEquals(null, StringUtils.remove(null, ));
  +assertEquals(null, StringUtils.remove(null, a));
  +
  +// StringUtils.remove(, *)  = 
  +assertEquals(, StringUtils.remove(, null));
  +assertEquals(, StringUtils.remove(, ));
  +assertEquals(, StringUtils.remove(, a));
  +
  +// StringUtils.remove(*, null)= *
  +assertEquals(null, StringUtils.remove(null, null));
  +assertEquals(, StringUtils.remove(, null));
  +assertEquals(a, StringUtils.remove(a, null));
  +
  +// StringUtils.remove(*, )  = *
  +assertEquals(null, StringUtils.remove(null, ));
  +assertEquals(, StringUtils.remove(, ));
  +assertEquals(a, StringUtils.remove(a, ));
  +
  +// StringUtils.remove(queued, ue) = qd
  +assertEquals(qd, StringUtils.remove(queued, ue));
  +
  +// StringUtils.remove(queued, zz) = queued
  +assertEquals(queued, StringUtils.remove(queued, zz));
  +}
  +
  +public void testRemove_char() {
  +// StringUtils.remove(null, *)   = null
  +assertEquals(null, StringUtils.remove(null, 'a'));
  +assertEquals(null, StringUtils.remove(null, 'a'));
  +assertEquals(null, StringUtils.remove(null, 'a'));
  +
  +// StringUtils.remove(, *)  = 
  +assertEquals(, StringUtils.remove(, 'a'));
  +assertEquals(, StringUtils.remove(, 'a'));
  +assertEquals(, StringUtils.remove(, 'a'));
  +
  +// StringUtils.remove(queued, 'u') = qeed
  +assertEquals(qeed, StringUtils.remove(queued, 'u'));
  +
  +// StringUtils.remove(queued, 'z') = queued
  +assertEquals(queued, StringUtils.remove(queued, 'z'));
  +}
  +
  +}
  
  
  
  1.133 +64 -1 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.132
  retrieving revision 1.133
  diff -u -r1.132 -r1.133
  --- StringUtils.java  30 Jul 2004 01:55:42 -  1.132
  +++ StringUtils.java  15 Aug 2004 23:47:05 -  1.133
  @@ -2691,6 +2691,69 @@
   return str;
   }
   
  +/**
  + * pRemoves all occurances of a substring from within the source string./p
  + *
  + * pA codenull/code source string will return codenull/code.
  + * An empty () source string will return the empty string.
  + * A codenull/code remove string will return the source string.
  + * An empty () remove string will return the source string./p
  + *
  + * pre
  + * StringUtils.remove(null, *)= null
  + * StringUtils.remove(, *)  = 
  + * StringUtils.remove(*, null)= *
  + * StringUtils.remove(*, )  = *
  + * StringUtils.remove(queued, ue) = qd
  + * StringUtils.remove(queued, zz) = queued
  + * /pre
  + *
  + * @param str  the source String to search, may be null
  + * @param remove  the String to search for and remove, may be null
  + * @return the substring with the string removed if found,
  + *  codenull/code if null String input
  + * @since 2.1
  + */
  +public static String remove(String str, String remove) {
  +if (isEmpty(str) || isEmpty(remove)) {
  +return str;
  +}
  +return replace(str, remove, , -1);
  +}
  +
  +/**
  + * pRemoves all occurances of a character from within the source string./p
  + *
  + * pA codenull/code source string will return codenull/code.
  + * An empty () source string will return the empty 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2004-07-11 Thread stevencaswell
stevencaswell2004/07/11 09:48:32

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  http://issues.apache.org/bugzilla/show_bug.cgi?id=22692 :
  - added new splitPreserveAllTokens methods to mirror the split functionality, 
preserving empty tokens indicated by adjacent tokens;
  - refactored logic of existing split method into splitWorker for sharing by new 
splitPreserveAllTokens methods
  
  Revision  ChangesPath
  1.131 +219 -28   
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.130
  retrieving revision 1.131
  diff -u -r1.130 -r1.131
  --- StringUtils.java  24 May 2004 20:15:44 -  1.130
  +++ StringUtils.java  11 Jul 2004 16:48:31 -  1.131
  @@ -1994,6 +1994,150 @@
* @since 2.0
*/
   public static String[] split(String str, char separatorChar) {
  +return splitWorker(str, separatorChar, false);
  +}
  +
  +/**
  + * pSplits the provided text into an array, separators specified.
  + * This is an alternative to using StringTokenizer./p
  + *
  + * pThe separator is not included in the returned String array.
  + * Adjacent separators are treated as one separator.
  + * For more control over the split use the Tokenizer class./p
  + *
  + * pA codenull/code input String returns codenull/code.
  + * A codenull/code separatorChars splits on whitespace./p
  + *
  + * pre
  + * StringUtils.split(null, *) = null
  + * StringUtils.split(, *)   = []
  + * StringUtils.split(abc def, null) = [abc, def]
  + * StringUtils.split(abc def,  )  = [abc, def]
  + * StringUtils.split(abc  def,  ) = [abc, def]
  + * StringUtils.split(ab:cd:ef, :) = [ab, cd, ef]
  + * /pre
  + *
  + * @param str  the String to parse, may be null
  + * @param separatorChars  the characters used as the delimiters,
  + *  codenull/code splits on whitespace
  + * @return an array of parsed Strings, codenull/code if null String input
  + */
  +public static String[] split(String str, String separatorChars) {
  +return splitWorker(str, separatorChars, -1, false);
  +}
  +
  +/**
  + * pSplits the provided text into an array with a maximum length,
  + * separators specified./p
  + *
  + * pThe separator is not included in the returned String array.
  + * Adjacent separators are treated as one separator./p
  + *
  + * pA codenull/code input String returns codenull/code.
  + * A codenull/code separatorChars splits on whitespace./p
  + *
  + * pIf more than codemax/code delimited substrings are found, the last
  + * returned string includes all characters after the first codemax - 1/code
  + * returned strings (including separator characters)./p
  + *
  + * pre
  + * StringUtils.split(null, *, *)= null
  + * StringUtils.split(, *, *)  = []
  + * StringUtils.split(ab de fg, null, 0)   = [ab, cd, ef]
  + * StringUtils.split(ab   de fg, null, 0) = [ab, cd, ef]
  + * StringUtils.split(ab:cd:ef, :, 0)= [ab, cd, ef]
  + * StringUtils.split(ab:cd:ef, :, 2)= [ab, cd:ef]
  + * /pre
  + *
  + * @param str  the String to parse, may be null
  + * @param separatorChars  the characters used as the delimiters,
  + *  codenull/code splits on whitespace
  + * @param max  the maximum number of elements to include in the
  + *  array. A zero or negative value implies no limit
  + * @return an array of parsed Strings, codenull/code if null String input
  + */
  +public static String[] split(String str, String separatorChars, int max) {
  +return splitWorker(str, separatorChars, max, false);
  +}
  +
  +//---
  +/**
  + * pSplits the provided text into an array, using whitespace as the
  + * separator, preserving all tokens, including empty tokens created by 
  + * adjacent separators. This is an alternative to using StringTokenizer.
  + * Whitespace is defined by [EMAIL PROTECTED] Character#isWhitespace(char)}./p
  + *
  + * pThe separator is not included in the returned String array.
  + * Adjacent separators are treated as separators for empty tokens.
  + * For more control over the split use the Tokenizer class./p
  + *
  + * pA codenull/code input String returns codenull/code./p
  + *
  + * pre
  + * StringUtils.splitPreserveAllTokens(null)   = null
  + * StringUtils.splitPreserveAllTokens() = []
  + * StringUtils.splitPreserveAllTokens(abc def)  = [abc, def]
  + * 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2004-05-24 Thread fredrik
fredrik 2004/05/24 13:15:44

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  PR: http://issues.apache.org/bugzilla/show_bug.cgi?id=28468
  Fixed error in javadoc.
  Submitted by: Christian d'Heureuse
  
  Revision  ChangesPath
  1.130 +3 -3  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.129
  retrieving revision 1.130
  diff -u -r1.129 -r1.130
  --- StringUtils.java  10 Mar 2004 23:54:48 -  1.129
  +++ StringUtils.java  24 May 2004 20:15:44 -  1.130
  @@ -4032,8 +4032,8 @@
   }
   
   /**
  - * pReturns either the passed in String,
  - * or if the String is codenull/code, an empty String ()./p
  + * pReturns either the passed in String, or if the String is
  + * codenull/code, the value of codedefaultStr/code./p
*
* pre
* StringUtils.defaultString(null, null)  = null
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2004-02-18 Thread fredrik
fredrik 2004/02/18 14:32:50

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Using isEmpty() internally.
  
  Revision  ChangesPath
  1.125 +32 -32
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.124
  retrieving revision 1.125
  diff -u -r1.124 -r1.125
  --- StringUtils.java  16 Feb 2004 23:48:10 -  1.124
  +++ StringUtils.java  18 Feb 2004 22:32:50 -  1.125
  @@ -1,7 +1,7 @@
   /* 
* The Apache Software License, Version 1.1
*
  - * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
  + * Copyright (c) 2002-2004 The Apache Software Foundation.  All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
  @@ -383,7 +383,7 @@
*/
   public static String trimToNull(String str) {
   String ts = trim(str);
  -return (ts == null || ts.length() == 0 ? null : ts);
  +return (isEmpty(ts) ? null : ts);
   }
   
   /**
  @@ -523,7 +523,7 @@
* @return the stripped String, codenull/code if null String input
*/
   public static String strip(String str, String stripChars) {
  -if (str == null || str.length() == 0) {
  +if (isEmpty(str)) {
   return str;
   }
   str = stripStart(str, stripChars);
  @@ -753,7 +753,7 @@
* @since 2.0
*/
   public static int indexOf(String str, char searchChar) {
  -if (str == null || str.length() == 0) {
  +if (isEmpty(str)) {
   return -1;
   }
   return str.indexOf(searchChar);
  @@ -785,7 +785,7 @@
* @since 2.0
*/
   public static int indexOf(String str, char searchChar, int startPos) {
  -if (str == null || str.length() == 0) {
  +if (isEmpty(str)) {
   return -1;
   }
   return str.indexOf(searchChar, startPos);
  @@ -930,7 +930,7 @@
* @since 2.0
*/
   public static int lastIndexOf(String str, char searchChar) {
  -if (str == null || str.length() == 0) {
  +if (isEmpty(str)) {
   return -1;
   }
   return str.lastIndexOf(searchChar);
  @@ -964,7 +964,7 @@
* @since 2.0
*/
   public static int lastIndexOf(String str, char searchChar, int startPos) {
  -if (str == null || str.length() == 0) {
  +if (isEmpty(str)) {
   return -1;
   }
   return str.lastIndexOf(searchChar, startPos);
  @@ -1056,7 +1056,7 @@
* @since 2.0
*/
   public static boolean contains(String str, char searchChar) {
  -if (str == null || str.length() == 0) {
  +if (isEmpty(str)) {
   return false;
   }
   return (str.indexOf(searchChar) = 0);
  @@ -1115,7 +1115,7 @@
* @since 2.0
*/
   public static int indexOfAny(String str, char[] searchChars) {
  -if (StringUtils.isEmpty(str) || searchChars == null || searchChars.length 
== 0) {
  +if (isEmpty(str) || searchChars == null || searchChars.length == 0) {
   return -1;
   }
   for (int i = 0; i  str.length(); i++) {
  @@ -1152,7 +1152,7 @@
* @since 2.0
*/
   public static int indexOfAny(String str, String searchChars) {
  -if (StringUtils.isEmpty(str) || StringUtils.isEmpty(searchChars)) {
  +if (isEmpty(str) || isEmpty(searchChars)) {
   return -1;
   }
   return indexOfAny(str, searchChars.toCharArray());
  @@ -1183,7 +1183,7 @@
* @since 2.0
*/
   public static int indexOfAnyBut(String str, char[] searchChars) {
  -if (str == null || str.length() == 0 || searchChars == null || 
searchChars.length == 0) {
  +if (isEmpty(str) || searchChars == null || searchChars.length == 0) {
   return -1;
   }
   outer : for (int i = 0; i  str.length(); i++) {
  @@ -1221,7 +1221,7 @@
* @since 2.0
*/
   public static int indexOfAnyBut(String str, String searchChars) {
  -if (str == null || str.length() == 0 || searchChars == null || 
searchChars.length() == 0) {
  +if (isEmpty(str) || isEmpty(searchChars)) {
   return -1;
   }
   for (int i = 0; i  str.length(); i++) {
  @@ -1722,7 +1722,7 @@
* @since 2.0
*/
   public static String substringBefore(String str, String separator) {
  -if (str == null || separator == null || str.length() == 0) {
  +if (isEmpty(str) || separator == null) {
   return str;
   }
   if 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2004-02-13 Thread scolebourne
scolebourne2004/02/13 15:32:39

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add comment about new Tokenizer class in split method
  
  Revision  ChangesPath
  1.123 +7 -4  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.122
  retrieving revision 1.123
  diff -u -r1.122 -r1.123
  --- StringUtils.java  24 Dec 2003 01:33:30 -  1.122
  +++ StringUtils.java  13 Feb 2004 23:32:39 -  1.123
  @@ -1984,7 +1984,8 @@
* Whitespace is defined by [EMAIL PROTECTED] Character#isWhitespace(char)}./p
*
* pThe separator is not included in the returned String array.
  - * Adjacent separators are treated as one separator./p
  + * Adjacent separators are treated as one separator.
  + * For more control over the split use the Tokenizer class./p
*
* pA codenull/code input String returns codenull/code./p
*
  @@ -2008,7 +2009,8 @@
* This is an alternative to using StringTokenizer./p
*
* pThe separator is not included in the returned String array.
  - * Adjacent separators are treated as one separator./p
  + * Adjacent separators are treated as one separator.
  + * For more control over the split use the Tokenizer class./p
*
* pA codenull/code input String returns codenull/code./p
*
  @@ -2064,7 +2066,8 @@
* This is an alternative to using StringTokenizer./p
*
* pThe separator is not included in the returned String array.
  - * Adjacent separators are treated as one separator./p
  + * Adjacent separators are treated as one separator.
  + * For more control over the split use the Tokenizer class./p
*
* pA codenull/code input String returns codenull/code.
* A codenull/code separatorChars splits on whitespace./p
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-12-23 Thread scolebourne
scolebourne2003/12/23 17:33:30

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Fix mistake and clarify javadoc spec for replace
  
  Revision  ChangesPath
  1.122 +14 -10
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.121
  retrieving revision 1.122
  diff -u -r1.121 -r1.122
  --- StringUtils.java  15 Dec 2003 01:51:36 -  1.121
  +++ StringUtils.java  24 Dec 2003 01:33:30 -  1.122
  @@ -2544,10 +2544,11 @@
* pre
* StringUtils.replaceOnce(null, *, *)= null
* StringUtils.replaceOnce(, *, *)  = 
  - * StringUtils.replaceOnce(aba, null, null) = aba
  - * StringUtils.replaceOnce(aba, null, null) = aba
  + * StringUtils.replaceOnce(any, null, *)= any
  + * StringUtils.replaceOnce(any, *, null)= any
  + * StringUtils.replaceOnce(any, , *)  = any
* StringUtils.replaceOnce(aba, a, null)  = aba
  - * StringUtils.replaceOnce(aba, a, )= aba
  + * StringUtils.replaceOnce(aba, a, )= ba
* StringUtils.replaceOnce(aba, a, z)   = zba
* /pre
*
  @@ -2570,8 +2571,9 @@
* pre
* StringUtils.replace(null, *, *)= null
* StringUtils.replace(, *, *)  = 
  - * StringUtils.replace(aba, null, null) = aba
  - * StringUtils.replace(aba, null, null) = aba
  + * StringUtils.replace(any, null, *)= any
  + * StringUtils.replace(any, *, null)= any
  + * StringUtils.replace(any, , *)  = any
* StringUtils.replace(aba, a, null)  = aba
* StringUtils.replace(aba, a, )= b
* StringUtils.replace(aba, a, z)   = zbz
  @@ -2597,10 +2599,12 @@
* pre
* StringUtils.replace(null, *, *, *) = null
* StringUtils.replace(, *, *, *)   = 
  - * StringUtils.replace(abaa, null, null, 1) = abaa
  - * StringUtils.replace(abaa, null, null, 1) = abaa
  - * StringUtils.replace(abaa, a, null, 1)  = abaa
  - * StringUtils.replace(abaa, a, , 1)= abaa
  + * StringUtils.replace(any, null, *, *) = any
  + * StringUtils.replace(any, *, null, *) = any
  + * StringUtils.replace(any, , *, *)   = any
  + * StringUtils.replace(any, *, *, 0)= any
  + * StringUtils.replace(abaa, a, null, -1) = abaa
  + * StringUtils.replace(abaa, a, , -1)   = b
* StringUtils.replace(abaa, a, z, 0)   = abaa
* StringUtils.replace(abaa, a, z, 1)   = zbaa
* StringUtils.replace(abaa, a, z, 2)   = zbza
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-12-14 Thread ggregory
ggregory2003/12/14 17:51:36

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25454
  StringUtils.replaceChars(String,String,String).
  
  Revision  ChangesPath
  1.121 +14 -28
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.120
  retrieving revision 1.121
  diff -u -r1.120 -r1.121
  --- StringUtils.java  29 Nov 2003 13:24:33 -  1.120
  +++ StringUtils.java  15 Dec 2003 01:51:36 -  1.121
  @@ -2699,39 +2699,25 @@
* @since 2.0
*/
   public static String replaceChars(String str, String searchChars, String 
replaceChars) {
  -if (str == null || str.length() == 0 || searchChars == null || 
searchChars.length() == 0) {
  +if (StringUtils.isEmpty(str) || StringUtils.isEmpty(searchChars)) {
   return str;
   }
  -char[] chars = str.toCharArray();
  -int len = chars.length;
  -boolean modified = false;
  -for (int i = 0, isize = searchChars.length(); i  isize; i++) {
  -char searchChar = searchChars.charAt(i);
  -if (replaceChars == null || i = replaceChars.length()) {
  -// delete
  -int pos = 0;
  -for (int j = 0; j  len; j++) {
  -if (chars[j] != searchChar) {
  -chars[pos++] = chars[j];
  -} else {
  -modified = true;
  -}
  +if (replaceChars == null) {
  +replaceChars = ;
  +}
  +StringBuffer buffer = new StringBuffer(str.length());
  +for (int i = 0; i  str.length(); i++) {
  +char ch = str.charAt(i);
  +int index = searchChars.indexOf(ch);
  +if (index = 0) {
  +if (index  replaceChars.length()) {
  +buffer.append(replaceChars.charAt(index));
   }
  -len = pos;
   } else {
  -// replace
  -for (int j = 0; j  len; j++) {
  -if (chars[j] == searchChar) {
  -chars[j] = replaceChars.charAt(i);
  -modified = true;
  -}
  -}
  +buffer.append(ch);
   }
   }
  -if (modified == false) {
  -return str;
  -}
  -return new String(chars, 0, len);
  +return buffer.toString();
   }
   
   // Overlay
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-11-04 Thread fredrik
fredrik 2003/11/04 13:00:22

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Using StringUtils.isEmpty() when testing Strings.
  Renamed the parameter string to the more commonly used str in removeStart() and 
removeEnd.
  
  Revision  ChangesPath
  1.117 +15 -15
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.116
  retrieving revision 1.117
  diff -u -r1.116 -r1.117
  --- StringUtils.java  3 Nov 2003 03:48:59 -   1.116
  +++ StringUtils.java  4 Nov 2003 21:00:22 -   1.117
  @@ -1114,7 +1114,7 @@
* @since 2.0
*/
   public static int indexOfAny(String str, char[] searchChars) {
  -if (str == null || str.length() == 0 || searchChars == null || 
searchChars.length == 0) {
  +if (StringUtils.isEmpty(str) || searchChars == null || searchChars.length 
== 0) {
   return -1;
   }
   for (int i = 0; i  str.length(); i++) {
  @@ -1151,7 +1151,7 @@
* @since 2.0
*/
   public static int indexOfAny(String str, String searchChars) {
  -if (str == null || str.length() == 0 || searchChars == null || 
searchChars.length() == 0) {
  +if (StringUtils.isEmpty(str) || StringUtils.isEmpty(searchChars)) {
   return -1;
   }
   return indexOfAny(str, searchChars.toCharArray());
  @@ -2485,14 +2485,14 @@
*  codenull/code if null String input
* @since 2.1
*/
  -public static String removeStart(String string, String remove) {
  -if (string == null || string.length() == 0 || remove == null || 
remove.length() == 0) {
  -return string;
  +public static String removeStart(String str, String remove) {
  +if (StringUtils.isEmpty(str) || StringUtils.isEmpty(remove)) {
  +return str;
   }
  -if (string.startsWith(remove)){
  -return string.substring(remove.length());
  +if (str.startsWith(remove)){
  +return str.substring(remove.length());
   }
  -return string;
  +return str;
   }
   
   /**
  @@ -2519,14 +2519,14 @@
*  codenull/code if null String input
* @since 2.1
*/
  -public static String removeEnd(String string, String remove) {
  -if (string == null || string.length() == 0 || remove == null || 
remove.length() == 0) {
  -return string;
  +public static String removeEnd(String str, String remove) {
  +if (StringUtils.isEmpty(str) || StringUtils.isEmpty(remove)) {
  +return str;
   }
  -if (string.endsWith(remove)) {
  -return string.substring(0, string.length() - remove.length());
  +if (str.endsWith(remove)) {
  +return str.substring(0, str.length() - remove.length());
   }
  -return string;
  +return str;
   }
   
   // Replacing
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: cvs commit: jakarta-commons/lang/src/java/org/apache/commons/ lang StringUtils.java

2003-11-04 Thread Gary Gregory
FWIW,

I disagree with this type of shorthand C-like naming. Since this is a
religious matter, I'll not waste anyone's time beyond this.

Gary

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, November 04, 2003 13:00
 To: [EMAIL PROTECTED]
 Subject: cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang
 StringUtils.java
 
 fredrik 2003/11/04 13:00:22
 
   Modified:lang/src/java/org/apache/commons/lang StringUtils.java
   Log:
   Using StringUtils.isEmpty() when testing Strings.
   Renamed the parameter string to the more commonly used str in
 removeStart() and removeEnd.
 
   Revision  ChangesPath
   1.117 +15 -15jakarta-
 commons/lang/src/java/org/apache/commons/lang/StringUtils.java
 
   Index: StringUtils.java
   ===
   RCS file: /home/cvs/jakarta-
 commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
   retrieving revision 1.116
   retrieving revision 1.117
   diff -u -r1.116 -r1.117
   --- StringUtils.java3 Nov 2003 03:48:59 -   1.116
   +++ StringUtils.java4 Nov 2003 21:00:22 -   1.117
   @@ -1114,7 +1114,7 @@
 * @since 2.0
 */
public static int indexOfAny(String str, char[] searchChars) {
   -if (str == null || str.length() == 0 || searchChars == null ||
 searchChars.length == 0) {
   +if (StringUtils.isEmpty(str) || searchChars == null ||
 searchChars.length == 0) {
return -1;
}
for (int i = 0; i  str.length(); i++) {
   @@ -1151,7 +1151,7 @@
 * @since 2.0
 */
public static int indexOfAny(String str, String searchChars) {
   -if (str == null || str.length() == 0 || searchChars == null ||
 searchChars.length() == 0) {
   +if (StringUtils.isEmpty(str) ||
 StringUtils.isEmpty(searchChars)) {
return -1;
}
return indexOfAny(str, searchChars.toCharArray());
   @@ -2485,14 +2485,14 @@
 *  codenull/code if null String input
 * @since 2.1
 */
   -public static String removeStart(String string, String remove) {
   -if (string == null || string.length() == 0 || remove == null ||
 remove.length() == 0) {
   -return string;
   +public static String removeStart(String str, String remove) {
   +if (StringUtils.isEmpty(str) || StringUtils.isEmpty(remove)) {
   +return str;
}
   -if (string.startsWith(remove)){
   -return string.substring(remove.length());
   +if (str.startsWith(remove)){
   +return str.substring(remove.length());
}
   -return string;
   +return str;
}
 
/**
   @@ -2519,14 +2519,14 @@
 *  codenull/code if null String input
 * @since 2.1
 */
   -public static String removeEnd(String string, String remove) {
   -if (string == null || string.length() == 0 || remove == null ||
 remove.length() == 0) {
   -return string;
   +public static String removeEnd(String str, String remove) {
   +if (StringUtils.isEmpty(str) || StringUtils.isEmpty(remove)) {
   +return str;
}
   -if (string.endsWith(remove)) {
   -return string.substring(0, string.length() -
 remove.length());
   +if (str.endsWith(remove)) {
   +return str.substring(0, str.length() - remove.length());
}
   -return string;
   +return str;
}
 
// Replacing
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


RE: cvs commit: jakarta-commons/lang/src/java/org/apache/commons/ lang StringUtils.java

2003-11-02 Thread Gary Gregory
Is there any sense in talking about keeping the source code in an easy to
deal with order, for example, in our product, when we order source, we use
Eclipse's default Sort Members function.

Gary

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Saturday, November 01, 2003 11:21
 To: [EMAIL PROTECTED]
 Subject: cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang
 StringUtils.java
 
 scolebourne2003/11/01 11:20:35
 
   Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
lang/src/java/org/apache/commons/lang StringUtils.java
   Log:
   Move remove code to relevant position in source file
 
   Revision  ChangesPath
   1.55  +3 -1  jakarta-
 commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
 
   Index: StringUtilsTest.java
   ===
   RCS file: /home/cvs/jakarta-
 commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
   retrieving revision 1.54
   retrieving revision 1.55
   diff -u -r1.54 -r1.55
   --- StringUtilsTest.java29 Oct 2003 02:16:30 -  1.54
   +++ StringUtilsTest.java1 Nov 2003 19:20:35 -   1.55
   @@ -1000,6 +1000,7 @@
assertEquals(StringUtils.removeStart(www.domain.com, www.),
 domain.com);
assertEquals(StringUtils.removeStart(domain.com, www.),
 domain.com);
assertEquals(StringUtils.removeStart(domain.com, ),
 domain.com);
   +assertEquals(StringUtils.removeStart(domain.com, null),
 domain.com);
}
 
public void testRemoveEnd() {
   @@ -1017,6 +1018,7 @@
assertEquals(StringUtils.removeEnd(www.domain.com, .com),
 www.domain);
assertEquals(StringUtils.removeEnd(www.domain, .com),
 www.domain);
assertEquals(StringUtils.removeEnd(domain.com, ),
 domain.com);
   +assertEquals(StringUtils.removeEnd(domain.com, null),
 domain.com);
}
}
 
 
 
 
   1.115 +74 -70jakarta-
 commons/lang/src/java/org/apache/commons/lang/StringUtils.java
 
   Index: StringUtils.java
   ===
   RCS file: /home/cvs/jakarta-
 commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
   retrieving revision 1.114
   retrieving revision 1.115
   diff -u -r1.114 -r1.115
   --- StringUtils.java29 Oct 2003 02:16:15 -  1.114
   +++ StringUtils.java1 Nov 2003 19:20:35 -   1.115
   @@ -80,7 +80,9 @@
 *  - substring extraction relative to other strings/li
 *  libSplit/Join/b
 *  - splits a String into an array of substrings and vice
 versa/li
   - *  libReplace/Delete/Overlay/b
   + *  libRemove/Delete/b
   + *  - removes part of a String/li
   + *  libReplace/Overlay/b
 *  - Searches a String and replaces one String with another/li
 *  libChomp/Chop/b
 *  - removes the last part of a String/li
   @@ -2457,6 +2459,76 @@
return new String(chs, 0, count);
}
 
   +// Remove
   +//-
 --
   +/**
   + * pRemoves a substring only if it is at the begining of a source
 string,
   + * otherwise returns the source string./p
   + *
   + * pA codenull/code source string will return
 codenull/code.
   + * An empty () source string will return the empty string.
   + * A codenull/code search string will return the source
 string./p
   + *
   + * pre
   + * StringUtils.removeStart(null, *)  = null
   + * StringUtils.removeStart(, *)= 
   + * StringUtils.removeStart(*, null)  = *
   + * StringUtils.removeStart(www.domain.com, www.)   =
 domain.com
   + * StringUtils.removeStart(domain.com, www.)   =
 domain.com
   + * StringUtils.removeStart(www.domain.com, domain) =
 www.domain.com
   + * StringUtils.removeStart(abc, )= abc
   + * /pre
   + *
   + * @param str  the source String to search, may be null
   + * @param remove  the String to search for and remove, may be null
   + * @return the substring with the string removed if found,
   + *  codenull/code if null String input
   + * @since 2.1
   + */
   +public static String removeStart(String str, String remove) {
   +if (str == null || str.length() == 0 || remove == null ||
 remove.length() == 0) {
   +return str;
   +}
   +if (str.startsWith(remove)){
   +return str.substring(remove.length());
   +}
   +return str;
   +}
   +
   +/**
   + * pRemoves a substring only if it is at the end of a source
 string,
   + * otherwise returns the source string./p
   + *
   + * pA codenull/code source string will return
 codenull/code.
   + * An empty () source string will return the empty string.
   + * A codenull/code

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-11-02 Thread ggregory
ggregory2003/11/02 19:49:00

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  javadoc.
  
  Revision  ChangesPath
  1.116 +13 -13
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.115
  retrieving revision 1.116
  diff -u -r1.115 -r1.116
  --- StringUtils.java  1 Nov 2003 19:20:35 -   1.115
  +++ StringUtils.java  3 Nov 2003 03:48:59 -   1.116
  @@ -2485,14 +2485,14 @@
*  codenull/code if null String input
* @since 2.1
*/
  -public static String removeStart(String str, String remove) {
  -if (str == null || str.length() == 0 || remove == null || remove.length() 
== 0) {
  -return str;
  +public static String removeStart(String string, String remove) {
  +if (string == null || string.length() == 0 || remove == null || 
remove.length() == 0) {
  +return string;
   }
  -if (str.startsWith(remove)){
  -return str.substring(remove.length());
  +if (string.startsWith(remove)){
  +return string.substring(remove.length());
   }
  -return str;
  +return string;
   }
   
   /**
  @@ -2519,14 +2519,14 @@
*  codenull/code if null String input
* @since 2.1
*/
  -public static String removeEnd(String str, String remove) {
  -if (str == null || str.length() == 0 || remove == null || remove.length() 
== 0) {
  -return str;
  +public static String removeEnd(String string, String remove) {
  +if (string == null || string.length() == 0 || remove == null || 
remove.length() == 0) {
  +return string;
   }
  -if (str.endsWith(remove)) {
  -return str.substring(0, str.length() - remove.length());
  +if (string.endsWith(remove)) {
  +return string.substring(0, string.length() - remove.length());
   }
  -return str;
  +return string;
   }
   
   // Replacing
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-11-01 Thread scolebourne
scolebourne2003/11/01 11:20:35

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Move remove code to relevant position in source file
  
  Revision  ChangesPath
  1.55  +3 -1  
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- StringUtilsTest.java  29 Oct 2003 02:16:30 -  1.54
  +++ StringUtilsTest.java  1 Nov 2003 19:20:35 -   1.55
  @@ -1000,6 +1000,7 @@
   assertEquals(StringUtils.removeStart(www.domain.com, www.), 
domain.com);
   assertEquals(StringUtils.removeStart(domain.com, www.), domain.com);
   assertEquals(StringUtils.removeStart(domain.com, ), domain.com);  
  
  +assertEquals(StringUtils.removeStart(domain.com, null), domain.com);

   }
   
   public void testRemoveEnd() {
  @@ -1017,6 +1018,7 @@
   assertEquals(StringUtils.removeEnd(www.domain.com, .com), www.domain);
   assertEquals(StringUtils.removeEnd(www.domain, .com), www.domain);
   assertEquals(StringUtils.removeEnd(domain.com, ), domain.com);   
  +assertEquals(StringUtils.removeEnd(domain.com, null), domain.com);   
   }
   }
   
  
  
  
  1.115 +74 -70
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.114
  retrieving revision 1.115
  diff -u -r1.114 -r1.115
  --- StringUtils.java  29 Oct 2003 02:16:15 -  1.114
  +++ StringUtils.java  1 Nov 2003 19:20:35 -   1.115
  @@ -80,7 +80,9 @@
*  - substring extraction relative to other strings/li
*  libSplit/Join/b
*  - splits a String into an array of substrings and vice versa/li
  - *  libReplace/Delete/Overlay/b
  + *  libRemove/Delete/b
  + *  - removes part of a String/li
  + *  libReplace/Overlay/b
*  - Searches a String and replaces one String with another/li
*  libChomp/Chop/b
*  - removes the last part of a String/li
  @@ -2457,6 +2459,76 @@
   return new String(chs, 0, count);
   }
   
  +// Remove
  +//---
  +/**
  + * pRemoves a substring only if it is at the begining of a source string,
  + * otherwise returns the source string./p
  + * 
  + * pA codenull/code source string will return codenull/code.
  + * An empty () source string will return the empty string.
  + * A codenull/code search string will return the source string./p
  + * 
  + * pre
  + * StringUtils.removeStart(null, *)  = null
  + * StringUtils.removeStart(, *)= 
  + * StringUtils.removeStart(*, null)  = *
  + * StringUtils.removeStart(www.domain.com, www.)   = domain.com
  + * StringUtils.removeStart(domain.com, www.)   = domain.com
  + * StringUtils.removeStart(www.domain.com, domain) = www.domain.com
  + * StringUtils.removeStart(abc, )= abc
  + * /pre
  + *
  + * @param str  the source String to search, may be null
  + * @param remove  the String to search for and remove, may be null
  + * @return the substring with the string removed if found,
  + *  codenull/code if null String input
  + * @since 2.1
  + */
  +public static String removeStart(String str, String remove) {
  +if (str == null || str.length() == 0 || remove == null || remove.length() 
== 0) {
  +return str;
  +}
  +if (str.startsWith(remove)){
  +return str.substring(remove.length());
  +}
  +return str;
  +}
  +
  +/**
  + * pRemoves a substring only if it is at the end of a source string,
  + * otherwise returns the source string./p
  + *
  + * pA codenull/code source string will return codenull/code.
  + * An empty () source string will return the empty string.
  + * A codenull/code search string will return the source string./p
  + * 
  + * pre
  + * StringUtils.removeEnd(null, *)  = null
  + * StringUtils.removeEnd(, *)= 
  + * StringUtils.removeEnd(*, null)  = *
  + * StringUtils.removeEnd(www.domain.com, .com.)  = www,domain
  + * StringUtils.removeEnd(www.domain.com, .com)   = www.domain
  + * StringUtils.removeEnd(www.domain.com, domain) = www.domain.com
  + * StringUtils.removeEnd(abc, )= abc
  + * /pre
  + *
  + * @param str  

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-10-28 Thread ggregory
ggregory2003/10/28 18:16:15

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Added  public static String removeEnd(String str, String remove).
  Reimpl'd removeStart.
  
  Revision  ChangesPath
  1.114 +40 -5 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.113
  retrieving revision 1.114
  diff -u -r1.113 -r1.114
  --- StringUtils.java  29 Oct 2003 01:49:47 -  1.113
  +++ StringUtils.java  29 Oct 2003 02:16:15 -  1.114
  @@ -202,6 +202,7 @@
* instance to operate./p
*/
   public StringUtils() {
  +// no init.
   }
   
   // Empty checks
  @@ -2801,7 +2802,8 @@
   lastIdx--;
   }
   } else if (last == '\r') {
  -
  +// why is this block empty?
  +// just to skip incrementing the index?
   } else {
   lastIdx++;
   }
  @@ -4381,11 +4383,44 @@
   if (remove == null || remove.length() == 0) {
   return str;
   }
  -int pos = str.indexOf(remove);
  -if (pos == -1) {
  +if (str.startsWith(remove)){
  +return str.substring(remove.length());
  +}
  +return str;
  +}
  +
  +/**
  + * pRemoves a substring only if it is at the end of a source string, 
otherwise returns the source string.
  + *
  + * pA codenull/code source string will return codenull/code.
  + * An empty () source string will return the empty string.
  + * A codenull/code search string will return the source string./p
  + * 
  + * pre
  + * StringUtils.removeEnd(null, *)  = null
  + * StringUtils.removeEnd(, *)= 
  + * StringUtils.removeEnd(*, null)  = *
  + * StringUtils.removeEnd(www.domain.com, .com.)   = www,domain
  + * StringUtils.removeEnd(www.domain.com, .com)   = www.domain
  + * StringUtils.removeEnd(abc, )= abc
  + * /pre
  + *
  + * @param string  the source String to search, may be null
  + * @param remove  the String to search for, may be null
  + * @return the substring after the optional occurrence of the separator,
  + *  codenull/code if null String input
  + */
  +public static String removeEnd(String str, String remove) {
  +if (str == null || str.length() == 0) {
  +return str;
  +}
  +if (remove == null || remove.length() == 0) {
   return str;
   }
  -return str.substring(pos + remove.length());
  +if (str.endsWith(remove)) {
  +return str.substring(0, str.length() - remove.length());
  +}
  +return str;
   }
   
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-10-23 Thread scolebourne
scolebourne2003/10/23 13:40:36

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Fix javadoc of replace method
  bug 24056, from Russell Dittmar
  
  Revision  ChangesPath
  1.111 +2 -2  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.110
  retrieving revision 1.111
  diff -u -r1.110 -r1.111
  --- StringUtils.java  21 Oct 2003 20:24:22 -  1.110
  +++ StringUtils.java  23 Oct 2003 20:40:36 -  1.111
  @@ -2495,7 +2495,7 @@
* StringUtils.replace(aba, null, null) = aba
* StringUtils.replace(aba, null, null) = aba
* StringUtils.replace(aba, a, null)  = aba
  - * StringUtils.replace(aba, a, )= aba
  + * StringUtils.replace(aba, a, )= b
* StringUtils.replace(aba, a, z)   = zbz
* /pre
* 
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-10-23 Thread scolebourne
scolebourne2003/10/23 13:49:22

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Javadoc of method contains
  bug 23430, from Michael Heuer
  
  Revision  ChangesPath
  1.112 +3 -3  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- StringUtils.java  23 Oct 2003 20:40:36 -  1.111
  +++ StringUtils.java  23 Oct 2003 20:49:22 -  1.112
  @@ -1059,7 +1059,7 @@
   }
   
   /**
  - * pFind the first index within a String, handling codenull/code.
  + * pChecks if String contains a search String, handling codenull/code.
* This method uses [EMAIL PROTECTED] String#indexOf(int)}./p
*
* pA codenull/code String will return codefalse/code./p
  @@ -1075,7 +1075,7 @@
* 
* @param str  the String to check, may be null
* @param searchStr  the String to find, may be null
  - * @return true if the String contains the search character, 
  + * @return true if the String contains the search String, 
*  false if not or codenull/code string input
* @since 2.0
*/
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-10-21 Thread scolebourne
scolebourne2003/10/21 13:24:22

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Tweak deleteWhitespace to avoid creating a new String if possible
  
  Revision  ChangesPath
  1.110 +10 -6 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.109
  retrieving revision 1.110
  diff -u -r1.109 -r1.110
  --- StringUtils.java  7 Sep 2003 14:32:34 -   1.109
  +++ StringUtils.java  21 Oct 2003 20:24:22 -  1.110
  @@ -2439,17 +2439,21 @@
* @return the String without whitespaces, codenull/code if null String 
input
*/
   public static String deleteWhitespace(String str) {
  -if (str == null) {
  -return null;
  +if (str == null || str.length() == 0) {
  +return str;
   }
   int sz = str.length();
  -StringBuffer buffer = new StringBuffer(sz);
  +char[] chs = new char[sz];
  +int count = 0;
   for (int i = 0; i  sz; i++) {
   if (!Character.isWhitespace(str.charAt(i))) {
  -buffer.append(str.charAt(i));
  +chs[count++] = str.charAt(i);
   }
   }
  -return buffer.toString();
  +if (count == sz) {
  +return str;
  +}
  +return new String(chs, 0, count);
   }
   
   // Replacing
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-09-04 Thread ggregory
ggregory2003/09/04 11:18:18

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsEqualsIndexOfTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Added ordinalIndexOf() and associated unit tests.
  
  Revision  ChangesPath
  1.9   +63 -1 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java
  
  Index: StringUtilsEqualsIndexOfTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- StringUtilsEqualsIndexOfTest.java 18 Aug 2003 02:22:25 -  1.8
  +++ StringUtilsEqualsIndexOfTest.java 4 Sep 2003 18:18:18 -   1.9
  @@ -146,6 +146,68 @@
   assertEquals(0, StringUtils.indexOf(aabaabaa, ));
   }
   
  +public void testOrdinalIndexOf() {
  +assertEquals(-1, StringUtils.ordinalIndexOf(null, null, Integer.MIN_VALUE));
  +assertEquals(-1, StringUtils.ordinalIndexOf(, null, Integer.MIN_VALUE));
  +assertEquals(-1, StringUtils.ordinalIndexOf(, , Integer.MIN_VALUE));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, a, 
Integer.MIN_VALUE));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, b, 
Integer.MIN_VALUE));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, ab, 
Integer.MIN_VALUE));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, , 
Integer.MIN_VALUE));
  +
  +assertEquals(-1, StringUtils.ordinalIndexOf(null, null, -1));
  +assertEquals(-1, StringUtils.ordinalIndexOf(, null, -1));
  +assertEquals(-1, StringUtils.ordinalIndexOf(, , -1));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, a, -1));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, b, -1));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, ab, -1));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, , -1));
  +
  +assertEquals(-1, StringUtils.ordinalIndexOf(null, null, 0));
  +assertEquals(-1, StringUtils.ordinalIndexOf(, null, 0));
  +assertEquals(-1, StringUtils.ordinalIndexOf(, , 0));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, a, 0));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, b, 0));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, ab, 0));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, , 0));
  +
  +assertEquals(-1, StringUtils.ordinalIndexOf(null, null, 1));
  +assertEquals(-1, StringUtils.ordinalIndexOf(, null, 1));
  +assertEquals(0, StringUtils.ordinalIndexOf(, , 1));
  +assertEquals(0, StringUtils.ordinalIndexOf(aabaabaa, a, 1));
  +assertEquals(2, StringUtils.ordinalIndexOf(aabaabaa, b, 1));
  +assertEquals(1, StringUtils.ordinalIndexOf(aabaabaa, ab, 1));
  +assertEquals(0, StringUtils.ordinalIndexOf(aabaabaa, , 1));
  +
  +assertEquals(-1, StringUtils.ordinalIndexOf(null, null, 2));
  +assertEquals(-1, StringUtils.ordinalIndexOf(, null, 2));
  +assertEquals(0, StringUtils.ordinalIndexOf(, , 2));
  +assertEquals(1, StringUtils.ordinalIndexOf(aabaabaa, a, 2));
  +assertEquals(5, StringUtils.ordinalIndexOf(aabaabaa, b, 2));
  +assertEquals(4, StringUtils.ordinalIndexOf(aabaabaa, ab, 2));
  +assertEquals(0, StringUtils.ordinalIndexOf(aabaabaa, , 2));
  +
  +assertEquals(-1, StringUtils.ordinalIndexOf(null, null, Integer.MAX_VALUE));
  +assertEquals(-1, StringUtils.ordinalIndexOf(, null, Integer.MAX_VALUE));
  +assertEquals(0, StringUtils.ordinalIndexOf(, , Integer.MAX_VALUE));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, a, 
Integer.MAX_VALUE));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, b, 
Integer.MAX_VALUE));
  +assertEquals(-1, StringUtils.ordinalIndexOf(aabaabaa, ab, 
Integer.MAX_VALUE));
  +assertEquals(0, StringUtils.ordinalIndexOf(aabaabaa, , 
Integer.MAX_VALUE));
  +
  +assertEquals(-1, StringUtils.ordinalIndexOf(a, a, 0));
  +assertEquals(0, StringUtils.ordinalIndexOf(a, a, 1));
  +assertEquals(1, StringUtils.ordinalIndexOf(a, a, 2));
  +assertEquals(2, StringUtils.ordinalIndexOf(a, a, 3));
  +assertEquals(3, StringUtils.ordinalIndexOf(a, a, 4));
  +assertEquals(4, StringUtils.ordinalIndexOf(a, a, 5));
  +assertEquals(5, StringUtils.ordinalIndexOf(a, a, 6));
  +assertEquals(6, StringUtils.ordinalIndexOf(a, a, 7));
  +assertEquals(7, StringUtils.ordinalIndexOf(a, a, 8));
  +assertEquals(8, StringUtils.ordinalIndexOf(a, a, 9));
  +

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-08-20 Thread ggregory
ggregory2003/08/20 22:57:21

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add @since 2.0 tags based on 
http://www.apache.org/~bayard/commons-lang-2.0/Commons-Lang-1.0.1-to-2.0/missingSinces.txt
  
  Revision  ChangesPath
  1.104 +49 -1 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.103
  retrieving revision 1.104
  diff -u -r1.103 -r1.104
  --- StringUtils.java  19 Aug 2003 00:11:20 -  1.103
  +++ StringUtils.java  21 Aug 2003 05:57:21 -  1.104
  @@ -166,6 +166,7 @@
   
   /**
* The empty String code/code.
  + * @since 2.0
*/
   public static final String EMPTY = ;
   
  @@ -252,6 +253,7 @@
*
* @param str  the String to check, may be null
* @return codetrue/code if the String is null, empty or whitespace
  + * @since 2.0
*/
   public static boolean isBlank(String str) {
   int strLen;
  @@ -280,6 +282,7 @@
* @param str  the String to check, may be null
* @return codetrue/code if the String is 
*  not empty and not null and not whitespace
  + * @since 2.0
*/
   public static boolean isNotBlank(String str) {
   int strLen;
  @@ -366,6 +369,7 @@
* @param str  the String to be trimmed, may be null
* @return the trimmed String, 
*  codenull/code if only chars lt;= 32, empty or null String input
  + * @since 2.0
*/
   public static String trimToNull(String str) {
   String ts = trim(str);
  @@ -391,6 +395,7 @@
*  
* @param str  the String to be trimmed, may be null
* @return the trimmed String, or an empty String if codenull/code input
  + * @since 2.0
*/
   public static String trimToEmpty(String str) {
   return (str == null ? EMPTY : str.trim());
  @@ -445,6 +450,7 @@
* @param str  the String to be stripped, may be null
* @return the stripped String, 
*  codenull/code if whitespace, empty or null String input
  + * @since 2.0
*/
   public static String stripToNull(String str) {
   if (str == null) {
  @@ -474,6 +480,7 @@
*  
* @param str  the String to be stripped, may be null
* @return the trimmed String, or an empty String if codenull/code input
  + * @since 2.0
*/
   public static String stripToEmpty(String str) {
   return (str == null ? EMPTY : strip(str, null));
  @@ -733,6 +740,7 @@
* @param searchChar  the character to find
* @return the first index of the search character, 
*  -1 if no match or codenull/code string input
  + * @since 2.0
*/
   public static int indexOf(String str, char searchChar) {
   if (str == null || str.length() == 0) {
  @@ -764,6 +772,7 @@
* @param startPos  the start position, negative treated as zero
* @return the first index of the search character, 
*  -1 if no match or codenull/code string input
  + * @since 2.0
*/
   public static int indexOf(String str, char searchChar, int startPos) {
   if (str == null || str.length() == 0) {
  @@ -792,6 +801,7 @@
* @param searchStr  the String to find, may be null
* @return the first index of the search String,
*  -1 if no match or codenull/code string input
  + * @since 2.0
*/
   public static int indexOf(String str, String searchStr) {
   if (str == null || searchStr == null) {
  @@ -829,6 +839,7 @@
* @param startPos  the start position, negative treated as zero
* @return the first index of the search String,
*  -1 if no match or codenull/code string input
  + * @since 2.0
*/
   public static int indexOf(String str, String searchStr, int startPos) {
   if (str == null || searchStr == null) {
  @@ -860,6 +871,7 @@
* @param searchChar  the character to find
* @return the last index of the search character, 
*  -1 if no match or codenull/code string input
  + * @since 2.0
*/
   public static int lastIndexOf(String str, char searchChar) {
   if (str == null || str.length() == 0) {
  @@ -893,6 +905,7 @@
* @param startPos  the start position
* @return the last index of the search character, 
*  -1 if no match or codenull/code string input
  + * @since 2.0
*/
   public static int lastIndexOf(String str, char searchChar, int startPos) {
   if (str == null || str.length() == 0) {
  @@ -921,6 +934,7 @@
* @param searchStr  the String to find, may be null
* @return the last index of the search String,
*  -1 if no 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-08-16 Thread scolebourne
scolebourne2003/08/16 03:36:00

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  uncapitaliseAllWords was not in 1.0.1, so it should not be in 2.0 as deprecated
  
  Revision  ChangesPath
  1.100 +1 -17 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.99
  retrieving revision 1.100
  diff -u -r1.99 -r1.100
  --- StringUtils.java  14 Aug 2003 02:20:48 -  1.99
  +++ StringUtils.java  16 Aug 2003 10:36:00 -  1.100
  @@ -3644,22 +3644,6 @@
   return buffer.toString();
   }
   
  -/**
  - * pUncapitalizes all the whitespace separated words in a String.
  - * Only the first letter of each word is changed./p
  - *
  - * pWhitespace is defined by [EMAIL PROTECTED] Character#isWhitespace(char)}.
  - * A codenull/code input String returns codenull/code./p
  - *
  - * @param str  the String to uncapitalize, may be null
  - * @return uncapitalized String, codenull/code if null String input
  - * @deprecated Use the standardly named [EMAIL PROTECTED] 
#uncapitalizeAllWords(String)}.
  - * Method will be removed in Commons Lang 3.0.
  - */
  -public static String uncapitaliseAllWords(String str) {
  -return uncapitalizeAllWords(str);
  -}
  -
   // Count matches
   //---
   /**
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-08-14 Thread ggregory
ggregory2003/08/13 19:20:48

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Javadoc: Add matching /li tags.
  
  Revision  ChangesPath
  1.99  +29 -29
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.98
  retrieving revision 1.99
  diff -u -r1.98 -r1.99
  --- StringUtils.java  14 Aug 2003 01:49:03 -  1.98
  +++ StringUtils.java  14 Aug 2003 02:20:48 -  1.99
  @@ -63,56 +63,56 @@
* 
* ul
*  libIsEmpty/IsBlank/b
  - *  - checks if a String contains text
  + *  - checks if a String contains text/li
*  libTrim/Strip/b
  - *  - removes leading and trailing whitespace
  + *  - removes leading and trailing whitespace/li
*  libEquals/b
  - *  - compares two strings null-safe
  + *  - compares two strings null-safe/li
*  libIndexOf/LastIndexOf/Contains/b
*  - null-safe index-of checks
*  libIndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut/b
  - *  - index-of any of a set of Strings
  + *  - index-of any of a set of Strings/li
*  libContainsOnly/ContainsNone/b
  - *  - does String contains only/none of these characters
  + *  - does String contains only/none of these characters/li
*  libSubString/Left/Right/Mid/SubStringBefore/SubStringAfter/b
  - *  - null-safe substring extractions
  + *  - null-safe substring extractions/li
*  libSplit/Join/b
  - *  - splits a String into an array of substrings and vice versa
  + *  - splits a String into an array of substrings and vice versa/li
*  libReplace/Delete/Overlay/b
  - *  - Searches a String and replaces one String with another
  + *  - Searches a String and replaces one String with another/li
*  libChomp/Chop/b
  - *  - removes the last part of a String
  + *  - removes the last part of a String/li
*  libLeftPad/RightPad/Center/Repeat/b
  - *  - pads a String
  + *  - pads a String/li
*  libUpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize/b
  - *  - changes the case of a String
  + *  - changes the case of a String/li
*  libNestedString/b
  - *  - returns a substring nested within other Strings
  + *  - returns a substring nested within other Strings/li
*  libCountMatches/b
  - *  - counts the number of occurrances of one String in another
  + *  - counts the number of occurrances of one String in another/li
*  libIsAlpha/IsNumeric/IsWhitespace/b
  - *  - checks the characters in a String
  + *  - checks the characters in a String/li
*  libDefaultString/b
  - *  - protects against a null input String
  + *  - protects against a null input String/li
*  libReverse/ReverseDelimited/b
  - *  - reverses a String
  + *  - reverses a String/li
*  libAbbreviate/b
  - *  - abbreviates a string using ellipsis
  + *  - abbreviates a string using ellipsis/li
*  libDifference/b
  - *  - compares two Strings and reports on their differences
  + *  - compares two Strings and reports on their differences/li
*  libLevensteinDistance/b
  - *  - the number of changes needed to change one String into another
  + *  - the number of changes needed to change one String into another/li
* /ul
*
* pThe codeStringUtils/code class defines certain words related to
* String handling./p
* 
* ul
  - *  linull - codenull/code
  - *  liempty - a zero-length string (code/code)
  - *  lispace - the space character (code' '/code, char 32)
  - *  liwhitespace - the characters defined by [EMAIL PROTECTED] 
Character#isWhitespace(char)}
  - *  litrim - the characters lt;= 32 as in [EMAIL PROTECTED] String#trim()}
  + *  linull - codenull/code/li
  + *  liempty - a zero-length string (code/code)/li
  + *  lispace - the space character (code' '/code, char 32)/li
  + *  liwhitespace - the characters defined by [EMAIL PROTECTED] 
Character#isWhitespace(char)}/li
  + *  litrim - the characters lt;= 32 as in [EMAIL PROTECTED] String#trim()}/li
* /ul
* 
* pcodeStringUtils/code handles codenull/code input Strings quietly.
  @@ -3498,10 +3498,10 @@
* pSwaps the case of a String using a word based algorithm./p
* 
* ul
  - *  liUpper case character converts to Lower case
  - *  liTitle case character converts to Lower case
  - *  liLower case character after Whitespace or at start converts to Title case
  - *  liOther Lower case character converts to Upper case
  + *  liUpper case character converts to Lower case/li
  + *  liTitle case character converts to Lower case/li
  + *  liLower case character after Whitespace or at start converts to Title 
case/li
  + *  liOther 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-08-14 Thread bayard
bayard  2003/08/13 18:21:37

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Added in Javadoc for deprecated capitalise methods.
  
  Revision  ChangesPath
  1.97  +27 -1 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.96
  retrieving revision 1.97
  diff -u -r1.96 -r1.97
  --- StringUtils.java  14 Aug 2003 00:59:39 -  1.96
  +++ StringUtils.java  14 Aug 2003 01:21:36 -  1.97
  @@ -3439,6 +3439,11 @@
   }
   
   /**
  + * pCapitalizes a String changing the first letter to title case as
  + * per [EMAIL PROTECTED] Character#toTitleCase(char)}. No other letters are 
changed./p
  + * 
  + * @param str  the String to capitalize, may be null
  + * @return the capitalized String, codenull/code if null String input
* @deprecated Use the standardly named [EMAIL PROTECTED] #capitalize(String)}.
* Method will be removed in Commons Lang 3.0.
*/
  @@ -3476,6 +3481,11 @@
   }
   
   /**
  + * pUncapitalizes a String changing the first letter to title case as
  + * per [EMAIL PROTECTED] Character#toLowerCase(char)}. No other letters are 
changed./p
  + * 
  + * @param str  the String to uncapitalize, may be null
  + * @return the uncapitalized String, codenull/code if null String input
* @deprecated Use the standardly named [EMAIL PROTECTED] 
#uncapitalize(String)}.
* Method will be removed in Commons Lang 3.0.
*/
  @@ -3578,6 +3588,14 @@
   }
   
   /**
  + * pCapitalizes all the whitespace separated words in a String.
  + * Only the first letter of each word is changed./p
  + *
  + * pWhitespace is defined by [EMAIL PROTECTED] Character#isWhitespace(char)}.
  + * A codenull/code input String returns codenull/code./p
  + *
  + * @param str  the String to capitalize, may be null
  + * @return capitalized String, codenull/code if null String input
* @deprecated Use the standardly named [EMAIL PROTECTED] 
#capitalizeAllWords(String)}.
* Method will be removed in Commons Lang 3.0.
*/
  @@ -3626,6 +3644,14 @@
   }
   
   /**
  + * pUncapitalizes all the whitespace separated words in a String.
  + * Only the first letter of each word is changed./p
  + *
  + * pWhitespace is defined by [EMAIL PROTECTED] Character#isWhitespace(char)}.
  + * A codenull/code input String returns codenull/code./p
  + *
  + * @param str  the String to uncapitalize, may be null
  + * @return uncapitalized String, codenull/code if null String input
* @deprecated Use the standardly named [EMAIL PROTECTED] 
#uncapitalizeAllWords(String)}.
* Method will be removed in Commons Lang 3.0.
*/
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-08-14 Thread ggregory
ggregory2003/08/13 18:49:03

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Javadoc improvements, clean up and fix a missing /code tag.
  
  Revision  ChangesPath
  1.98  +16 -15
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- StringUtils.java  14 Aug 2003 01:21:36 -  1.97
  +++ StringUtils.java  14 Aug 2003 01:49:03 -  1.98
  @@ -58,24 +58,24 @@
   import java.util.List;
   
   /**
  - * pCommon codeString/code manipulation routines that are 
  + * pCommon [EMAIL PROTECTED] java.lang.String} manipulation routines that are 
* codenull/code safe./p
* 
* ul
*  libIsEmpty/IsBlank/b
*  - checks if a String contains text
*  libTrim/Strip/b
  - *  - remove leading and trailing whitespace
  + *  - removes leading and trailing whitespace
*  libEquals/b
  - *  - compare two strings null-safe
  + *  - compares two strings null-safe
*  libIndexOf/LastIndexOf/Contains/b
  - *  - null-safe index of checks
  + *  - null-safe index-of checks
*  libIndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut/b
  - *  - index of any of a set of Strings
  + *  - index-of any of a set of Strings
*  libContainsOnly/ContainsNone/b
  - *  - does String contain only/none of these characters
  + *  - does String contains only/none of these characters
*  libSubString/Left/Right/Mid/SubStringBefore/SubStringAfter/b
  - *  - null-safe substring extraction
  + *  - null-safe substring extractions
*  libSplit/Join/b
*  - splits a String into an array of substrings and vice versa
*  libReplace/Delete/Overlay/b
  @@ -85,7 +85,7 @@
*  libLeftPad/RightPad/Center/Repeat/b
*  - pads a String
*  libUpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize/b
  - *  - change the case of a String
  + *  - changes the case of a String
*  libNestedString/b
*  - returns a substring nested within other Strings
*  libCountMatches/b
  @@ -110,23 +110,24 @@
* ul
*  linull - codenull/code
*  liempty - a zero-length string (code/code)
  - *  lispace - the space character (code' '/code)(char 32)
  + *  lispace - the space character (code' '/code, char 32)
*  liwhitespace - the characters defined by [EMAIL PROTECTED] 
Character#isWhitespace(char)}
*  litrim - the characters lt;= 32 as in [EMAIL PROTECTED] String#trim()}
* /ul
* 
* pcodeStringUtils/code handles codenull/code input Strings quietly.
* That is to say that a codenull/code input will return codenull/code.
  - * Where a codeboolean/code or codeint/code is being returned exact
  + * Where a codeboolean/code or codeint/code is being returned
* details vary by method./p
* 
* pA side effect of the codenull/code handling is that a 
  - * NullPointerException should be considered a bug in codeStringUtils/code.
  - * (Except for deprecated methods)./p
  + * [EMAIL PROTECTED] java.lang.NullPointerException} should be considered a bug in 
codeStringUtils/code
  + * (except for deprecated methods)./p
* 
* pMethods in this class give sample code to explain their operation.
* The symbol code*/code is used to indicate any input including 
codenull/code./p
*
  + * @see java.lang.String
* @author a href=http://jakarta.apache.org/turbine/;Apache Jakarta Turbine/a
* @author GenerationJavaCore
* @author a href=mailto:[EMAIL PROTECTED]Jon S. Stevens/a
  @@ -186,7 +187,7 @@
   }
   
   /**
  - * pcodeStringUtilscode instances should NOT be constructed in
  + * pcodeStringUtils/code instances should NOT be constructed in
* standard programming. Instead, the class should be used as
* codeStringUtils.trim( foo );/code./p
*
  @@ -2836,7 +2837,7 @@
* @return String prechomped
* @throws NullPointerException if str or sep is codenull/code
* @deprecated Use [EMAIL PROTECTED] #substringBefore(String,String)} instead
  - * (although this doesn't include the separator)
  + * (although this doesn't include the separator).
* Method will be removed in Commons Lang 3.0.
*/
   public static String getPrechomp(String str, String sep) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-08-14 Thread ggregory
ggregory2003/08/13 14:32:10

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  
  Refactor  string literals to use the new:
  public static final String EMPTY = 
  I made EMPTY public since I plan on using it when replacing most of our internal 
StringUtil class with this StringUtil.
  
  Revision  ChangesPath
  1.92  +29 -24
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- StringUtils.java  1 Aug 2003 23:58:30 -   1.91
  +++ StringUtils.java  13 Aug 2003 21:32:10 -  1.92
  @@ -164,6 +164,11 @@
   // (not sure who tested this)
   
   /**
  + * The empty String code/code.
  + */
  +public static final String EMPTY = ;
  +
  +/**
* pThe maximum size to which the padding constant(s) can expand./p
*/
   private static final int PAD_LIMIT = 8192;
  @@ -310,7 +315,7 @@
* Method will be removed in Commons Lang 3.0.
*/
   public static String clean(String str) {
  -return (str == null ?  : str.trim());
  +return (str == null ? EMPTY : str.trim());
   }
   
   /**
  @@ -387,7 +392,7 @@
* @return the trimmed String, or an empty String if codenull/code input
*/
   public static String trimToEmpty(String str) {
  -return (str == null ?  : str.trim());
  +return (str == null ? EMPTY : str.trim());
   }
   
   // Stripping
  @@ -470,7 +475,7 @@
* @return the trimmed String, or an empty String if codenull/code input
*/
   public static String stripToEmpty(String str) {
  -return (str == null ?  : strip(str, null));
  +return (str == null ? EMPTY : strip(str, null));
   }
   
   /**
  @@ -1423,7 +1428,7 @@
   start = 0;
   }
   if (start  str.length()) {
  -return ;
  +return EMPTY;
   }
   
   return str.substring(start);
  @@ -1484,7 +1489,7 @@
   
   // if start is greater than end, return 
   if (start  end) {
  -return ;
  +return EMPTY;
   }
   
   if (start  0) {
  @@ -1524,7 +1529,7 @@
   return null;
   }
   if (len  0) {
  -return ;
  +return EMPTY;
   }
   if (str.length() = len) {
   return str;
  @@ -1558,7 +1563,7 @@
   return null;
   }
   if (len  0) {
  -return ;
  +return EMPTY;
   }
   if (str.length() = len) {
   return str;
  @@ -1596,7 +1601,7 @@
   return null;
   }
   if (len  0 || pos  str.length()) {
  -return ;
  +return EMPTY;
   }
   if (pos  0) {
   pos = 0;
  @@ -1639,7 +1644,7 @@
   return str;
   }
   if (separator.length() == 0) {
  -return ;
  +return EMPTY;
   }
   int pos = str.indexOf(separator);
   if (pos == -1) {
  @@ -1678,11 +1683,11 @@
   return str;
   }
   if (separator == null) {
  -return ;
  +return EMPTY;
   }
   int pos = str.indexOf(separator);
   if (pos == -1) {
  -return ;
  +return EMPTY;
   }
   return str.substring(pos + separator.length());
   }
  @@ -1753,11 +1758,11 @@
   return str;
   }
   if (separator == null || separator.length() == 0) {
  -return ;
  +return EMPTY;
   }
   int pos = str.lastIndexOf(separator);
   if (pos == -1 || pos == (str.length() - separator.length())) {
  -return ;
  +return EMPTY;
   }
   return str.substring(pos + separator.length());
   }
  @@ -2210,7 +2215,7 @@
   return null;
   }
   if (separator == null) {
  -separator = ;
  +separator = EMPTY;
   }
   int arraySize = array.length;
   
  @@ -2624,7 +2629,7 @@
   return null;
   }
   if (overlay == null) {
  -overlay = ;
  +overlay = EMPTY;
   }
   int len = str.length();
   if (start  0) {
  @@ -2686,7 +2691,7 @@
   if (str.length() == 1) {
   char ch = str.charAt(0);
   if (ch == '\r' || ch == '\n') {
  -return ;
  +return EMPTY;
   } else {
   return str;
   }
  @@ -2798,7 +2803,7 @@
   } else if (idx 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-08-01 Thread scolebourne
scolebourne2003/08/01 14:02:16

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add  join(Object[])  as a replacement for concatenate
  
  Revision  ChangesPath
  1.42  +12 -2 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- StringUtilsTest.java  31 Jul 2003 20:38:26 -  1.41
  +++ StringUtilsTest.java  1 Aug 2003 21:02:16 -   1.42
  @@ -205,6 +205,16 @@
Hello aPACHE, StringUtils.swapCase(hELLO Apache) );
   }
   
  +public void testJoin_Objectarray() {
  +assertEquals(null, StringUtils.join(null));
  +assertEquals(, StringUtils.join(EMPTY_ARRAY_LIST));
  +assertEquals(, StringUtils.join(NULL_ARRAY_LIST));
  +assertEquals(abc, StringUtils.join(new String[] {a, b, c}));
  +assertEquals(a, StringUtils.join(new String[] {null, a, }));
  +assertEquals(foo, StringUtils.join(MIXED_ARRAY_LIST));
  +assertEquals(foo2, StringUtils.join(MIXED_TYPE_LIST));
  +}
  +
   public void testJoin_ArrayChar() {
   assertEquals(null, StringUtils.join((Object[]) null, ','));
   assertEquals(TEXT_LIST_CHAR, StringUtils.join(ARRAY_LIST, SEPARATOR_CHAR));
  @@ -250,7 +260,7 @@
   assertEquals(TEXT_LIST, 
StringUtils.join(Arrays.asList(ARRAY_LIST).iterator(), SEPARATOR));
   }
   
  -public void testConcatenate_Array() {
  +public void testConcatenate_Objectarray() {
   assertEquals(null, StringUtils.concatenate(null));
   assertEquals(, StringUtils.concatenate(EMPTY_ARRAY_LIST));
   assertEquals(, StringUtils.concatenate(NULL_ARRAY_LIST));
  
  
  
  1.85  +26 -4 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- StringUtils.java  1 Aug 2003 20:45:17 -   1.84
  +++ StringUtils.java  1 Aug 2003 21:02:16 -   1.85
  @@ -1909,9 +1909,6 @@
* Null objects or empty strings within the array are represented by 
* empty strings./p
*
  - * pThe difference from join is that concatenate has no delimiter -- i.e., 
br
  - * codeStringUtils.concatenate(array) = StringUtils.join(array, 
null)/code./p
  - *
* pre
* StringUtils.concatenate(null)= null
* StringUtils.concatenate([])  = 
  @@ -1922,8 +1919,33 @@
* 
* @param array  the array of values to concatenate, may be null
* @return the concatenated String, codenull/code if null array input
  + * @deprecated Use the better named [EMAIL PROTECTED] #join(Object[])} instead.
  + * Method will be removed in Commons Lang 3.0.
*/
   public static String concatenate(Object[] array) {
  +return join(array, null);
  +}
  +
  +/**
  + * pJoins the elements of the provided array into a single String
  + * containing the provided list of elements./p
  + *
  + * pNo separator is added to the joined String.
  + * Null objects or empty strings within the array are represented by 
  + * empty strings./p
  + * 
  + * pre
  + * StringUtils.join(null)= null
  + * StringUtils.join([])  = 
  + * StringUtils.join([null])  = 
  + * StringUtils.join([a, b, c]) = abc
  + * StringUtils.join([null, , a]) = a
  + * /pre
  + * 
  + * @param array  the array of values to join together, may be null
  + * @return the joined String, codenull/code if null array input
  + */
  +public static String join(Object[] array) {
   return join(array, null);
   }
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-08-01 Thread scolebourne
scolebourne2003/08/01 15:05:43

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsSubstringTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add  substringBetween()  as a replacement for getNestedString()
  
  Revision  ChangesPath
  1.11  +22 -1 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java
  
  Index: StringUtilsSubstringTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- StringUtilsSubstringTest.java 30 Jul 2003 22:21:39 -  1.10
  +++ StringUtilsSubstringTest.java 1 Aug 2003 22:05:43 -   1.11
  @@ -269,6 +269,27 @@
   }
   
   //---
  +public void testSubstringBetween_StringString() {
  +assertEquals(null, StringUtils.substringBetween(null, tag));
  +assertEquals(, StringUtils.substringBetween(, ));
  +assertEquals(null, StringUtils.substringBetween(, abc));
  +assertEquals(, StringUtils.substringBetween(,  ));
  +assertEquals(null, StringUtils.substringBetween(abc, null));
  +assertEquals(, StringUtils.substringBetween(abc, ));
  +assertEquals(null, StringUtils.substringBetween(abc, a));
  +assertEquals(bc, StringUtils.substringBetween(abca, a));
  +assertEquals(bc, StringUtils.substringBetween(abcabca, a));
  +assertEquals(bar, StringUtils.substringBetween(\nbar\n, \n));
  +}
  +
  +public void testSubstringBetween_StringStringString() {
  +assertEquals(null, StringUtils.substringBetween(null, , ));
  +assertEquals(, StringUtils.substringBetween(, , ));
  +assertEquals(, StringUtils.substringBetween(,  ,   ));
  +assertEquals(bar, StringUtils.substringBetween(foobar/foo, foo, 
/foo) );
  +}
  +
  +//---
   public void testCountMatches_String() {
   assertEquals(0, StringUtils.countMatches(null, null));
   assertEquals(0, StringUtils.countMatches(blah, null));
  
  
  
  1.86  +123 -65   
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.85
  retrieving revision 1.86
  diff -u -r1.85 -r1.86
  --- StringUtils.java  1 Aug 2003 21:02:16 -   1.85
  +++ StringUtils.java  1 Aug 2003 22:05:43 -   1.86
  @@ -1691,6 +1691,128 @@
   return str.substring(pos + separator.length());
   }
   
  +// Substring between
  +//---
  +/**
  + * pGets the String that is nested in between two instances of the
  + * same String./p
  + *
  + * pA codenull/code input String returns codenull/code.
  + * A codenull/code tag returns codenull/code./p
  + * 
  + * pre
  + * StringUtils.substringBetween(null, *)= null
  + * StringUtils.substringBetween(, ) = 
  + * StringUtils.substringBetween(, tag)  = null
  + * StringUtils.substringBetween(tagabctag, null)  = null
  + * StringUtils.substringBetween(tagabctag, )= 
  + * StringUtils.substringBetween(tagabctag, tag) = abc
  + * /pre
  + *
  + * @param str  the String containing the substring, may be null
  + * @param tag  the String before and after the substring, may be null
  + * @return the substring, codenull/code if no match
  + */
  +public static String substringBetween(String str, String tag) {
  +return substringBetween(str, tag, tag);
  +}
  +
  +/**
  + * pGets the String that is nested in between two Strings.
  + * Only the first match is returned./p
  + * 
  + * pA codenull/code input String returns codenull/code.
  + * A codenull/code open/close returns codenull/code (no match).
  + * An empty () open/close returns an empty string./p
  + *
  + * pre
  + * StringUtils.substringBetween(null, *, *)  = null
  + * StringUtils.substringBetween(, , )  = 
  + * StringUtils.substringBetween(, , tag)   = null
  + * StringUtils.substringBetween(, tag, tag)= null
  + * StringUtils.substringBetween(yabcz, null, null) = null
  + * StringUtils.substringBetween(yabcz, , ) = 
  + * StringUtils.substringBetween(yabcz, y, z)   = abc
  + * StringUtils.substringBetween(yabczyabcz, y, z)   = abc
  + * /pre
  + *
  +

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-08-01 Thread scolebourne
scolebourne2003/08/01 16:01:53

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add  overlay()  as a replacement for  overlayString()
  
  Revision  ChangesPath
  1.43  +37 -4 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- StringUtilsTest.java  1 Aug 2003 21:02:16 -   1.42
  +++ StringUtilsTest.java  1 Aug 2003 23:01:52 -   1.43
  @@ -490,15 +490,21 @@
   assertSame(abcba, StringUtils.replaceChars(abcba, z, w));
   }
   
  -public void testOverlayString() {
  +public void testOverlayString_StringStringIntInt() {
   assertEquals(overlayString(String, String, int, int) failed,
foo foor baz, StringUtils.overlayString(SENTENCE, FOO, 4, 6) 
);
  -assertEquals(null, StringUtils.overlayString(null, null, 2, 4));
  -assertEquals(abef, StringUtils.overlayString(abcdef, null, 2, 4));
   assertEquals(abef, StringUtils.overlayString(abcdef, , 2, 4));
   assertEquals(abef, StringUtils.overlayString(abcdef, , 2, 4));
   assertEquals(abcdcdef, StringUtils.overlayString(abcdef, , 4, 
2));
   try {
  +StringUtils.overlayString(null, , 2, 4);
  +fail();
  +} catch (NullPointerException ex) {}
  +try {
  +StringUtils.overlayString(abcdef, null, 2, 4);
  +fail();
  +} catch (NullPointerException ex) {}
  +try {
   StringUtils.overlayString(abcdef, , -1, 4);
   fail();
   } catch (IndexOutOfBoundsException ex) {}
  @@ -506,6 +512,33 @@
   StringUtils.overlayString(abcdef, , 2, 8);
   fail();
   } catch (IndexOutOfBoundsException ex) {}
  +}
  +
  +public void testOverlay_StringStringIntInt() {
  +assertEquals(null, StringUtils.overlay(null, null, 2, 4));
  +assertEquals(null, StringUtils.overlay(null, null, -2, -4));
  +
  +assertEquals(, StringUtils.overlay(, null, 0, 0));
  +assertEquals(, StringUtils.overlay(, , 0, 0));
  +assertEquals(, StringUtils.overlay(, , 0, 0));
  +assertEquals(, StringUtils.overlay(, , 2, 4));
  +assertEquals(, StringUtils.overlay(, , -2, -4));
  +
  +assertEquals(abef, StringUtils.overlay(abcdef, null, 2, 4));
  +assertEquals(abef, StringUtils.overlay(abcdef, null, 4, 2));
  +assertEquals(abef, StringUtils.overlay(abcdef, , 2, 4));
  +assertEquals(abef, StringUtils.overlay(abcdef, , 4, 2));
  +assertEquals(abef, StringUtils.overlay(abcdef, , 2, 4));
  +assertEquals(abef, StringUtils.overlay(abcdef, , 4, 2));
  +
  +assertEquals(ef, StringUtils.overlay(abcdef, , -1, 4));
  +assertEquals(ef, StringUtils.overlay(abcdef, , 4, -1));
  +assertEquals(abcdef, StringUtils.overlay(abcdef, , -2, -1));
  +assertEquals(abcdef, StringUtils.overlay(abcdef, , -1, -2));
  +assertEquals(abcd, StringUtils.overlay(abcdef, , 4, 10));
  +assertEquals(abcd, StringUtils.overlay(abcdef, , 10, 4));
  +assertEquals(abcdef, StringUtils.overlay(abcdef, , 8, 10));
  +assertEquals(abcdef, StringUtils.overlay(abcdef, , 10, 8));
   }
   
   public void testRepeat_StringInt() {
  
  
  
  1.87  +65 -7 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- StringUtils.java  1 Aug 2003 22:05:43 -   1.86
  +++ StringUtils.java  1 Aug 2003 23:01:52 -   1.87
  @@ -204,7 +204,7 @@
* StringUtils.isEmpty(  bob  ) = false
* /pre
*
  - * pNOTE: This method changed in version 2.0.
  + * pNOTE: This method changed in Lang version 2.0.
* It no longer trims the String.
* That functionality is available in isBlank()./p
* 
  @@ -2491,7 +2491,8 @@
* pOverlays part of a String with another String./p
*
* pre
  - * StringUtils.overlayString(null, *, *, *)   = null
  + * StringUtils.overlayString(null, *, *, *)   = NullPointerException
  + * StringUtils.overlayString(*, null, *, *)   = 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-08-01 Thread scolebourne
scolebourne2003/08/01 16:11:55

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsSubstringTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Relax exceptions in left(), right() and mid()
  
  Revision  ChangesPath
  1.12  +19 -19
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java
  
  Index: StringUtilsSubstringTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StringUtilsSubstringTest.java 1 Aug 2003 22:05:43 -   1.11
  +++ StringUtilsSubstringTest.java 1 Aug 2003 23:11:54 -   1.12
  @@ -139,30 +139,30 @@
   assertSame(null, StringUtils.left(null, -1));
   assertSame(null, StringUtils.left(null, 0));
   assertSame(null, StringUtils.left(null, 2));
  -assertSame(, StringUtils.left(, 0));
  -assertSame(, StringUtils.left(, 2));
  +
  +assertEquals(, StringUtils.left(, -1));
  +assertEquals(, StringUtils.left(, 0));
  +assertEquals(, StringUtils.left(, 2));
  +
  +assertEquals(, StringUtils.left(FOOBAR, -1));
   assertEquals(, StringUtils.left(FOOBAR, 0));
   assertEquals(FOO, StringUtils.left(FOOBAR, 3));
   assertSame(FOOBAR, StringUtils.left(FOOBAR, 80));
  -try {
  -StringUtils.left(FOOBAR, -1);
  -fail();
  -} catch (IllegalArgumentException ex) {}
   }
   
   public void testRight_String() {
   assertSame(null, StringUtils.right(null, -1));
   assertSame(null, StringUtils.right(null, 0));
   assertSame(null, StringUtils.right(null, 2));
  -assertSame(, StringUtils.right(, 0));
  -assertSame(, StringUtils.right(, 2));
  +
  +assertEquals(, StringUtils.right(, -1));
  +assertEquals(, StringUtils.right(, 0));
  +assertEquals(, StringUtils.right(, 2));
  +
  +assertEquals(, StringUtils.right(FOOBAR, -1));
   assertEquals(, StringUtils.right(FOOBAR, 0));
   assertEquals(BAR, StringUtils.right(FOOBAR, 3));
   assertSame(FOOBAR, StringUtils.right(FOOBAR, 80));
  -try {
  -StringUtils.right(FOOBAR, -1);
  -fail();
  -} catch (IllegalArgumentException ex) {}
   }
   
   public void testMid_String() {
  @@ -170,8 +170,12 @@
   assertSame(null, StringUtils.mid(null, 0, -1));
   assertSame(null, StringUtils.mid(null, 3, 0));
   assertSame(null, StringUtils.mid(null, 3, 2));
  -assertSame(, StringUtils.mid(, 0, 0));
  -assertSame(, StringUtils.mid(, 0, 2));
  +
  +assertEquals(, StringUtils.mid(, 0, -1));
  +assertEquals(, StringUtils.mid(, 0, 0));
  +assertEquals(, StringUtils.mid(, 0, 2));
  +
  +assertEquals(, StringUtils.mid(FOOBAR, 3, -1));
   assertEquals(, StringUtils.mid(FOOBAR, 3, 0));
   assertEquals(b, StringUtils.mid(FOOBAR, 3, 1));
   assertEquals(FOO, StringUtils.mid(FOOBAR, 0, 3));
  @@ -180,10 +184,6 @@
   assertEquals(BAR, StringUtils.mid(FOOBAR, 3, 80));
   assertEquals(, StringUtils.mid(FOOBAR, 9, 3));
   assertEquals(FOO, StringUtils.mid(FOOBAR, -1, 3));
  -try {
  -StringUtils.mid(FOOBAR, 0, -1);
  -fail();
  -} catch (IllegalArgumentException ex) {}
   }
   
   //---
  
  
  
  1.88  +7 -13 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.87
  retrieving revision 1.88
  diff -u -r1.87 -r1.88
  --- StringUtils.java  1 Aug 2003 23:01:52 -   1.87
  +++ StringUtils.java  1 Aug 2003 23:11:55 -   1.88
  @@ -1431,7 +1431,7 @@
*
* pre
* StringUtils.left(null, *)= null
  - * StringUtils.left(*, -ve) = IllegalArgumentException
  + * StringUtils.left(*, -ve) = 
* StringUtils.left(, *)  = 
* StringUtils.left(abc, 0)   = 
* StringUtils.left(abc, 2)   = ab
  @@ -1441,14 +1441,13 @@
* @param str  the String to get the leftmost characters from, may be null
* @param len  the length of the required String, must be zero or positive
* @return the leftmost characters, codenull/code if null String input
  - * @throws IllegalArgumentException if len is less than zero
*/
   public static String left(String 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-08-01 Thread scolebourne
scolebourne2003/08/01 16:20:06

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Relax exceptions in leftPad(), rightPad() and center()
  
  Revision  ChangesPath
  1.44  +7 -27 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- StringUtilsTest.java  1 Aug 2003 23:01:52 -   1.43
  +++ StringUtilsTest.java  1 Aug 2003 23:20:06 -   1.44
  @@ -703,14 +703,8 @@
   assertEquals(abc-+, StringUtils.rightPad(abc, 5, -+~));
   assertEquals(abc, StringUtils.rightPad(abc, 2,  ));
   assertEquals(abc, StringUtils.rightPad(abc, -1,  ));
  -try {
  -StringUtils.rightPad(abc56, 6, null);
  -fail();
  -} catch (IllegalArgumentException ex) {}
  -try {
  -StringUtils.rightPad(abc56, 6, );
  -fail();
  -} catch (IllegalArgumentException ex) {}
  +assertEquals(abc  , StringUtils.rightPad(abc, 5, null));
  +assertEquals(abc  , StringUtils.rightPad(abc, 5, ));
   }
   
   //---
  @@ -741,14 +735,8 @@
   assertEquals(-+abc, StringUtils.leftPad(abc, 5, -+~));
   assertEquals(abc, StringUtils.leftPad(abc, 2,  ));
   assertEquals(abc, StringUtils.leftPad(abc, -1,  ));
  -try {
  -StringUtils.leftPad(abc56, 6, null);
  -fail();
  -} catch (IllegalArgumentException ex) {}
  -try {
  -StringUtils.leftPad(abc56, 6, );
  -fail();
  -} catch (IllegalArgumentException ex) {}
  +assertEquals(  abc, StringUtils.leftPad(abc, 5, null));
  +assertEquals(  abc, StringUtils.leftPad(abc, 5, ));
   }
   
   //---
  @@ -795,16 +783,8 @@
   assertEquals( a  , StringUtils.center(a, 4,  ));
   assertEquals(yayz, StringUtils.center(a, 4, yz));
   assertEquals(yzyayzy, StringUtils.center(a, 7, yz));
  -try {
  -StringUtils.center(abc, 4, null);
  -fail();
  -} catch (IllegalArgumentException ex) {
  -}
  -try {
  -StringUtils.center(abc, 4, );
  -fail();
  -} catch (IllegalArgumentException ex) {
  -}
  +assertEquals(  abc  , StringUtils.center(abc, 7, null));
  +assertEquals(  abc  , StringUtils.center(abc, 7, ));
   }
   
   //---
  
  
  
  1.89  +16 -21
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- StringUtils.java  1 Aug 2003 23:11:55 -   1.88
  +++ StringUtils.java  1 Aug 2003 23:20:06 -   1.89
  @@ -3022,26 +3022,24 @@
* StringUtils.rightPad(bat, 8, yz)  = batyzyzy
* StringUtils.rightPad(bat, 1, yz)  = bat
* StringUtils.rightPad(bat, -1, yz) = bat
  - * StringUtils.rightPad(bat, 1, null)  = IllegalArgumentException
  - * StringUtils.rightPad(bat, 1, )= IllegalArgumentException
  - * StringUtils.rightPad(null, 1, ) = null
  + * StringUtils.rightPad(bat, 5, null)  = bat  
  + * StringUtils.rightPad(bat, 5, )= bat  
* /pre
*
* @param str  the String to pad out, may be null
* @param size  the size to pad to
  - * @param padStr  the String to pad with, must not be null
  + * @param padStr  the String to pad with, null or empty treated as single space
* @return right padded String or original String if no padding is necessary,
*  codenull/code if null String input
  - * @throws IllegalArgumentException if padStr is the empty String or null
*/
   public static String rightPad(String str, int size, String padStr) {
   if (str == null) {
   return null;
   }
  -int padLen;
  -if (padStr == null || (padLen = padStr.length()) == 0) {
  -throw new IllegalArgumentException(Pad String must not be null or 
empty);
  +if (padStr == null || padStr.length() == 0) {
  +padStr =  ;
   }
  +int padLen = padStr.length();
   int strLen = str.length();
   int pads = 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-08-01 Thread scolebourne
scolebourne2003/08/01 16:54:41

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsEqualsIndexOfTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Complete the indexOfAny() method set
  
  Revision  ChangesPath
  1.7   +64 -37
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java
  
  Index: StringUtilsEqualsIndexOfTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StringUtilsEqualsIndexOfTest.java 30 Jul 2003 22:21:39 -  1.6
  +++ StringUtilsEqualsIndexOfTest.java 1 Aug 2003 23:54:41 -   1.7
  @@ -251,10 +251,10 @@
   }
   
   //---
  -public void testIndexOfAny() {
  -assertEquals(-1, StringUtils.indexOfAny(null, null));
  +public void testIndexOfAny_StringStringarray() {
  +assertEquals(-1, StringUtils.indexOfAny(null, (String[]) null));
   assertEquals(-1, StringUtils.indexOfAny(null, FOOBAR_SUB_ARRAY));
  -assertEquals(-1, StringUtils.indexOfAny(FOOBAR, null));
  +assertEquals(-1, StringUtils.indexOfAny(FOOBAR, (String[]) null));
   assertEquals(2, StringUtils.indexOfAny(FOOBAR, FOOBAR_SUB_ARRAY));
   assertEquals(-1, StringUtils.indexOfAny(FOOBAR, new String[0]));
   assertEquals(-1, StringUtils.indexOfAny(null, new String[0]));
  @@ -268,7 +268,7 @@
   assertEquals(-1, StringUtils.indexOfAny(null, new String[] {null}));
   }
   
  -public void testLastIndexOfAny() {
  +public void testLastIndexOfAny_StringStringarray() {
   assertEquals(-1, StringUtils.lastIndexOfAny(null, null));
   assertEquals(-1, StringUtils.lastIndexOfAny(null, FOOBAR_SUB_ARRAY));
   assertEquals(-1, StringUtils.lastIndexOfAny(FOOBAR, null));
  @@ -286,44 +286,71 @@
   }
   
   //---
  -public void testIndexOfAnyBut() {
  -String str1 = a;
  -String str2 = b;
  -String str3 = ab;
  -String chars1= b;
  -String chars2= a;
  -String chars3= ab;
  -assertEquals(-1, StringUtils.indexOfAnyBut(null, (String) null));
  -assertEquals(-1, StringUtils.indexOfAnyBut(, (String) null));
  -assertEquals(-1, StringUtils.indexOfAnyBut(null, ));
  -assertEquals(0, StringUtils.indexOfAnyBut(str1, ));
  -assertEquals(-1, StringUtils.indexOfAnyBut(, ));
  -assertEquals(-1, StringUtils.indexOfAnyBut(, chars1));
  -assertEquals(0, StringUtils.indexOfAnyBut(str1, chars1));
  -assertEquals(-1, StringUtils.indexOfAnyBut(str1, chars2));
  -assertEquals(-1, StringUtils.indexOfAnyBut(str1, chars3));
  -assertEquals(-1, StringUtils.indexOfAnyBut(str2, chars1));
  -assertEquals(0, StringUtils.indexOfAnyBut(str2, chars2));
  -assertEquals(-1, StringUtils.indexOfAnyBut(str2, chars3));
  -assertEquals(0, StringUtils.indexOfAnyBut(str3, chars1));
  -assertEquals(1, StringUtils.indexOfAnyBut(str3, chars2));
  -assertEquals(-1, StringUtils.indexOfAnyBut(str3, chars3));
  -assertEquals(3, StringUtils.indexOfAnyBut(zzabyycdxx, za));
  -assertEquals(0, StringUtils.indexOfAnyBut(zzabyycdxx, ));
  -assertEquals(-1, StringUtils.indexOfAnyBut(aba,ab));
  +public void testIndexOfAny_StringChararray() {
  +assertEquals(-1, StringUtils.indexOfAny(null, (char[]) null));
  +assertEquals(-1, StringUtils.indexOfAny(null, new char[0]));
  +assertEquals(-1, StringUtils.indexOfAny(null, new char[] {'a','b'}));
  +
  +assertEquals(-1, StringUtils.indexOfAny(, (char[]) null));
  +assertEquals(-1, StringUtils.indexOfAny(, new char[0]));
  +assertEquals(-1, StringUtils.indexOfAny(, new char[] {'a','b'}));
  +
  +assertEquals(-1, StringUtils.indexOfAny(zzabyycdxx, (char[]) null)); 
  +assertEquals(-1, StringUtils.indexOfAny(zzabyycdxx, new char[0])); 
  +assertEquals(0, StringUtils.indexOfAny(zzabyycdxx, new char[] 
{'z','a'})); 
  +assertEquals(3, StringUtils.indexOfAny(zzabyycdxx, new char[] {'b','y'}));
  +assertEquals(-1, StringUtils.indexOfAny(ab, new char[] {'z'}));
  +}
  +
  +public void testIndexOfAny_StringString() {
  +assertEquals(-1, StringUtils.indexOfAny(null, (String) null));
  +assertEquals(-1, StringUtils.indexOfAny(null, ));
  +assertEquals(-1, StringUtils.indexOfAny(null, ab));
  +
  +assertEquals(-1, StringUtils.indexOfAny(, (String) null));
  +assertEquals(-1, StringUtils.indexOfAny(, ));
  

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-08-01 Thread scolebourne
scolebourne2003/08/01 16:58:30

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Reorder indexOf methods in file
  
  Revision  ChangesPath
  1.91  +102 -102  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- StringUtils.java  1 Aug 2003 23:54:41 -   1.90
  +++ StringUtils.java  1 Aug 2003 23:58:30 -   1.91
  @@ -1011,107 +1011,6 @@
   return (str.indexOf(searchStr) = 0);
   }
   
  -// IndexOfAny strings
  -//---
  -/**
  - * pFind the first index of any of a set of potential substrings./p
  - *
  - * pA codenull/code String will return code-1/code.
  - * A codenull/code or zero length search array will return code-1/code.
  - * A codenull/code search array entry will be ignored, but a search
  - * array containing  will return code0/code if codestr/code is not
  - * null. This method uses [EMAIL PROTECTED] String#indexOf(String)}./p
  - * 
  - * pre
  - * StringUtils.indexOfAny(null, *) = -1
  - * StringUtils.indexOfAny(*, null) = -1
  - * StringUtils.indexOfAny(*, [])   = -1
  - * StringUtils.indexOfAny(zzabyycdxx, [ab,cd])   = 2
  - * StringUtils.indexOfAny(zzabyycdxx, [cd,ab])   = 2
  - * StringUtils.indexOfAny(zzabyycdxx, [mn,op])   = -1
  - * StringUtils.indexOfAny(zzabyycdxx, [zab,aby]) = 1
  - * StringUtils.indexOfAny(zzabyycdxx, [])  = 0
  - * StringUtils.indexOfAny(, [])= 0
  - * StringUtils.indexOfAny(, [a])   = -1
  - * /pre
  - * 
  - * @param str  the String to check, may be null
  - * @param searchStrs  the Strings to search for, may be null
  - * @return the first index of any of the searchStrs in str, -1 if no match
  - */
  -public static int indexOfAny(String str, String[] searchStrs) {
  -if ((str == null) || (searchStrs == null)) {
  -return -1;
  -}
  -int sz = searchStrs.length;
  -
  -// String's can't have a MAX_VALUEth index.
  -int ret = Integer.MAX_VALUE;
  -
  -int tmp = 0;
  -for (int i = 0; i  sz; i++) {
  -String search = searchStrs[i];
  -if (search == null) {
  -continue;
  -}
  -tmp = str.indexOf(search);
  -if (tmp == -1) {
  -continue;
  -}
  -
  -if (tmp  ret) {
  -ret = tmp;
  -}
  -}
  -
  -return (ret == Integer.MAX_VALUE) ? -1 : ret;
  -}
  -
  -/**
  - * pFind the latest index of any of a set of potential substrings./p
  - *
  - * pA codenull/code String will return code-1/code.
  - * A codenull/code search array will return code-1/code.
  - * A codenull/code or zero length search array entry will be ignored,
  - * but a search array containing  will return the length of codestr/code 
  - * if codestr/code is not null. This method uses [EMAIL PROTECTED] 
String#indexOf(String)}/p
  - * 
  - * pre
  - * StringUtils.lastIndexOfAny(null, *)   = -1
  - * StringUtils.lastIndexOfAny(*, null)   = -1
  - * StringUtils.lastIndexOfAny(*, []) = -1
  - * StringUtils.lastIndexOfAny(*, [null]) = -1
  - * StringUtils.lastIndexOfAny(zzabyycdxx, [ab,cd]) = 6
  - * StringUtils.lastIndexOfAny(zzabyycdxx, [cd,ab]) = 6
  - * StringUtils.lastIndexOfAny(zzabyycdxx, [mn,op]) = -1
  - * StringUtils.lastIndexOfAny(zzabyycdxx, [mn,op]) = -1
  - * StringUtils.lastIndexOfAny(zzabyycdxx, [mn,])   = 10
  - * /pre
  - * 
  - * @param str  the String to check, may be null
  - * @param searchStrs  the Strings to search for, may be null
  - * @return the last index of any of the Strings, -1 if no match
  - */
  -public static int lastIndexOfAny(String str, String[] searchStrs) {
  -if ((str == null) || (searchStrs == null)) {
  -return -1;
  -}
  -int sz = searchStrs.length;
  -int ret = -1;
  -int tmp = 0;
  -for (int i = 0; i  sz; i++) {
  -String search = searchStrs[i];
  -if (search == null) {
  -continue;
  -}
  -tmp = str.lastIndexOf(search);
  -if (tmp  ret) {
  -ret = tmp;
  -}
  -}
  -return ret;
  -}
  -
   // IndexOfAny chars
   

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-30 Thread scolebourne
scolebourne2003/07/30 15:17:49

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Fixes arising from Clover report
  
  Revision  ChangesPath
  1.82  +12 -12
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- StringUtils.java  26 Jul 2003 15:35:35 -  1.81
  +++ StringUtils.java  30 Jul 2003 22:17:49 -  1.82
  @@ -2331,10 +2331,10 @@
   }
   
   if (str.length() == 1) {
  -if (\r.equals(str) || \n.equals(str)) {
  +char ch = str.charAt(0);
  +if (ch == '\r' || ch == '\n') {
   return ;
  -}
  -else {
  +} else {
   return str;
   }
   }
  @@ -2615,8 +2615,8 @@
   if (repeat = 0) {
   return ;
   }
  -int inputLength;
  -if (repeat == 1 || (inputLength = str.length()) == 0) {
  +int inputLength = str.length();
  +if (repeat == 1 || inputLength == 0) {
   return str;
   }
   if (inputLength == 1  repeat = PAD_LIMIT) {
  @@ -2771,13 +2771,13 @@
   }
   int strLen = str.length();
   int pads = size - strLen;
  +if (pads = 0) {
  +return str; // returns original String when possible
  +}
   if (padLen == 1  pads = PAD_LIMIT) {
   return rightPad(str, size, padStr.charAt(0));
   }
   
  -if (pads = 0) {
  -return str; // returns original String when possible
  -}
   if (pads == padLen) {
   return str.concat(padStr);
   } else if (pads  padLen) {
  @@ -2884,13 +2884,13 @@
   }
   int strLen = str.length();
   int pads = size - strLen;
  +if (pads = 0) {
  +return str; // returns original String when possible
  +}
   if (padLen == 1  pads = PAD_LIMIT) {
   return leftPad(str, size, padStr.charAt(0));
   }
   
  -if (pads = 0) {
  -return str; // returns original String when possible
  -}
   if (pads == padLen) {
   return padStr.concat(str);
   } else if (pads  padLen) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-26 Thread scolebourne
scolebourne2003/07/26 07:34:50

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Handle JDK1.2/JDK1.3 bug in String.indexOf
  
  Revision  ChangesPath
  1.80  +6 -1  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.79
  retrieving revision 1.80
  diff -u -r1.79 -r1.80
  --- StringUtils.java  25 Jul 2003 22:22:30 -  1.79
  +++ StringUtils.java  26 Jul 2003 14:34:49 -  1.80
  @@ -822,6 +822,7 @@
* StringUtils.indexOf(aabaabaa, b, 9)  = -1
* StringUtils.indexOf(aabaabaa, b, -1) = 2
* StringUtils.indexOf(aabaabaa, , 2)   = 2
  + * StringUtils.indexOf(abc, , 9)= 3
* /pre
* 
* @param str  the String to check, may be null
  @@ -833,6 +834,10 @@
   public static int indexOf(String str, String searchStr, int startPos) {
   if (str == null || searchStr == null) {
   return -1;
  +}
  +// JDK1.2/JDK1.3 have a bug, when startPos  str.length for , hence
  +if (searchStr.length() == 0  startPos = str.length()) {
  +return str.length();
   }
   return str.indexOf(searchStr, startPos);
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-25 Thread scolebourne
scolebourne2003/07/25 15:22:31

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
StringUtilsSubstringTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Rename slice functions to substringAfter/substringBefore
  
  Revision  ChangesPath
  1.39  +1 -104
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- StringUtilsTest.java  25 Jul 2003 00:50:00 -  1.38
  +++ StringUtilsTest.java  25 Jul 2003 22:22:30 -  1.39
  @@ -573,109 +573,6 @@
 }
   }
   
  -public void testSliceFunctions() {
  -
  -String[][] sliceCases = {
  -{foo\n, foo},
  -{foo\nbar, foo},
  -{foo\nbar\n, foo\nbar},
  -{foo\nbar\nbaz, foo\nbar},
  -{null, null},
  -{, },
  -{\n, },
  -{abc \n, abc },
  -{abc\r\n, abc\r},
  -{foo, foo},
  -};
  -for (int i = 0; i  sliceCases.length; i++) {
  -String original = sliceCases[i][0];
  -String expectedResult = sliceCases[i][1];
  -assertEquals(slice(String) failed,
  -expectedResult, StringUtils.slice(original));
  -}
  -}
  -
  -public void testSlice_StringString() {
  -assertEquals(fooXXbar, StringUtils.slice(fooXXbarXXbaz, XX));
  -
  -assertEquals(null, StringUtils.slice(null, null));
  -assertEquals(null, StringUtils.slice(null, ));
  -assertEquals(null, StringUtils.slice(null, XX));
  -assertEquals(, StringUtils.slice(, null));
  -assertEquals(, StringUtils.slice(, ));
  -assertEquals(, StringUtils.slice(, XX));
  -
  -assertEquals(foo, StringUtils.slice(foo, null));
  -assertEquals(foo, StringUtils.slice(foo, b));
  -assertEquals(fo, StringUtils.slice(foo, o));
  -assertEquals(abc\r\n, StringUtils.slice(abc\r\n, d));
  -assertEquals(abc, StringUtils.slice(abcdabc, d));
  -assertEquals(abcdabc, StringUtils.slice(abcdabcd, d));
  -assertEquals(a, StringUtils.slice(abc, b));
  -assertEquals(abc , StringUtils.slice(abc \n, \n));
  -assertEquals(a, StringUtils.slice(a, null));
  -assertEquals(a, StringUtils.slice(a, ));
  -assertEquals(, StringUtils.slice(a, a));
  -}
  -
  -public void testSliceRemainder_StringString() {
  -assertEquals(baz, StringUtils.sliceRemainder(fooXXbarXXbaz, XX));
  -
  -assertEquals(null, StringUtils.sliceRemainder(null, null));
  -assertEquals(null, StringUtils.sliceRemainder(null, ));
  -assertEquals(null, StringUtils.sliceRemainder(null, XX));
  -assertEquals(, StringUtils.sliceRemainder(, null));
  -assertEquals(, StringUtils.sliceRemainder(, ));
  -assertEquals(, StringUtils.sliceRemainder(, a));
  -
  -assertEquals(, StringUtils.sliceRemainder(foo, null));
  -assertEquals(, StringUtils.sliceRemainder(foo, b));
  -assertEquals(t, StringUtils.sliceRemainder(foot, o));
  -assertEquals(bc, StringUtils.sliceRemainder(abc, a));
  -assertEquals(a, StringUtils.sliceRemainder(abcba, b));
  -assertEquals(, StringUtils.sliceRemainder(abc, c));
  -assertEquals(, StringUtils.sliceRemainder(, d));
  -assertEquals(, StringUtils.sliceRemainder(abc, ));
  -}
  -
  -public void testSliceFirst_StringString() {
  -assertEquals(foo, StringUtils.sliceFirst(fooXXbarXXbaz, XX));
  -
  -assertEquals(null, StringUtils.sliceFirst(null, null));
  -assertEquals(null, StringUtils.sliceFirst(null, ));
  -assertEquals(null, StringUtils.sliceFirst(null, XX));
  -assertEquals(, StringUtils.sliceFirst(, null));
  -assertEquals(, StringUtils.sliceFirst(, ));
  -assertEquals(, StringUtils.sliceFirst(, XX));
  -
  -assertEquals(foo, StringUtils.sliceFirst(foo, null));
  -assertEquals(foo, StringUtils.sliceFirst(foo, b));
  -assertEquals(f, StringUtils.sliceFirst(foot, o));
  -assertEquals(, StringUtils.sliceFirst(abc, a));
  -assertEquals(a, StringUtils.sliceFirst(abcba, b));
  -assertEquals(ab, StringUtils.sliceFirst(abc, c));
  -assertEquals(, StringUtils.sliceFirst(abc, ));
  -}
  -
  -public void testSliceFirstRemainder_StringString() {
  -assertEquals(barXXbaz, StringUtils.sliceFirstRemainder(fooXXbarXXbaz, 
XX));
  -
  -assertEquals(null, StringUtils.sliceFirstRemainder(null, null));
  -  

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-24 Thread scolebourne
scolebourne2003/07/24 17:50:01

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Update slice methods to be more consistent
  from Phil Steitz
  
  Revision  ChangesPath
  1.38  +5 -7  
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- StringUtilsTest.java  22 Jul 2003 23:36:39 -  1.37
  +++ StringUtilsTest.java  25 Jul 2003 00:50:00 -  1.38
  @@ -649,13 +649,12 @@
   assertEquals(, StringUtils.sliceFirst(, XX));
   
   assertEquals(foo, StringUtils.sliceFirst(foo, null));
  -assertEquals(, StringUtils.sliceFirst(foo, b));
  +assertEquals(foo, StringUtils.sliceFirst(foo, b));
   assertEquals(f, StringUtils.sliceFirst(foot, o));
   assertEquals(, StringUtils.sliceFirst(abc, a));
   assertEquals(a, StringUtils.sliceFirst(abcba, b));
   assertEquals(ab, StringUtils.sliceFirst(abc, c));
  -assertEquals(abc, StringUtils.sliceFirst(abc, ));
  -assertEquals(, StringUtils.sliceFirst(abc, d));
  +assertEquals(, StringUtils.sliceFirst(abc, ));
   }
   
   public void testSliceFirstRemainder_StringString() {
  @@ -669,13 +668,12 @@
   assertEquals(, StringUtils.sliceFirstRemainder(, XX));
   
   assertEquals(, StringUtils.sliceFirstRemainder(foo, null));
  -assertEquals(foo, StringUtils.sliceFirstRemainder(foo, b));
   assertEquals(ot, StringUtils.sliceFirstRemainder(foot, o));
   assertEquals(bc, StringUtils.sliceFirstRemainder(abc, a));
   assertEquals(cba, StringUtils.sliceFirstRemainder(abcba, b));
   assertEquals(, StringUtils.sliceFirstRemainder(abc, c));
  -assertEquals(, StringUtils.sliceFirstRemainder(abc, ));
  -assertEquals(abc, StringUtils.sliceFirstRemainder(abc, d));
  +assertEquals(abc, StringUtils.sliceFirstRemainder(abc, ));
  +assertEquals(, StringUtils.sliceFirstRemainder(abc, d));
   }
   
   //---
  
  
  
  1.78  +34 -43
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- StringUtils.java  22 Jul 2003 23:36:40 -  1.77
  +++ StringUtils.java  25 Jul 2003 00:50:00 -  1.78
  @@ -2438,8 +2438,6 @@
* pA codenull/code string input will return codenull/code.
* An empty () string input will return the empty string.
* An empty or codenull/code separator will return the input string./p
  - *
  - * pThis method is the opposite of [EMAIL PROTECTED] #sliceRemainder(String, 
String)}./p
* 
* pre
* StringUtils.slice(null, *)  = null
  @@ -2462,12 +2460,11 @@
   if (str == null || separator == null || str.length() == 0 || 
separator.length() == 0) {
   return str;
   }
  -int idx = str.lastIndexOf(separator);
  -if (idx != -1) {
  -return str.substring(0, idx);
  -} else {
  +int pos = str.lastIndexOf(separator);
  +if (pos == -1) {
   return str;
   }
  +return str.substring(0, pos);
   }
   
   /**
  @@ -2476,9 +2473,8 @@
*
* pA codenull/code string input will return codenull/code.
* An empty () string input will return the empty string.
  - * An empty or codenull/code separator will return the empty string./p
  - * 
  - * pThis method is the opposite of [EMAIL PROTECTED] #slice(String, 
String)}./p
  + * An empty or codenull/code separator will return the empty string if
  + * the input string is not codenull/code./p
*
* pre
* StringUtils.sliceRemainder(null, *) = null
  @@ -2506,14 +2502,11 @@
   if (separator == null || separator.length() == 0) {
   return ;
   }
  -int idx = str.lastIndexOf(separator);
  -if (idx == str.length() - separator.length()) {
  -return ;
  -} else if (idx != -1) {
  -return str.substring(idx + separator.length());
  -} else {
  +int pos = str.lastIndexOf(separator);
  +if (pos == -1 || pos == (str.length() - separator.length())) {
   return ;
   }
  +return 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-20 Thread scolebourne
scolebourne2003/07/20 03:29:22

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add new method center(String, int, char) to complete API
  Rework padding internals
  Example javadoc difference()/differenceAt()
  Remove dependency on NumberUtils
  
  Revision  ChangesPath
  1.32  +225 -186  
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- StringUtilsTest.java  20 Jul 2003 00:17:29 -  1.31
  +++ StringUtilsTest.java  20 Jul 2003 10:29:21 -  1.32
  @@ -279,7 +279,7 @@
   assertEquals(a, res[0]);
   }
   
  -public void testSplit() {
  +public void testSplit_StringString_StringStringInt() {
   assertEquals(null, StringUtils.split(null, .));
   assertEquals(null, StringUtils.split(null, ., 3));
   
  @@ -298,47 +298,43 @@
   }
   
   private void innerTestSplit(char separator, String sepStr, char noMatch) {
  -try {
  -final String str = a + separator + b + separator + separator + 
noMatch + c;
  -String[] res;
  -// (str, sepStr)
  -res = StringUtils.split(str, sepStr);
  -assertEquals(3, res.length);
  -assertEquals(a, res[0]);
  -assertEquals(b, res[1]);
  -assertEquals(noMatch + c, res[2]);
  -
  -final String str2 = separator + a + separator;
  -res = StringUtils.split(str2, sepStr);
  -assertEquals(1, res.length);
  -assertEquals(a, res[0]);
  -
  -res = StringUtils.split(str, sepStr, -1);
  -assertEquals(3, res.length);
  -assertEquals(a, res[0]);
  -assertEquals(b, res[1]);
  -assertEquals(noMatch + c, res[2]);
  -
  -res = StringUtils.split(str, sepStr, 0);
  -assertEquals(3, res.length);
  -assertEquals(a, res[0]);
  -assertEquals(b, res[1]);
  -assertEquals(noMatch + c, res[2]);
  -
  -res = StringUtils.split(str, sepStr, 1);
  -assertEquals(1, res.length);
  -assertEquals(str, res[0]);
  -
  -res = StringUtils.split(str, sepStr, 2);
  -assertEquals(2, res.length);
  -assertEquals(a, res[0]);
  -assertEquals(str.substring(2), res[1]);
  -
  -} catch (AssertionFailedError ex) {
  -System.out.println(Failed on separator hex( + 
Integer.toHexString(separator) +
  - ), noMatch hex( + Integer.toHexString(noMatch) + ), sepStr( + 
sepStr + ));
  -throw ex;
  -}
  +String msg = Failed on separator hex( + Integer.toHexString(separator) +
  +), noMatch hex( + Integer.toHexString(noMatch) + ), sepStr( + 
sepStr + );
  +
  +final String str = a + separator + b + separator + separator + noMatch 
+ c;
  +String[] res;
  +// (str, sepStr)
  +res = StringUtils.split(str, sepStr);
  +assertEquals(msg, 3, res.length);
  +assertEquals(msg, a, res[0]);
  +assertEquals(msg, b, res[1]);
  +assertEquals(msg, noMatch + c, res[2]);
  +
  +final String str2 = separator + a + separator;
  +res = StringUtils.split(str2, sepStr);
  +assertEquals(msg, 1, res.length);
  +assertEquals(msg, a, res[0]);
  +
  +res = StringUtils.split(str, sepStr, -1);
  +assertEquals(msg, 3, res.length);
  +assertEquals(msg, a, res[0]);
  +assertEquals(msg, b, res[1]);
  +assertEquals(msg, noMatch + c, res[2]);
  +
  +res = StringUtils.split(str, sepStr, 0);
  +assertEquals(msg, 3, res.length);
  +assertEquals(msg, a, res[0]);
  +assertEquals(msg, b, res[1]);
  +assertEquals(msg, noMatch + c, res[2]);
  +
  +res = StringUtils.split(str, sepStr, 1);
  +assertEquals(msg, 1, res.length);
  +assertEquals(msg, str, res[0]);
  +
  +res = StringUtils.split(str, sepStr, 2);
  +assertEquals(msg, 2, res.length);
  +assertEquals(msg, a, res[0]);
  +assertEquals(msg, str.substring(2), res[1]);
   }
   
   public void testDeleteSpace_String() {
  @@ -433,7 +429,7 @@
   } catch (IndexOutOfBoundsException ex) {}
   }
   
  -public void testRepeat() {
  +public void testRepeat_StringInt() {
   assertEquals(null, StringUtils.repeat(null, 2));
   assertEquals(, 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-20 Thread scolebourne
scolebourne2003/07/20 07:47:29

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add summary javadoc section to StringUtils class
  Rename reverseDelimitedString to reverseDelimited
  
  Revision  ChangesPath
  1.33  +7 -7  
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- StringUtilsTest.java  20 Jul 2003 10:29:21 -  1.32
  +++ StringUtilsTest.java  20 Jul 2003 14:47:29 -  1.33
  @@ -704,12 +704,12 @@
   assertEquals(sdrawkcab, StringUtils.reverse(backwards) );
   }
   
  -public void testReverseDelimitedString_StringChar() {
  -assertEquals(null, StringUtils.reverseDelimitedString(null, '.') );
  -assertEquals(, StringUtils.reverseDelimitedString(, '.') );
  -assertEquals(c.b.a, StringUtils.reverseDelimitedString(a.b.c, '.') );
  -assertEquals(a b c, StringUtils.reverseDelimitedString(a b c, '.') );
  -assertEquals(, StringUtils.reverseDelimitedString(, '.') );
  +public void testReverseDelimited_StringChar() {
  +assertEquals(null, StringUtils.reverseDelimited(null, '.') );
  +assertEquals(, StringUtils.reverseDelimited(, '.') );
  +assertEquals(c.b.a, StringUtils.reverseDelimited(a.b.c, '.') );
  +assertEquals(a b c, StringUtils.reverseDelimited(a b c, '.') );
  +assertEquals(, StringUtils.reverseDelimited(, '.') );
   }
   
   public void testReverseDelimitedString_StringString() {
  
  
  
  1.72  +54 -8 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- StringUtils.java  20 Jul 2003 10:29:22 -  1.71
  +++ StringUtils.java  20 Jul 2003 14:47:29 -  1.72
  @@ -60,6 +60,51 @@
   /**
* pCommon codeString/code manipulation routines that are 
* codenull/code safe./p
  + * 
  + * ul
  + *  libIsEmpty/IsBlank/b
  + *  - checks if a String contains text
  + *  libTrim/Strip/b
  + *  - remove leading and trailing whitespace
  + *  libEquals/b
  + *  - compare two strings null-safe
  + *  libIndexOf/LastIndexOf/Contains/b
  + *  - null-safe index of checks
  + *  libIndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut/b
  + *  - index of any of a set of Strings
  + *  libContainsOnly/ContainsNone/b
  + *  - does String contain only/none of these characters
  + *  libSubString/Left/Right/Mid/b
  + *  - null-safe substring extraction
  + *  libSplit/b
  + *  - splits a String into an array of subtrings based on a separator
  + *  libJoin/Concatenate/b
  + *  - joins an array of Strings into one with optional separator
  + *  libReplace/Delete/Overlay/b
  + *  - Searches a String and replaces one String with another
  + *  libChomp/Chop/Slice/b
  + *  - searches a String and returns the substring before/after the separator
  + *  libLeftPad/RightPad/Center/Repeat/b
  + *  - pads a String
  + *  libUpperCase/LowerCase/SwapCase/Capitalise/Uncapitalise/b
  + *  - change the case of a String
  + *  libNestedString/b
  + *  - returns a substring nested within other Strings
  + *  libCountMatches/b
  + *  - counts the number of occurrances of one String in another
  + *  libIsAlpha/IsNumeric/IsWhitespace/b
  + *  - checks the characters in a String
  + *  libDefaultString/b
  + *  - protects against a null input String
  + *  libReverse/ReverseDelimited/b
  + *  - reverses a String
  + *  libAbbreviate/b
  + *  - abbreviates a string using ellipsis
  + *  libDifference/b
  + *  - compares two Strings and reports on their differences
  + *  libLevensteinDistance/b
  + *  - the number of changes needed to change one String into another
  + * /ul
*
* pThe codeStringUtils/code class defines certain words related to
* String handling./p
  @@ -67,8 +112,9 @@
* ul
*  linull - codenull/code
*  liempty - a zero-length string (code/code)
  - *  lispace - the space character (code' '/code)(32)
  + *  lispace - the space character (code' '/code)(char 32)
*  liwhitespace - the characters defined by [EMAIL PROTECTED] 
Character#isWhitespace(char)}
  + *  litrim - the characters lt;= 32 as in [EMAIL PROTECTED] String#trim(String)}
* /ul
* 
* pcodeStringUtils/code handles codenull/code input Strings quietly.
  @@ 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-20 Thread scolebourne
scolebourne2003/07/20 08:29:45

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsSubstringTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add more javadoc example code
  Ensure empty string behaviour documented in example code
  
  Revision  ChangesPath
  1.6   +9 -5  
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java
  
  Index: StringUtilsSubstringTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StringUtilsSubstringTest.java 18 Jul 2003 02:06:23 -  1.5
  +++ StringUtilsSubstringTest.java 20 Jul 2003 15:29:44 -  1.6
  @@ -207,17 +207,21 @@
StringUtils.countMatches(, ooo));
   }
   
  -public void testGetNestedString() {
  +public void testGetNestedString_StringString() {
   assertEquals(null, StringUtils.getNestedString(null, tag));
  +assertEquals(, StringUtils.getNestedString(, ));
  +assertEquals(null, StringUtils.getNestedString(, abc));
  +assertEquals(, StringUtils.getNestedString(,  ));
   assertEquals(null, StringUtils.getNestedString(abc, null));
   assertEquals(, StringUtils.getNestedString(abc, ));
   assertEquals(null, StringUtils.getNestedString(abc, a));
   assertEquals(bc, StringUtils.getNestedString(abca, a));
   assertEquals(bc, StringUtils.getNestedString(abcabca, a));
  -assertEquals(, StringUtils.getNestedString(, ));
  -assertEquals(, StringUtils.getNestedString(,  ));
   assertEquals(bar, StringUtils.getNestedString(\nbar\n, \n));
  -
  +}
  +
  +public void testGetNestedString_StringStringString() {
  +assertEquals(null, StringUtils.getNestedString(null, , ));
   assertEquals(, StringUtils.getNestedString(, , ));
   assertEquals(, StringUtils.getNestedString(,  ,   ));
   assertEquals(bar, StringUtils.getNestedString(foobar/foo, foo, 
/foo) );
  
  
  
  1.73  +177 -52   
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- StringUtils.java  20 Jul 2003 14:47:29 -  1.72
  +++ StringUtils.java  20 Jul 2003 15:29:44 -  1.73
  @@ -297,10 +297,10 @@
* 
* pre
* StringUtils.clean(null)  = 
  + * StringUtils.clean()= 
* StringUtils.clean(abc) = abc
* StringUtils.clean(abc) = abc
* StringUtils.clean( )   = 
  - * StringUtils.clean()= 
* /pre
*
* @see java.lang.String#trim()
  @@ -327,10 +327,10 @@
* 
* pre
* StringUtils.trim(null)  = null
  + * StringUtils.trim()= 
  + * StringUtils.trim( )   = 
* StringUtils.trim(abc) = abc
* StringUtils.trim(abc) = abc
  - * StringUtils.trim( )   = 
  - * StringUtils.trim()= 
* /pre
*
* @param str  the String to be trimmed, may be null
  @@ -351,10 +351,10 @@
* 
* pre
* StringUtils.trimToNull(null)  = null
  + * StringUtils.trimToNull()= null
  + * StringUtils.trimToNull( )   = null
* StringUtils.trimToNull(abc) = abc
* StringUtils.trimToNull(abc) = abc
  - * StringUtils.trimToNull( )   = null
  - * StringUtils.trimToNull()= null
* /pre
*  
* @param str  the String to be trimmed, may be null
  @@ -377,10 +377,10 @@
* 
* pre
* StringUtils.trimToEmpty(null)  = 
  + * StringUtils.trimToEmpty()= 
  + * StringUtils.trimToEmpty( )   = 
* StringUtils.trimToEmpty(abc) = abc
* StringUtils.trimToEmpty(abc) = abc
  - * StringUtils.trimToEmpty( )   = 
  - * StringUtils.trimToEmpty()= 
* /pre
*  
* @param str  the String to be trimmed, may be null
  @@ -487,6 +487,7 @@
* 
* pre
* StringUtils.strip(null, null)   = null
  + * StringUtils.strip(, null) = 
* StringUtils.strip(abc, null)  = abc
* StringUtils.strip(  abc, null)= abc
* StringUtils.strip(abc  , null)= abc
  @@ -515,12 +516,14 @@
* stripped as defined by [EMAIL PROTECTED] 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-20 Thread scolebourne
scolebourne2003/07/20 16:57:26

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsEqualsIndexOfTest.java
StringUtilsTest.java StringUtilsSubstringTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Update Javadoc and tests
  bug 21750, from Phil Steitz
  
  Revision  ChangesPath
  1.4   +41 -3 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java
  
  Index: StringUtilsEqualsIndexOfTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StringUtilsEqualsIndexOfTest.java 19 Jul 2003 23:29:06 -  1.3
  +++ StringUtilsEqualsIndexOfTest.java 20 Jul 2003 23:57:26 -  1.4
  @@ -63,6 +63,7 @@
*
* @author a href=mailto:[EMAIL PROTECTED]Stephen Colebourne/a
* @author a href=mailto:[EMAIL PROTECTED]Ringo De Smet/a
  + * @author Phil Steitz
* @version $Id$
*/
   public class StringUtilsEqualsIndexOfTest extends TestCase {
  @@ -142,6 +143,7 @@
   assertEquals(0, StringUtils.indexOf(aabaabaa, a));
   assertEquals(2, StringUtils.indexOf(aabaabaa, b));
   assertEquals(1, StringUtils.indexOf(aabaabaa, ab));
  +assertEquals(0, StringUtils.indexOf(aabaabaa, ));
   }
   
   public void testIndexOf_StringInt() {
  @@ -163,6 +165,7 @@
   assertEquals(5, StringUtils.indexOf(aabaabaa, b, 3));
   assertEquals(-1, StringUtils.indexOf(aabaabaa, b, 9));
   assertEquals(2, StringUtils.indexOf(aabaabaa, b, -1));
  +assertEquals(2,StringUtils.indexOf(aabaabaa, , 2)); 
   }
   
   //---
  @@ -183,12 +186,15 @@
   assertEquals(2, StringUtils.lastIndexOf(aabaabaa, 'b', 3));
   assertEquals(5, StringUtils.lastIndexOf(aabaabaa, 'b', 9));
   assertEquals(-1, StringUtils.lastIndexOf(aabaabaa, 'b', -1));
  +assertEquals(0, StringUtils.lastIndexOf(aabaabaa, 'a', 0));
   }
   
   public void testLastIndexOf_String() {
   assertEquals(-1, StringUtils.lastIndexOf(null, null));
   assertEquals(-1, StringUtils.lastIndexOf(, null));
  +assertEquals(-1, StringUtils.lastIndexOf(, a));
   assertEquals(0, StringUtils.lastIndexOf(, ));
  +assertEquals(8, StringUtils.lastIndexOf(aabaabaa, ));
   assertEquals(7, StringUtils.lastIndexOf(aabaabaa, a));
   assertEquals(5, StringUtils.lastIndexOf(aabaabaa, b));
   assertEquals(4, StringUtils.lastIndexOf(aabaabaa, ab));
  @@ -213,19 +219,23 @@
   assertEquals(2, StringUtils.lastIndexOf(aabaabaa, b, 3));
   assertEquals(5, StringUtils.lastIndexOf(aabaabaa, b, 9));
   assertEquals(-1, StringUtils.lastIndexOf(aabaabaa, b, -1));
  +assertEquals(-1, StringUtils.lastIndexOf(aabaabaa, b, 0));
  +assertEquals(0, StringUtils.lastIndexOf(aabaabaa, a, 0));
   }
   
   //---
  -public void contains_char() {
  +public void testContainsChar() {
   assertEquals(false, StringUtils.contains(null, ' '));
   assertEquals(false, StringUtils.contains(, ' '));
  +assertEquals(false, StringUtils.contains(,null));
  +assertEquals(false, StringUtils.contains(null,null));
   assertEquals(true, StringUtils.contains(abc, 'a'));
   assertEquals(true, StringUtils.contains(abc, 'b'));
   assertEquals(true, StringUtils.contains(abc, 'c'));
   assertEquals(false, StringUtils.contains(abc, 'z'));
   }
   
  -public void contains_String() {
  +public void testContainsString() {
   assertEquals(false, StringUtils.contains(null, null));
   assertEquals(false, StringUtils.contains(null, ));
   assertEquals(false, StringUtils.contains(null, a));
  @@ -246,7 +256,15 @@
   assertEquals(-1, StringUtils.indexOfAny(FOOBAR, null));
   assertEquals(2, StringUtils.indexOfAny(FOOBAR, FOOBAR_SUB_ARRAY));
   assertEquals(-1, StringUtils.indexOfAny(FOOBAR, new String[0]));
  +assertEquals(-1, StringUtils.indexOfAny(null, new String[0]));
  +assertEquals(-1, StringUtils.indexOfAny(, new String[0]));
   assertEquals(-1, StringUtils.indexOfAny(FOOBAR, new String[] {}));
  +assertEquals(0, StringUtils.indexOfAny(FOOBAR, new String[] {}));
  +assertEquals(0, StringUtils.indexOfAny(, new String[] {}));
  +assertEquals(-1, StringUtils.indexOfAny(, new String[] {a}));
  +assertEquals(-1, StringUtils.indexOfAny(, new String[] {null}));
  +assertEquals(-1, StringUtils.indexOfAny(FOOBAR, new String[] {null}));
  +

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-20 Thread scolebourne
scolebourne2003/07/20 17:41:13

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsSubstringTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Update Javadoc examples
  Change mid() to accept invalid startPos
  
  Revision  ChangesPath
  1.8   +20 -47
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java
  
  Index: StringUtilsSubstringTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StringUtilsSubstringTest.java 20 Jul 2003 23:57:26 -  1.7
  +++ StringUtilsSubstringTest.java 21 Jul 2003 00:41:13 -  1.8
  @@ -127,7 +127,8 @@
   assertEquals(null, StringUtils.substring(null,1,2));
   }
  
  -public void testLeft() {
  +public void testLeft_String() {
  +assertSame(null, StringUtils.left(null, -1));
   assertSame(null, StringUtils.left(null, 0));
   assertSame(null, StringUtils.left(null, 2));
   assertSame(, StringUtils.left(, 0));
  @@ -135,18 +136,14 @@
   assertEquals(, StringUtils.left(FOOBAR, 0));
   assertEquals(FOO, StringUtils.left(FOOBAR, 3));
   assertSame(FOOBAR, StringUtils.left(FOOBAR, 80));
  -}
  -
  -public void testLeftEx() {
   try {
   StringUtils.left(FOOBAR, -1);
  -} catch (IllegalArgumentException ex) {
  -return;
  -}
  -fail();
  +fail();
  +} catch (IllegalArgumentException ex) {}
   }
  -
  -public void testRight() {
  +
  +public void testRight_String() {
  +assertSame(null, StringUtils.right(null, -1));
   assertSame(null, StringUtils.right(null, 0));
   assertSame(null, StringUtils.right(null, 2));
   assertSame(, StringUtils.right(, 0));
  @@ -154,18 +151,15 @@
   assertEquals(, StringUtils.right(FOOBAR, 0));
   assertEquals(BAR, StringUtils.right(FOOBAR, 3));
   assertSame(FOOBAR, StringUtils.right(FOOBAR, 80));
  -}
  -
  -public void testRightEx() {
   try {
   StringUtils.right(FOOBAR, -1);
  -} catch (IllegalArgumentException ex) {
  -return;
  -}
  -fail();
  +fail();
  +} catch (IllegalArgumentException ex) {}
   }
  -
  -public void testMid() {
  +
  +public void testMid_String() {
  +assertSame(null, StringUtils.mid(null, -1, 0));
  +assertSame(null, StringUtils.mid(null, 0, -1));
   assertSame(null, StringUtils.mid(null, 3, 0));
   assertSame(null, StringUtils.mid(null, 3, 2));
   assertSame(, StringUtils.mid(, 0, 0));
  @@ -176,36 +170,15 @@
   assertEquals(BAR, StringUtils.mid(FOOBAR, 3, 3));
   assertEquals(FOOBAR, StringUtils.mid(FOOBAR, 0, 80));
   assertEquals(BAR, StringUtils.mid(FOOBAR, 3, 80));
  -}
  -
  -public void testMidEx1() {
  +assertEquals(, StringUtils.mid(FOOBAR, 9, 3));
  +assertEquals(FOO, StringUtils.mid(FOOBAR, -1, 3));
   try {
   StringUtils.mid(FOOBAR, 0, -1);
  -} catch (IllegalArgumentException ex) {
  -return;
  -}
  -fail();
  -}
  -
  -public void testMidEx2() {
  -try {
  -StringUtils.mid(FOOBAR, -1, 3);
  -} catch (IndexOutOfBoundsException ex) {
  -return;
  -}
  -fail();
  +fail();
  +} catch (IllegalArgumentException ex) {}
   }
  -
  -public void testMidEx3() {
  -try {
  -StringUtils.mid(FOOBAR, 7, 3);
  -} catch (IndexOutOfBoundsException ex) {
  -return;
  -}
  -fail();
  -}
  -
  -public void testCountMatches() {
  +
  +public void testCountMatches_String() {
   assertEquals(0, StringUtils.countMatches(null, null));
   assertEquals(0, StringUtils.countMatches(blah, null));
   assertEquals(0, StringUtils.countMatches(null, DD));
  
  
  
  1.76  +90 -83
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- StringUtils.java  20 Jul 2003 23:57:26 -  1.75
  +++ StringUtils.java  21 Jul 2003 00:41:13 -  1.76
  @@ -125,6 +125,9 @@
* pA side effect of the codenull/code handling is that a 
* NullPointerException should be considered a bug in codeStringUtils/code.
* (Except 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 16:29:07

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsEqualsIndexOfTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add new methods for null-safe indexOf/lastIndexOf
  Add new methods for contains
  
  Revision  ChangesPath
  1.3   +250 -1
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java
  
  Index: StringUtilsEqualsIndexOfTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StringUtilsEqualsIndexOfTest.java 23 Mar 2003 21:50:58 -  1.2
  +++ StringUtilsEqualsIndexOfTest.java 19 Jul 2003 23:29:06 -  1.3
  @@ -115,6 +115,131 @@
   assertEquals(false, StringUtils.equalsIgnoreCase(null, FOO));
   }
   
  +//---
  +public void testIndexOf_char() {
  +assertEquals(-1, StringUtils.indexOf(null, ' '));
  +assertEquals(-1, StringUtils.indexOf(, ' '));
  +assertEquals(0, StringUtils.indexOf(aabaabaa, 'a'));
  +assertEquals(2, StringUtils.indexOf(aabaabaa, 'b'));
  +}
  +
  +public void testIndexOf_charInt() {
  +assertEquals(-1, StringUtils.indexOf(null, ' ', 0));
  +assertEquals(-1, StringUtils.indexOf(null, ' ', -1));
  +assertEquals(-1, StringUtils.indexOf(, ' ', 0));
  +assertEquals(-1, StringUtils.indexOf(, ' ', -1));
  +assertEquals(0, StringUtils.indexOf(aabaabaa, 'a', 0));
  +assertEquals(2, StringUtils.indexOf(aabaabaa, 'b', 0));
  +assertEquals(5, StringUtils.indexOf(aabaabaa, 'b', 3));
  +assertEquals(-1, StringUtils.indexOf(aabaabaa, 'b', 9));
  +assertEquals(2, StringUtils.indexOf(aabaabaa, 'b', -1));
  +}
  +
  +public void testIndexOf_String() {
  +assertEquals(-1, StringUtils.indexOf(null, null));
  +assertEquals(-1, StringUtils.indexOf(, null));
  +assertEquals(0, StringUtils.indexOf(, ));
  +assertEquals(0, StringUtils.indexOf(aabaabaa, a));
  +assertEquals(2, StringUtils.indexOf(aabaabaa, b));
  +assertEquals(1, StringUtils.indexOf(aabaabaa, ab));
  +}
  +
  +public void testIndexOf_StringInt() {
  +assertEquals(-1, StringUtils.indexOf(null, null, 0));
  +assertEquals(-1, StringUtils.indexOf(null, null, -1));
  +assertEquals(-1, StringUtils.indexOf(null, , 0));
  +assertEquals(-1, StringUtils.indexOf(null, , -1));
  +assertEquals(-1, StringUtils.indexOf(, null, 0));
  +assertEquals(-1, StringUtils.indexOf(, null, -1));
  +assertEquals(0, StringUtils.indexOf(, , 0));
  +assertEquals(0, StringUtils.indexOf(, , -1));
  +assertEquals(0, StringUtils.indexOf(, , 9));
  +assertEquals(0, StringUtils.indexOf(abc, , 0));
  +assertEquals(0, StringUtils.indexOf(abc, , -1));
  +assertEquals(3, StringUtils.indexOf(abc, , 9));
  +assertEquals(0, StringUtils.indexOf(aabaabaa, a, 0));
  +assertEquals(2, StringUtils.indexOf(aabaabaa, b, 0));
  +assertEquals(1, StringUtils.indexOf(aabaabaa, ab, 0));
  +assertEquals(5, StringUtils.indexOf(aabaabaa, b, 3));
  +assertEquals(-1, StringUtils.indexOf(aabaabaa, b, 9));
  +assertEquals(2, StringUtils.indexOf(aabaabaa, b, -1));
  +}
  +
  +//---
  +public void testLastIndexOf_char() {
  +assertEquals(-1, StringUtils.lastIndexOf(null, ' '));
  +assertEquals(-1, StringUtils.lastIndexOf(, ' '));
  +assertEquals(7, StringUtils.lastIndexOf(aabaabaa, 'a'));
  +assertEquals(5, StringUtils.lastIndexOf(aabaabaa, 'b'));
  +}
  +
  +public void testLastIndexOf_charInt() {
  +assertEquals(-1, StringUtils.lastIndexOf(null, ' ', 0));
  +assertEquals(-1, StringUtils.lastIndexOf(null, ' ', -1));
  +assertEquals(-1, StringUtils.lastIndexOf(, ' ', 0));
  +assertEquals(-1, StringUtils.lastIndexOf(, ' ', -1));
  +assertEquals(7, StringUtils.lastIndexOf(aabaabaa, 'a', 8));
  +assertEquals(5, StringUtils.lastIndexOf(aabaabaa, 'b', 8));
  +assertEquals(2, StringUtils.lastIndexOf(aabaabaa, 'b', 3));
  +assertEquals(5, StringUtils.lastIndexOf(aabaabaa, 'b', 9));
  +assertEquals(-1, StringUtils.lastIndexOf(aabaabaa, 'b', -1));
  +}
  +
  +public void testLastIndexOf_String() {
  +assertEquals(-1, StringUtils.lastIndexOf(null, null));
  +assertEquals(-1, StringUtils.lastIndexOf(, null));
  +assertEquals(0, StringUtils.lastIndexOf(, ));
  +assertEquals(7, 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 17:04:12

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsTrimEmptyTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add new methods stripToNull/stripToEmpty to provide alternative to trim versions
  
  Revision  ChangesPath
  1.13  +21 -1 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
  
  Index: StringUtilsTrimEmptyTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- StringUtilsTrimEmptyTest.java 19 Jul 2003 21:55:05 -  1.12
  +++ StringUtilsTrimEmptyTest.java 20 Jul 2003 00:04:12 -  1.13
  @@ -199,6 +199,26 @@
   StringUtils.strip(StringUtilsTest.WHITESPACE + 
StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE));
   }
   
  +public void testStripToNull_String() {
  +assertEquals(null, StringUtils.stripToNull(null));
  +assertEquals(null, StringUtils.stripToNull());
  +assertEquals(null, StringUtils.stripToNull());
  +assertEquals(null, StringUtils.stripToNull(StringUtilsTest.WHITESPACE));
  +assertEquals(ab c, StringUtils.stripToNull(  ab c  ));
  +assertEquals(StringUtilsTest.NON_WHITESPACE, 
  +StringUtils.stripToNull(StringUtilsTest.WHITESPACE + 
StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE));
  +}
  +
  +public void testStripToEmpty_String() {
  +assertEquals(, StringUtils.stripToEmpty(null));
  +assertEquals(, StringUtils.stripToEmpty());
  +assertEquals(, StringUtils.stripToEmpty());
  +assertEquals(, StringUtils.stripToEmpty(StringUtilsTest.WHITESPACE));
  +assertEquals(ab c, StringUtils.stripToEmpty(  ab c  ));
  +assertEquals(StringUtilsTest.NON_WHITESPACE, 
  +StringUtils.stripToEmpty(StringUtilsTest.WHITESPACE + 
StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE));
  +}
  +
   public void testStrip_StringString() {
   // null strip
   assertEquals(null, StringUtils.strip(null, null));
  
  
  
  1.68  +70 -9 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- StringUtils.java  19 Jul 2003 23:29:06 -  1.67
  +++ StringUtils.java  20 Jul 2003 00:04:12 -  1.68
  @@ -179,7 +179,8 @@
* codenull/code./p
* 
* pThe String is trimmed using [EMAIL PROTECTED] String#trim()}.
  - * Trim removes start and end characters lt;= 32./p
  + * Trim removes start and end characters lt;= 32.
  + * To strip whitespace use [EMAIL PROTECTED] #strip(String)}./p
* 
* pTo trim your choice of characters, use the
* [EMAIL PROTECTED] #strip(String, String)} methods./p
  @@ -192,7 +193,6 @@
* StringUtils.trim()= 
* /pre
*
  - * @see java.lang.String#trim()
* @param str  the String to be trimmed, may be null
* @return the trimmed string, codenull/code if null String input
*/
  @@ -206,7 +206,8 @@
* empty () after the trim or if it is codenull/code.
* 
* pThe String is trimmed using [EMAIL PROTECTED] String#trim()}.
  - * Trim removes start and end characters lt;= 32./p
  + * Trim removes start and end characters lt;= 32.
  + * To strip whitespace use [EMAIL PROTECTED] #stripToNull(String)}./p
* 
* pre
* StringUtils.trimToNull(null)  = null
  @@ -216,7 +217,6 @@
* StringUtils.trimToNull()= null
* /pre
*  
  - * @see java.lang.String#trim()
* @param str  the String to be trimmed, may be null
* @return the trimmed String, 
*  codenull/code if only chars lt;= 32, empty or null String input
  @@ -232,7 +232,8 @@
* is empty () after the trim or if it is codenull/code.
* 
* pThe String is trimmed using [EMAIL PROTECTED] String#trim()}.
  - * Trim removes start and end characters lt;= 32./p
  + * Trim removes start and end characters lt;= 32.
  + * To strip whitespace use [EMAIL PROTECTED] #stripToEmpty(String)}./p
* 
* pre
* StringUtils.trimToEmpty(null)  = 
  @@ -242,7 +243,6 @@
* StringUtils.trimToEmpty()= 
* /pre
*  
  - * @see java.lang.String#trim()
* @param str  the String to be trimmed, may be null
* @return the 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 17:17:30

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsTrimEmptyTest.java StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Deprecate deleteSpaces()
  Move delete methods next to replace
  
  Revision  ChangesPath
  1.14  +1 -21 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
  
  Index: StringUtilsTrimEmptyTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- StringUtilsTrimEmptyTest.java 20 Jul 2003 00:04:12 -  1.13
  +++ StringUtilsTrimEmptyTest.java 20 Jul 2003 00:17:29 -  1.14
  @@ -170,26 +170,6 @@
   assertEquals(true, StringUtils.isNotBlank(  foo  ));
   }
   
  -public void testDeleteSpace() {
  -assertEquals(null, StringUtils.deleteSpaces(null));
  -assertEquals(, StringUtils.deleteSpaces());
  -assertEquals(, StringUtils.deleteSpaces(\t\t\n\n   ));
  -assertEquals(test, StringUtils.deleteSpaces(t  \t\ne\rs\n\n   \tt));
  -}
  -
  -public void testDeleteWhitespace() {
  -assertEquals(null, StringUtils.deleteWhitespace(null));
  -assertEquals(, StringUtils.deleteWhitespace());
  -assertEquals(, StringUtils.deleteWhitespace(  \u000C  \t\t\u001F\n\n 
\u000B  ));
  -assertEquals(, StringUtils.deleteWhitespace(StringUtilsTest.WHITESPACE));
  -assertEquals(StringUtilsTest.NON_WHITESPACE, 
StringUtils.deleteWhitespace(StringUtilsTest.NON_WHITESPACE));
  -// Note: u-2007 and u-000A both cause problems in the source code
  -// it should ignore 2007 but delete 000A
  -assertEquals(\u00A0\u202F, StringUtils.deleteWhitespace(  \u00A0  
\t\t\n\n \u202F  ));
  -assertEquals(\u00A0\u202F, StringUtils.deleteWhitespace(\u00A0\u202F));
  -assertEquals(test, StringUtils.deleteWhitespace(\u000Bt  
\t\n\u0009e\rs\n\n   \tt));
  -}
  -
   public void testStrip_String() {
   assertEquals(null, StringUtils.strip(null));
   assertEquals(, StringUtils.strip());
  
  
  
  1.31  +73 -21
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- StringUtilsTest.java  19 Jul 2003 23:28:23 -  1.30
  +++ StringUtilsTest.java  20 Jul 2003 00:17:29 -  1.31
  @@ -341,26 +341,78 @@
   }
   }
   
  -public void testReplaceFunctions() {
  -assertEquals(replace(String, String, String, int) failed,
  - FOO, StringUtils.replace(oo + FOO, o, , 2));
  -assertEquals(replace(String, String, String) failed,
  - , StringUtils.replace(FOO + FOO + FOO, FOO, ));
  -assertEquals(replaceOnce(String, String, String) failed,
  - FOO, StringUtils.replaceOnce(FOO + FOO, FOO, ));
  -assertEquals(carriage-return replace(String,String,String) failed,
  - test123, StringUtils.replace(test\r1\r2\r3, \r, ));
  -
  -assertEquals(replace(String, String, String) failed,
  -FOO, StringUtils.replace(FOO, , any));
  -assertEquals(replace(String, String, String) failed,
  -FOO, StringUtils.replace(FOO, null, any));
  -assertEquals(replace(String, String, String) failed,
  -FOO, StringUtils.replace(FOO, F, null));
  -assertEquals(replace(String, String, String) failed,
  -FOO, StringUtils.replace(FOO, null, null));
  -assertEquals(replace(String, String, String) failed,
  -null, StringUtils.replace(null, , any));
  +public void testDeleteSpace_String() {
  +assertEquals(null, StringUtils.deleteSpaces(null));
  +assertEquals(, StringUtils.deleteSpaces());
  +assertEquals(, StringUtils.deleteSpaces(\t\t\n\n   ));
  +assertEquals(test, StringUtils.deleteSpaces(t  \t\ne\rs\n\n   \tt));
  +}
  +
  +public void testDeleteWhitespace_String() {
  +assertEquals(null, StringUtils.deleteWhitespace(null));
  +assertEquals(, StringUtils.deleteWhitespace());
  +assertEquals(, StringUtils.deleteWhitespace(  \u000C  \t\t\u001F\n\n 
\u000B  ));
  +assertEquals(, StringUtils.deleteWhitespace(StringUtilsTest.WHITESPACE));
  +assertEquals(StringUtilsTest.NON_WHITESPACE, 
StringUtils.deleteWhitespace(StringUtilsTest.NON_WHITESPACE));
  +// Note: u-2007 and u-000A 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-19 Thread scolebourne
scolebourne2003/07/19 17:37:09

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsTrimEmptyTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Group all the trim/strip methods together in source file
  
  Revision  ChangesPath
  1.15  +34 -33
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
  
  Index: StringUtilsTrimEmptyTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- StringUtilsTrimEmptyTest.java 20 Jul 2003 00:17:29 -  1.14
  +++ StringUtilsTrimEmptyTest.java 20 Jul 2003 00:37:09 -  1.15
  @@ -91,7 +91,39 @@
   }
   
   //---
  +public void testIsEmpty() {
  +assertEquals(true, StringUtils.isEmpty(null));
  +assertEquals(true, StringUtils.isEmpty());
  +assertEquals(false, StringUtils.isEmpty( ));
  +assertEquals(false, StringUtils.isEmpty(foo));
  +assertEquals(false, StringUtils.isEmpty(  foo  ));
  +}
  +
  +public void testIsNotEmpty() {
  +assertEquals(false, StringUtils.isNotEmpty(null));
  +assertEquals(false, StringUtils.isNotEmpty());
  +assertEquals(true, StringUtils.isNotEmpty( ));
  +assertEquals(true, StringUtils.isNotEmpty(foo));
  +assertEquals(true, StringUtils.isNotEmpty(  foo  ));
  +}
  +
  +public void testIsBlank() {
  +assertEquals(true, StringUtils.isBlank(null));
  +assertEquals(true, StringUtils.isBlank());
  +assertEquals(true, StringUtils.isBlank(StringUtilsTest.WHITESPACE));
  +assertEquals(false, StringUtils.isBlank(foo));
  +assertEquals(false, StringUtils.isBlank(  foo  ));
  +}
  +
  +public void testIsNotBlank() {
  +assertEquals(false, StringUtils.isNotBlank(null));
  +assertEquals(false, StringUtils.isNotBlank());
  +assertEquals(false, StringUtils.isNotBlank(StringUtilsTest.WHITESPACE));
  +assertEquals(true, StringUtils.isNotBlank(foo));
  +assertEquals(true, StringUtils.isNotBlank(  foo  ));
  +}
   
  +//---
   public void testClean() {
   assertEquals(FOO, StringUtils.clean(FOO +   ));
   assertEquals(FOO, StringUtils.clean(  + FOO +   ));
  @@ -138,38 +170,7 @@
   assertEquals(, StringUtils.trimToEmpty(null));
   }
   
  -public void testIsEmpty() {
  -assertEquals(true, StringUtils.isEmpty(null));
  -assertEquals(true, StringUtils.isEmpty());
  -assertEquals(false, StringUtils.isEmpty( ));
  -assertEquals(false, StringUtils.isEmpty(foo));
  -assertEquals(false, StringUtils.isEmpty(  foo  ));
  -}
  -
  -public void testIsNotEmpty() {
  -assertEquals(false, StringUtils.isNotEmpty(null));
  -assertEquals(false, StringUtils.isNotEmpty());
  -assertEquals(true, StringUtils.isNotEmpty( ));
  -assertEquals(true, StringUtils.isNotEmpty(foo));
  -assertEquals(true, StringUtils.isNotEmpty(  foo  ));
  -}
  -
  -public void testIsBlank() {
  -assertEquals(true, StringUtils.isBlank(null));
  -assertEquals(true, StringUtils.isBlank());
  -assertEquals(true, StringUtils.isBlank(StringUtilsTest.WHITESPACE));
  -assertEquals(false, StringUtils.isBlank(foo));
  -assertEquals(false, StringUtils.isBlank(  foo  ));
  -}
  -
  -public void testIsNotBlank() {
  -assertEquals(false, StringUtils.isNotBlank(null));
  -assertEquals(false, StringUtils.isNotBlank());
  -assertEquals(false, StringUtils.isNotBlank(StringUtilsTest.WHITESPACE));
  -assertEquals(true, StringUtils.isNotBlank(foo));
  -assertEquals(true, StringUtils.isNotBlank(  foo  ));
  -}
  -
  +//---
   public void testStrip_String() {
   assertEquals(null, StringUtils.strip(null));
   assertEquals(, StringUtils.strip());
  
  
  
  1.70  +321 -318  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- StringUtils.java  20 Jul 2003 00:17:29 -  1.69
  +++ StringUtils.java  20 Jul 2003 00:37:09 -  1.70
  @@ -147,7 +147,106 @@
   public StringUtils() {
   }
   
  -// Empty
  +// Empty 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-18 Thread scolebourne
scolebourne2003/07/18 16:57:43

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Fixed leftPad() and rightPad() to correctly handle multi letter pad strings
  
  Revision  ChangesPath
  1.27  +3 -1  
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- StringUtilsTest.java  18 Jul 2003 02:06:23 -  1.26
  +++ StringUtilsTest.java  18 Jul 2003 23:57:43 -  1.27
  @@ -315,6 +315,7 @@
   assertEquals( ab , StringUtils.center(ab, 4));
   assertEquals(abcd, StringUtils.center(abcd, 2));
   assertEquals( a  , StringUtils.center(a, 4));
  +assertEquals(  a  , StringUtils.center(a, 5));
   
   assertEquals(null, StringUtils.center(null, -1,  ));
   assertEquals(null, StringUtils.center(null, 4,  ));
  @@ -323,6 +324,7 @@
   assertEquals(abcd, StringUtils.center(abcd, 2,  ));
   assertEquals( a  , StringUtils.center(a, 4,  ));
   assertEquals(yayz, StringUtils.center(a, 4, yz));
  +assertEquals(yzyayzy, StringUtils.center(a, 7, yz));
   try {
   StringUtils.center(abc, 4, null);
   fail();
  
  
  
  1.63  +43 -16
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- StringUtils.java  18 Jul 2003 02:06:24 -  1.62
  +++ StringUtils.java  18 Jul 2003 23:57:43 -  1.63
  @@ -1967,18 +1967,31 @@
   if (str == null) {
   return null;
   }
  -if (padStr == null || padStr.length() == 0) {
  +int padLen;
  +if (padStr == null || (padLen = padStr.length()) == 0) {
   throw new IllegalArgumentException(Pad String must not be null or 
empty);
   }
  -if (padStr.length() == 1  size - str.length() = PAD_LIMIT) {
  -   return rightPad(str, size, padStr.charAt(0));
  +int strLen = str.length();
  +int pads = size - strLen;
  +if (padLen == 1  pads = PAD_LIMIT) {
  +return rightPad(str, size, padStr.charAt(0));
   }
  -
  -size = (size - str.length()) / padStr.length();
  -if (size  0) {
  -str += repeat(padStr, size);
  +
  +if (pads = 0) {
  +return str; // returns original String when possible
  +}
  +if (pads == padLen) {
  +return str.concat(padStr);
  +} else if (pads  padLen) {
  +return str.concat(padStr.substring(0, pads));
  +} else {
  +char[] padding = new char[pads];
  +char[] padChars = padStr.toCharArray();
  +for (int i = 0; i  pads; i++) {
  +padding[i] = padChars[i % padLen];
  +}
  +return str.concat(new String(padding));
   }
  -return str;
   }
   
   /**
  @@ -2041,7 +2054,7 @@
   return str; // returns original String when possible
   }
   if (pads  PAD_LIMIT) {
  -return leftPad(str, size, ' ');
  +return leftPad(str, size, String.valueOf(padChar));
   }
   return padding(pads, padChar).concat(str);
   }
  @@ -2073,17 +2086,31 @@
   if (str == null) {
   return null;
   }
  -if (padStr == null || padStr.length() == 0) {
  +int padLen;
  +if (padStr == null || (padLen = padStr.length()) == 0) {
   throw new IllegalArgumentException(Pad String must not be null or 
empty);
   }
  -if (padStr.length() == 1  size - str.length() = PAD_LIMIT) {
  +int strLen = str.length();
  +int pads = size - strLen;
  +if (padLen == 1  pads = PAD_LIMIT) {
   return leftPad(str, size, padStr.charAt(0));
   }
  -size = (size - str.length()) / padStr.length();
  -if (size  0) {
  -str = repeat(padStr, size) + str;
  +
  +if (pads = 0) {
  +return str; // returns original String when possible
  +}
  +if (pads == padLen) {
  +return padStr.concat(str);
  +} else if (pads  padLen) {
  +return padStr.substring(0, pads).concat(str);
  +} else {
  +char[] padding = new char[pads];
  +char[] padChars = 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-18 Thread scolebourne
scolebourne2003/07/18 17:22:51

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Minor performance tweaks, and some extra tests
  
  Revision  ChangesPath
  1.28  +20 -1 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- StringUtilsTest.java  18 Jul 2003 23:57:43 -  1.27
  +++ StringUtilsTest.java  19 Jul 2003 00:22:50 -  1.28
  @@ -311,6 +311,9 @@
   public void testCenter() {
   assertEquals(null, StringUtils.center(null, -1));
   assertEquals(null, StringUtils.center(null, 4));
  +assertEquals(ab, StringUtils.center(ab, 0));
  +assertEquals(ab, StringUtils.center(ab, -1));
  +assertEquals(ab, StringUtils.center(ab, 1));
   assertEquals(, StringUtils.center(, 4));
   assertEquals( ab , StringUtils.center(ab, 4));
   assertEquals(abcd, StringUtils.center(abcd, 2));
  @@ -319,6 +322,9 @@
   
   assertEquals(null, StringUtils.center(null, -1,  ));
   assertEquals(null, StringUtils.center(null, 4,  ));
  +assertEquals(ab, StringUtils.center(ab, 0,  ));
  +assertEquals(ab, StringUtils.center(ab, -1,  ));
  +assertEquals(ab, StringUtils.center(ab, 1,  ));
   assertEquals(, StringUtils.center(, 4,  ));
   assertEquals( ab , StringUtils.center(ab, 4,  ));
   assertEquals(abcd, StringUtils.center(abcd, 2,  ));
  @@ -326,6 +332,11 @@
   assertEquals(yayz, StringUtils.center(a, 4, yz));
   assertEquals(yzyayzy, StringUtils.center(a, 7, yz));
   try {
  +StringUtils.center(null, 4, null);
  +fail();
  +} catch (IllegalArgumentException ex) {
  +}
  +try {
   StringUtils.center(abc, 4, null);
   fail();
   } catch (IllegalArgumentException ex) {
  @@ -477,6 +488,10 @@
   assertEquals(123456-+~, StringUtils.rightPad (123456, 9, -+~) );
   assertEquals(123456-+, StringUtils.rightPad (123456, 8, -+~) );
   try {
  +StringUtils.rightPad(null, 6, null);
  +fail();
  +} catch (IllegalArgumentException ex) {}
  +try {
   StringUtils.rightPad(123456, 6, null);
   fail();
   } catch (IllegalArgumentException ex) {}
  @@ -492,6 +507,10 @@
   assertEquals(-+-+1234, StringUtils.leftPad(1234, 8, -+) );
   assertEquals(-+~123456, StringUtils.leftPad(123456, 9, -+~) );
   assertEquals(-+123456, StringUtils.leftPad(123456, 8, -+~) );
  +try {
  +StringUtils.leftPad(null, 6, null);
  +fail();
  +} catch (IllegalArgumentException ex) {}
   try {
   StringUtils.leftPad(123456, 6, null);
   fail();
  
  
  
  1.64  +67 -75
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- StringUtils.java  18 Jul 2003 23:57:43 -  1.63
  +++ StringUtils.java  19 Jul 2003 00:22:50 -  1.64
  @@ -1954,6 +1954,7 @@
* StringUtils.rightPad(bat, -1, yz) = bat
* StringUtils.rightPad(bat, 1, null)  = IllegalArgumentException
* StringUtils.rightPad(bat, 1, )= IllegalArgumentException
  + * StringUtils.rightPad(null, 1, ) = IllegalArgumentException
* /pre
*
* @param str  the String to pad out, may be null
  @@ -1964,13 +1965,13 @@
* @throws IllegalArgumentException if padStr is the empty String or null
*/
   public static String rightPad(String str, int size, String padStr) {
  -if (str == null) {
  -return null;
  -}
   int padLen;
   if (padStr == null || (padLen = padStr.length()) == 0) {
   throw new IllegalArgumentException(Pad String must not be null or 
empty);
   }
  +if (str == null) {
  +return null;
  +}
   int strLen = str.length();
   int pads = size - strLen;
   if (padLen == 1  pads = PAD_LIMIT) {
  @@ -2073,6 +2074,7 @@
* StringUtils.leftPad(bat, -1, yz) = bat
* StringUtils.leftPad(bat, 1, null)  = IllegalArgumentException
* StringUtils.leftPad(bat, 1, )= IllegalArgumentException
  + * StringUtils.leftPad(null, 1, ) = 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-16 Thread scolebourne
scolebourne2003/07/16 13:19:24

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Remove old unused commented out code
  
  Revision  ChangesPath
  1.57  +1 -32 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- StringUtils.java  15 Jul 2003 23:41:54 -  1.56
  +++ StringUtils.java  16 Jul 2003 20:19:24 -  1.57
  @@ -2226,37 +2226,6 @@
   }
   
   /**
  - * pChecks if the String contains only certain chars./p
  - *
  - * @param str the String to check
  - * @param validChars an array of valid chars
  - * @return true if it only contains valid chars and is non-null
  - */
  - /* rewritten
  -public static boolean containsOnly(String str, char[] validChars) {
  -if (str == null || validChars == null) {
  -return false;
  -}
  -int strSize = str.length();
  -int validSize = validChars.length;
  -for (int i = 0; i  strSize; i++) {
  -char ch = str.charAt(i);
  -boolean contains = false;
  -for (int j = 0; j  validSize; j++) {
  -if (validChars[j] == ch) {
  -contains = true;
  -break;
  -}
  -}
  -if (contains == false) {
  -return false;
  -}
  -}
  -return true;
  -}
  -*/
  -
  -/**
* pChecks that the String does not contain certain chars./p
*
* @param str the String to check
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-16 Thread scolebourne
scolebourne2003/07/16 16:45:39

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
StringUtilsSubstringTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Update Null handling in StringUtils to handle nulls quietly
  
  Revision  ChangesPath
  1.24  +113 -41   
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- StringUtilsTest.java  16 Jul 2003 21:23:50 -  1.23
  +++ StringUtilsTest.java  16 Jul 2003 23:45:39 -  1.24
  @@ -54,6 +54,7 @@
   package org.apache.commons.lang;
   
   import java.util.Arrays;
  +import java.util.Iterator;
   
   import junit.framework.Test;
   import junit.framework.TestCase;
  @@ -153,6 +154,12 @@
   }
   
   public void testJoin() {
  +assertEquals(null, StringUtils.concatenate(null));
  +assertEquals(null, StringUtils.join((Object[]) null, null));
  +assertEquals(null, StringUtils.join((Object[]) null, ','));
  +assertEquals(null, StringUtils.join((Iterator) null, null));
  +assertEquals(null, StringUtils.join((Iterator) null, ','));
  +
   assertEquals(concatenate(Object[]) failed,
TEXT_LIST_NOSEP, StringUtils.concatenate(ARRAY_LIST));
   assertEquals(join(Object[], String) failed, TEXT_LIST,
  @@ -256,6 +263,19 @@
   public void testOverlayString() {
   assertEquals(overlayString(String, String, int, int) failed,
foo foor baz, StringUtils.overlayString(SENTENCE, FOO, 4, 6) 
);
  +assertEquals(null, StringUtils.overlayString(null, null, 2, 4));
  +assertEquals(abef, StringUtils.overlayString(abcdef, null, 2, 4));
  +assertEquals(abef, StringUtils.overlayString(abcdef, , 2, 4));
  +assertEquals(abef, StringUtils.overlayString(abcdef, , 2, 4));
  +assertEquals(abcdcdef, StringUtils.overlayString(abcdef, , 4, 
2));
  +try {
  +StringUtils.overlayString(abcdef, , -1, 4);
  +fail();
  +} catch (IndexOutOfBoundsException ex) {}
  +try {
  +StringUtils.overlayString(abcdef, , 2, 8);
  +fail();
  +} catch (IndexOutOfBoundsException ex) {}
   }
   
   public void testRepeat() {
  @@ -272,8 +292,30 @@
   }
   
   public void testCenter() {
  -assertEquals(center(String, int) failed,
  -+FOO+   , StringUtils.center(FOO, 9) );
  +assertEquals(null, StringUtils.center(null, -1));
  +assertEquals(null, StringUtils.center(null, 4));
  +assertEquals(, StringUtils.center(, 4));
  +assertEquals( ab , StringUtils.center(ab, 4));
  +assertEquals(abcd, StringUtils.center(abcd, 2));
  +assertEquals( a  , StringUtils.center(a, 4));
  +
  +assertEquals(null, StringUtils.center(null, -1,  ));
  +assertEquals(null, StringUtils.center(null, 4,  ));
  +assertEquals(, StringUtils.center(, 4,  ));
  +assertEquals( ab , StringUtils.center(ab, 4,  ));
  +assertEquals(abcd, StringUtils.center(abcd, 2,  ));
  +assertEquals( a  , StringUtils.center(a, 4,  ));
  +assertEquals(yayz, StringUtils.center(a, 4, yz));
  +try {
  +StringUtils.center(abc, 4, null);
  +fail();
  +} catch (IllegalArgumentException ex) {
  +}
  +try {
  +StringUtils.center(abc, 4, );
  +fail();
  +} catch (IllegalArgumentException ex) {
  +}
   }
   
   public void testDeprecatedChompFunctions() {
  @@ -304,6 +346,9 @@
   { \n,  },
   { \r,  },
   { \r\n,  },
  +{ null, null },
  +{ ,  },
  +{ a,  },
   };
   for (int i = 0; i  chopCases.length; i++) {
   String original = chopCases[i][0];
  @@ -370,6 +415,9 @@
   {foo\nbar, foo},
   {foo\nbar\n, foo\nbar},
   {foo\nbar\nbaz, foo\nbar},
  +{null, null},
  +{, },
  +{foo, foo},
   };
   for (int i = 0; i  sliceCases.length; i++) {
   String original = sliceCases[i][0];
  @@ -381,47 +429,66 @@
   String original = fooXXbarXXbaz;
   String sep = XX;
   
  -assertEquals(slice(String,String) failed,
  - fooXXbar, StringUtils.slice(original, sep) );
  +assertEquals(fooXXbar, StringUtils.slice(original, sep) );
  +assertEquals(null, StringUtils.slice(null, sep) );
  +

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-16 Thread scolebourne
scolebourne2003/07/16 16:56:45

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Update Null handling in StringUtils to handle nulls quietly
  
  Revision  ChangesPath
  1.25  +2 -6  
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- StringUtilsTest.java  16 Jul 2003 23:45:39 -  1.24
  +++ StringUtilsTest.java  16 Jul 2003 23:56:44 -  1.25
  @@ -279,16 +279,12 @@
   }
   
   public void testRepeat() {
  +assertEquals(null, StringUtils.repeat(null, 2));
   assertEquals(, StringUtils.repeat(ab, 0));
   assertEquals(, StringUtils.repeat(, 3));
   assertEquals(aaa, StringUtils.repeat(a, 3));
   assertEquals(ababab, StringUtils.repeat(ab, 3));
   assertEquals(abcabcabc, StringUtils.repeat(abc, 3));
  -try {
  -StringUtils.repeat(null, 0);
  -fail();
  -} catch (NullPointerException ex) {
  -}
   }
   
   public void testCenter() {
  
  
  
  1.61  +24 -15
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- StringUtils.java  16 Jul 2003 23:45:39 -  1.60
  +++ StringUtils.java  16 Jul 2003 23:56:45 -  1.61
  @@ -71,8 +71,15 @@
*  liwhitespace - the characters defined by [EMAIL PROTECTED] 
Character#isWhitespace(char)}
* /ul
* 
  - * pThe codeStringUtils/code class varies in its handling of
  - * codenull/code. Each method should be consulted individually./p
  + * pThe codeStringUtils/code tries to handle codenull/code input
  + * quietly. That is to say that a codenull/code will generally return a 
  + * sensible value rather than throw an exception.
  + * Typically, codenull/code in gives codenull/code out.
  + * Each method should be consulted individually for full details./p
  + * 
  + * pA side effect of the codenull/code handling is that a 
  + * NullPointerException should be considered a bug in codeStringUtils/code.
  + * (Except for deprecated methods)./p
*
* @author a href=http://jakarta.apache.org/turbine/;Apache Jakarta Turbine/a
* @author GenerationJavaCore
  @@ -1626,25 +1633,27 @@
* new string./p
*
* pre
  + * StringUtils.repeat(null, 2) = null
* StringUtils.repeat(, 0)   = 
* StringUtils.repeat(, 2)   = 
* StringUtils.repeat(a, 3)  = aaa
* StringUtils.repeat(ab, 2) = abab
  - * StringUtils.repeat(null, 2) = NullPointerException
  - * StringUtils.repeat(a, -2) = NegativeArraySizeException
  + * StringUtils.repeat(a, -2) = 
* /pre
*
  - * @param str  the String to repeat, must not be null
  - * @param repeat  number of times to repeat str
  - * @return a new String consisting of the original String repeated
  - * @throws NegativeArraySizeException if coderepeat lt; 0/code
  - * @throws NullPointerException if str is codenull/code
  + * @param str  the String to repeat, may be null
  + * @param repeat  number of times to repeat str, negative treated as zero
  + * @return a new String consisting of the original String repeated,
  + *  codenull/code if null string input
*/
   public static String repeat(String str, int repeat) {
  -int inputLength = str.length();
  -if (repeat == 0) {
  +if (str == null) {
  +return null;
  +}
  +if (repeat = 0) {
   return ;
   }
  +int inputLength = str.length();
   if (inputLength == 1  repeat = PAD_LIMIT) {
  return padding(repeat, str.charAt(0));
   }
  @@ -1904,8 +1913,8 @@
* StringUtils.leftPad(bat, 8, yz)  = yzyzybat
* StringUtils.leftPad(bat, 1, yz)  = bat
* StringUtils.leftPad(bat, -1, yz) = bat
  - * StringUtils.leftPad(bat, 1, null)  = NullPointerException
  - * StringUtils.leftPad(bat, 1, )= ArithmeticException
  + * StringUtils.leftPad(bat, 1, null)  = IllegalArgumentException
  + * StringUtils.leftPad(bat, 1, )= IllegalArgumentException
* /pre
*
* @param str  the String to pad out, may be null
  @@ -2841,7 +2850,7 @@
   /**
* pFind the Levenshtein distance between two Strings./p
*
  - * PThis is the number of changes needed 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-15 Thread scolebourne
scolebourne2003/07/15 16:41:54

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Update Javadoc defining empty, space and whitespace
  Improve performance of repeat
  Add defaultString(String) back in for performance
  
  Revision  ChangesPath
  1.22  +26 -3 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- StringUtilsTest.java  23 Jun 2003 03:51:13 -  1.21
  +++ StringUtilsTest.java  15 Jul 2003 23:41:54 -  1.22
  @@ -259,8 +259,16 @@
   }
   
   public void testRepeat() {
  -assertEquals(repeat(String, int) failed,
  - FOO + FOO + FOO, StringUtils.repeat(FOO, 3) );
  +assertEquals(, StringUtils.repeat(ab, 0));
  +assertEquals(, StringUtils.repeat(, 3));
  +assertEquals(aaa, StringUtils.repeat(a, 3));
  +assertEquals(ababab, StringUtils.repeat(ab, 3));
  +assertEquals(abcabcabc, StringUtils.repeat(abc, 3));
  +try {
  +StringUtils.repeat(null, 0);
  +fail();
  +} catch (NullPointerException ex) {
  +}
   }
   
   public void testCenter() {
  @@ -436,6 +444,21 @@
FOO, StringUtils.defaultString(FOO, BAR) );
   assertEquals(defaultString(null,String) failed,
BAR, StringUtils.defaultString(null, BAR) );
  +
  +assertEquals(defaultString((Object) empty-string) failed,
  + , StringUtils.defaultString((Object) ) );
  +assertEquals(defaultString((Object) String) failed,
  + FOO, StringUtils.defaultString((Object) FOO) );
  +assertEquals(defaultString((Object) null) failed,
  + , StringUtils.defaultString((Object) null) );
  +assertEquals(defaultString((Object) empty-string,String) failed,
  + , StringUtils.defaultString((Object) , BAR) );
  +assertEquals(defaultString((Object) String,String) failed,
  + FOO, StringUtils.defaultString((Object) FOO, BAR) );
  +assertEquals(defaultString((Object) null,String) failed,
  + BAR, StringUtils.defaultString((Object) null, BAR) );
  +assertEquals(defaultString(Boolean.TRUE,String) failed,
  + Boolean.TRUE.toString(), 
StringUtils.defaultString(Boolean.TRUE, BAR) );
   }
   
   public void testEscapeFunctions() {
  
  
  
  1.56  +316 -143  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- StringUtils.java  14 Jul 2003 23:02:08 -  1.55
  +++ StringUtils.java  15 Jul 2003 23:41:54 -  1.56
  @@ -61,10 +61,21 @@
   /**
* pCommon codeString/code manipulation routines./p
*
  - * pOriginally from 
  - * a href=http://jakarta.apache.org/turbine/;Turbine/a and the
  - * GenerationJavaCore library./p
  + * pThe codeStringUtils/code class defines certain words related to
  + * String handling./p
  + * 
  + * ul
  + *  linull - codenull/code
  + *  liempty - a zero-length string (code/code)
  + *  lispace - the space character (code' '/code)(32)
  + *  liwhitespace - the characters defined by [EMAIL PROTECTED] 
Character#isWhitespace(char)}
  + * /ul
  + * 
  + * pThe codeStringUtils/code class varies in its handling of
  + * codenull/code. Each method should be consulted individually./p
*
  + * @author a href=http://jakarta.apache.org/turbine/;Apache Jakarta Turbine/a
  + * @author GenerationJavaCore
* @author a href=mailto:[EMAIL PROTECTED]Jon S. Stevens/a
* @author a href=mailto:[EMAIL PROTECTED]Daniel Rall/a
* @author a href=mailto:[EMAIL PROTECTED]Greg Coladonato/a
  @@ -89,16 +100,16 @@
   private static int PAD_LIMIT = 8192;
   
   /**
  - * pA codeString/code containing all blank characters./p
  + * pA codeString/code containing all space characters (' ')./p
*
  - * pUsed for efficient blank padding.  The length of the string expands as 
needed./p
  + * pUsed for efficient space padding.  The length of the string expands as 
needed./p
*/
  -private static String blanks = new String( );
  +private static String spaces = new String( );
   
   /**
* pAn array of codeString/codes used for padding./p
*
  - * pUsed for efficient blank 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-14 Thread scolebourne
scolebourne2003/07/14 16:02:08

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Unify format of NOTE comments
  
  Revision  ChangesPath
  1.55  +7 -7  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- StringUtils.java  14 Jul 2003 22:26:51 -  1.54
  +++ StringUtils.java  14 Jul 2003 23:02:08 -  1.55
  @@ -1005,9 +1005,9 @@
* otherwise leave it alone.  A newline is quot;code\n/codequot;,
* quot;code\r/codequot;, or quot;code\r\n/codequot;./p
*
  - * pNote that this behavior has changed from 1.0.  It
  - * now more closely matches Perl chomp.  For the previous behavior,
  - * use [EMAIL PROTECTED] #slice(String)}./p
  + * pNOTE: This method changed in 2.0.
  + * It now more closely matches Perl chomp.
  + * For the previous behavior, use [EMAIL PROTECTED] #slice(String)}./p
*
* @param str String to chomp a newline from
* @return String without newline
  @@ -1046,9 +1046,9 @@
* pRemove codeseparator/code from the end of
* codestr/code if it's there, otherwise leave it alone./p
*
  - * pNote that this behavior has changed from 1.0.  It
  - * now more closely matches Perl chomp.  For the previous behavior,
  - * use [EMAIL PROTECTED] #slice(String,String)}./p
  + * pNOTE: This method changed in version 2.0.
  + * It now more closely matches Perl chomp.
  + * For the previous behavior, use [EMAIL PROTECTED] #slice(String,String)}./p
*
* @param str string to chomp from
* @param separator separator string
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-07-09 Thread bayard
bayard  2003/07/09 16:54:16

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Removed the unnecessary 'A' from join's char separator javadocs.
  
  Revision  ChangesPath
  1.53  +3 -3  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- StringUtils.java  8 Jul 2003 05:59:58 -   1.52
  +++ StringUtils.java  9 Jul 2003 23:54:16 -   1.53
  @@ -652,7 +652,7 @@
* pJoins the elements of the provided array into a single String
* containing the provided list of elements./p
*
  - * pNo delimiter is added before or after the list. A
  + * pNo delimiter is added before or after the list.
*
* @param array the array of values to join together
* @param separator the separator character to use
  @@ -698,7 +698,7 @@
* pJoins the elements of the provided codeIterator/code into
* a single String containing the provided elements./p
*
  - * pNo delimiter is added before or after the list. A
  + * pNo delimiter is added before or after the list.
*
* @param iterator the codeIterator/code of values to join together
* @param separator  the separator character to use
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-06-24 Thread scolebourne
scolebourne2003/06/24 01:15:15

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Deprecate escape, and comment escape and unescape fully
  
  Revision  ChangesPath
  1.50  +5 -3  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- StringUtils.java  24 Jun 2003 02:55:17 -  1.49
  +++ StringUtils.java  24 Jun 2003 08:15:15 -  1.50
  @@ -1162,7 +1162,6 @@
   // Conversion
   //--
   
  -// spec 3.10.6
   /**
* pEscapes any values it finds into their String form./p
*
  @@ -1170,12 +1169,14 @@
* code't'/code./p
*
* pAs of Lang 2.0, this calls [EMAIL PROTECTED] 
StringEscapeUtils#escapeJava(java.lang.String)}
  - * behind the scenes.  For convenience, this method is not deprecated.
  + * behind the scenes.
* /p
* @see StringEscapeUtils#escapeJava(java.lang.String)
* @param str String to escape values in
* @return String with escaped values
* @throws NullPointerException if str is codenull/code
  + * @deprecated Use [EMAIL PROTECTED] 
StringEscapeUtils#escapeJava(java.lang.String)}
  + * This method will be removed in Commons Lang 3.0
*/
   public static String escape(String str) {
   return StringEscapeUtils.escapeJava(str);
  @@ -1191,6 +1192,7 @@
* p
* @see StringEscapeUtils#unescapeJava(java.lang.String)
* @deprecated Use [EMAIL PROTECTED] 
StringEscapeUtils#unescapeJava(java.lang.String)}
  + * This method will be removed in Commons Lang 3.0
*/
   public static String unescape(String str) {
   return StringEscapeUtils.unescapeJava(str);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-06-23 Thread bayard
bayard  2003/06/23 19:55:17

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Deprecated unescape method.
  
  Revision  ChangesPath
  1.49  +3 -2  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- StringUtils.java  23 Jun 2003 03:51:13 -  1.48
  +++ StringUtils.java  24 Jun 2003 02:55:17 -  1.49
  @@ -1187,9 +1187,10 @@
* unless the '\' is preceded by another '\'.
* p
* As of Lang 2.0, this calls [EMAIL PROTECTED] 
StringEscapeUtils#unescapeJava(java.lang.String)}
  - * behind the scenes.  For convenience, this method is not deprecated.
  + * behind the scenes. 
* p
* @see StringEscapeUtils#unescapeJava(java.lang.String)
  + * @deprecated Use [EMAIL PROTECTED] 
StringEscapeUtils#unescapeJava(java.lang.String)}
*/
   public static String unescape(String str) {
   return StringEscapeUtils.unescapeJava(str);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-05-30 Thread ggregory
ggregory2003/05/29 18:00:24

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Javadoc.
  
  Revision  ChangesPath
  1.45  +10 -9 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- StringUtils.java  16 Apr 2003 04:37:33 -  1.44
  +++ StringUtils.java  30 May 2003 01:00:24 -  1.45
  @@ -75,6 +75,7 @@
* @author a href=mailto:[EMAIL PROTECTED]Alexander Day Chaffee/a
* @author a href=mailto:[EMAIL PROTECTED]Henning P. Schmiedehausen/a
* @author Arun Mammen Thomas
  + * @author a href=mailto:[EMAIL PROTECTED]Gary Gregory/a
* @since 1.0
* @version $Id$
*/
  @@ -130,7 +131,7 @@
* @see java.lang.String#trim()
* @param str the String to check
* @return the trimmed text (never codenull/code)
  - * @deprecated use the clearer named trimToEmpty(String)
  + * @deprecated Use the clearer named [EMAIL PROTECTED] #trimToEmpty(String)}.
*/
   public static String clean(String str) {
   return (str == null ?  : str.trim());
  @@ -887,7 +888,7 @@
*
* Note that this behavior has changed from 1.0.  It
* now more closely matches Perl chomp.  For the previous behavior,
  - * use slice(String,String).
  + * use [EMAIL PROTECTED] #slice(String,String)}.
*
* @param str string to chomp from
* @param separator separator string
  @@ -911,7 +912,7 @@
* @param str String to chomp from
* @return String without chomped ending
* @throws NullPointerException if str is codenull/code
  - * @deprecated use chomp(String) instead
  + * @deprecated Use [EMAIL PROTECTED] #chomp(String)} instead.
*/
   public static String chompLast(String str) {
   return chompLast(str, \n);
  @@ -924,7 +925,7 @@
* @param sep String to chomp
* @return String without chomped ending
* @throws NullPointerException if str or sep is codenull/code
  - * @deprecated use chomp(String,String) instead
  + * @deprecated Use [EMAIL PROTECTED] #chomp(String,String)} instead.
*/
   public static String chompLast(String str, String sep) {
   if (str.length() == 0) {
  @@ -947,7 +948,7 @@
* @param sep String to chomp
* @return String chomped
* @throws NullPointerException if str or sep is codenull/code
  - * @deprecated use sliceRemainder(String,String) instead
  + * @deprecated Use [EMAIL PROTECTED] #sliceRemainder(String,String)} instead.
*/
   public static String getChomp(String str, String sep) {
   int idx = str.lastIndexOf(sep);
  @@ -968,7 +969,7 @@
* @param sep String to chomp
* @return String without chomped beginning
* @throws NullPointerException if str or sep is codenull/code
  - * @deprecated use sliceFirstRemainder(String,String) instead
  + * @deprecated Use [EMAIL PROTECTED] #sliceFirstRemainder(String,String)} 
instead.
*/
   public static String prechomp(String str, String sep) {
   int idx = str.indexOf(sep);
  @@ -987,7 +988,7 @@
* @param sep String to chomp
* @return String prechomped
* @throws NullPointerException if str or sep is codenull/code
  - * @deprecated use sliceFirst(String) instead
  + * @deprecated Use [EMAIL PROTECTED] #sliceFirst(String,String)} instead.
*/
   public static String getPrechomp(String str, String sep) {
   int idx = str.indexOf(sep);
  @@ -1036,7 +1037,7 @@
* @param str String to chop a newline from
* @return String without newline
* @throws NullPointerException if str is codenull/code
  - * @deprecated use chomp(String) instead
  + * @deprecated Use [EMAIL PROTECTED] #chomp(String)} instead.
*/
   public static String chopNewline(String str) {
   int lastIdx = str.length() - 1;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-03-24 Thread scolebourne
scolebourne2003/03/24 16:15:58

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Deprecate clean() now trimToEmpty() is added
  
  Revision  ChangesPath
  1.39  +2 -1  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- StringUtils.java  24 Mar 2003 00:47:02 -  1.38
  +++ StringUtils.java  25 Mar 2003 00:15:58 -  1.39
  @@ -112,6 +112,7 @@
* @see java.lang.String#trim()
* @param str the String to check
* @return the trimmed text (never codenull/code)
  + * @deprecated use the clearer named trimToEmpty(String)
*/
   public static String clean(String str) {
   return (str == null ?  : str.trim());
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-03-23 Thread scolebourne
scolebourne2003/03/23 10:05:44

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Update licence date to 2003
  Javadoc fixes
  
  Revision  ChangesPath
  1.36  +10 -10
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- StringUtils.java  23 Mar 2003 05:26:23 -  1.35
  +++ StringUtils.java  23 Mar 2003 18:05:44 -  1.36
  @@ -1,7 +1,7 @@
   /* 
* The Apache Software License, Version 1.1
*
  - * Copyright (c) 2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
  @@ -1769,7 +1769,7 @@
   // could implement manually, but simple way is to reuse other, 
   // probably slower, methods.
   String[] strs = split(str, delimiter);
  -ArrayUtils.reverseArray(strs);
  +ArrayUtils.reverse(strs);
   return join(strs, delimiter);
   }
   
  @@ -1830,26 +1830,26 @@
* (More precisely, return the remainder of the second string,
* starting from where it's different from the first.)
* p
  - * E.g. strdiff(i am a machine, i am a robot) - robot
  + * For example, codedifference(i am a machine, i am a robot) - 
robot/code
*
* @return the portion of s2 where it differs from s1; returns the empty string 
() if they are equal
  - **/
  + */
   public static String difference(String s1, String s2) {
   int at = differenceAt(s1, s2);
  -if (at == -1)
  +if (at == -1) {
   return ;
  +}
   return s2.substring(at);
   }
   
   /**
* Compare two strings, and return the index at which the strings begin to 
differ
* p
  - * E.g. strdiff(i am a machine, i am a robot) - 7
  + * For example, codedifferenceAt(i am a machine, i am a robot) - 7/code
*
* @return the index where s2 and s1 begin to differ; -1 if they are equal
  - **/
  -public static int differenceAt(String s1, String s2)
  -{
  + */
  +public static int differenceAt(String s1, String s2) {
   int i;
   for (i=0; is1.length()  is2.length(); ++i) {
   if (s1.charAt(i) != s2.charAt(i)) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-03-23 Thread scolebourne
scolebourne2003/03/23 13:52:31

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Update containsOnly 
  Add containsNone
  
  Revision  ChangesPath
  1.37  +82 -31
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- StringUtils.java  23 Mar 2003 18:05:44 -  1.36
  +++ StringUtils.java  23 Mar 2003 21:52:31 -  1.37
  @@ -1705,6 +1705,87 @@
   return true;
   }
   
  +/**
  + * pChecks if the String contains only certain chars./p
  + *
  + * @param str  the string to check
  + * @param validChars  a string of valid chars
  + * @return true if it only contains valid chars and is non-null
  + */
  +public static boolean containsOnly(String str, String validChars) {
  +if (str == null || validChars == null) {
  +return false;
  +}
  +return containsOnly(str, validChars.toCharArray());
  +}
  +
  +/**
  + * pChecks if the String contains only certain chars./p
  + *
  + * @param str  the string to check
  + * @param validChars  an array of valid chars
  + * @return true if it only contains valid chars and is non-null
  + */
  +public static boolean containsOnly(String str, char[] validChars) {
  +if (str == null || validChars == null) {
  +return false;
  +}
  +int strSize = str.length();
  +int validSize = validChars.length;
  +for (int i = 0; i  strSize; i++) {
  +char ch = str.charAt(i);
  +boolean contains = false;
  +for (int j = 0; j  validSize; j++) {
  +if (validChars[j] == ch) {
  +contains = true;
  +break;
  +}
  +}
  +if (contains == false) {
  +return false;
  +}
  +}
  +return true;
  +}
  +
  +/**
  + * pChecks that the String does not contain certain chars./p
  + *
  + * @param str  the string to check
  + * @param invalidChars  a string of invalid chars
  + * @return true if it contains none of the invalid chars, or is null
  + */
  +public static boolean containsNone(String str, String invalidChars) {
  +if (str == null || invalidChars == null) {
  +return true;
  +}
  +return containsNone(str, invalidChars.toCharArray());
  +}
  +
  +/**
  + * pChecks that the String does not contain certain chars./p
  + *
  + * @param str  the string to check
  + * @param invalidChars  an array of invalid chars
  + * @return true if it contains none of the invalid chars, or is null
  + */
  +public static boolean containsNone(String str, char[] invalidChars) {
  +if (str == null || invalidChars == null) {
  +return true;
  +}
  +int strSize = str.length();
  +int validSize = invalidChars.length;
  +for (int i = 0; i  strSize; i++) {
  +char ch = str.charAt(i);
  +for (int j = 0; j  validSize; j++) {
  +if (invalidChars[j] == ch) {
  +return false;
  +}
  +}
  +}
  +return true;
  +}
  +
   // Defaults
   //--
   
  @@ -1934,34 +2015,4 @@
   return d[n][m];
   }
   
  -/**
  - * pChecks if the String contains only certain chars./p
  - *
  - * @param str the String to check
  - * @param valid an array of valid chars
  - * @return true if it only contains valid chars and is non-null
  - */
  -public static boolean containsOnly(String str, char[] valid) {
  -if (str == null || valid == null) {
  -return false;
  -}
  -
  -int strSize = str.length();
  -int validSize = valid.length;
  -
  -for (int i = 0; i  strSize; i++) {
  -boolean contains = false;
  -for (int j = 0; j  validSize; j++) {
  -if (valid[j] == str.charAt(i)) {
  -contains = true;
  -break;
  -}
  -}
  -if (!contains) {
  -return false;
  -}
  -}
  -
  -return true;
  -}
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-03-23 Thread scolebourne
scolebourne2003/03/23 16:47:03

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsTrimEmptyTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Add trimToNull
  Add trimToEmpty
  
  Revision  ChangesPath
  1.7   +25 -1 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
  
  Index: StringUtilsTrimEmptyTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StringUtilsTrimEmptyTest.java 23 Mar 2003 21:51:19 -  1.6
  +++ StringUtilsTrimEmptyTest.java 24 Mar 2003 00:47:02 -  1.7
  @@ -97,6 +97,8 @@
   assertEquals(FOO, StringUtils.clean(  + FOO +   ));
   assertEquals(FOO, StringUtils.clean(  + FOO));
   assertEquals(FOO, StringUtils.clean(FOO + ));
  +assertEquals(, StringUtils.clean( \t\r\n\b ));
  +assertEquals(, StringUtils.clean());
   assertEquals(, StringUtils.clean(null));
   }
   
  @@ -105,7 +107,29 @@
   assertEquals(FOO, StringUtils.trim(  + FOO +   ));
   assertEquals(FOO, StringUtils.trim(  + FOO));
   assertEquals(FOO, StringUtils.trim(FOO + ));
  +assertEquals(, StringUtils.trim( \t\r\n\b ));
  +assertEquals(, StringUtils.trim());
   assertEquals(null, StringUtils.trim(null));
  +}
  +
  +public void testTrimToNull() {
  +assertEquals(FOO, StringUtils.trimToNull(FOO +   ));
  +assertEquals(FOO, StringUtils.trimToNull(  + FOO +   ));
  +assertEquals(FOO, StringUtils.trimToNull(  + FOO));
  +assertEquals(FOO, StringUtils.trimToNull(FOO + ));
  +assertEquals(null, StringUtils.trimToNull( \t\r\n\b ));
  +assertEquals(null, StringUtils.trimToNull());
  +assertEquals(null, StringUtils.trimToNull(null));
  +}
  +
  +public void testTrimToEmpty() {
  +assertEquals(FOO, StringUtils.trimToEmpty(FOO +   ));
  +assertEquals(FOO, StringUtils.trimToEmpty(  + FOO +   ));
  +assertEquals(FOO, StringUtils.trimToEmpty(  + FOO));
  +assertEquals(FOO, StringUtils.trimToEmpty(FOO + ));
  +assertEquals(, StringUtils.trimToEmpty( \t\r\n\b ));
  +assertEquals(, StringUtils.trimToEmpty());
  +assertEquals(, StringUtils.trimToEmpty(null));
   }
   
   public void testIsNotEmpty() {
  
  
  
  1.38  +76 -10
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- StringUtils.java  23 Mar 2003 21:52:31 -  1.37
  +++ StringUtils.java  24 Mar 2003 00:47:02 -  1.38
  @@ -76,6 +76,7 @@
* @author Holger Krauth
* @author a href=mailto:[EMAIL PROTECTED]Alexander Day Chaffee/a
* @author a href=mailto:[EMAIL PROTECTED]Henning P. Schmiedehausen/a
  + * @author Arun Mammen Thomas
* @since 1.0
* @version $Id$
*/
  @@ -99,6 +100,14 @@
* pRemoves control characters, including whitespace, from both
* ends of this String, handling codenull/code by returning
* an empty String./p
  + * 
  + * pre
  + * StringUtils.clean(abc) = abc
  + * StringUtils.clean(abc) = abc
  + * StringUtils.clean( )   = 
  + * StringUtils.clean()= 
  + * StringUtils.clean(null)  = 
  + * /pre
*
* @see java.lang.String#trim()
* @param str the String to check
  @@ -112,15 +121,72 @@
* pRemoves control characters, including whitespace, from both
* ends of this String, handling codenull/code by returning
* codenull/code./p
  + * 
  + * pThe string is trimmed using [EMAIL PROTECTED] String#trim()}./p
  + * 
  + * pre
  + * StringUtils.trim(abc) = abc
  + * StringUtils.trim(abc) = abc
  + * StringUtils.trim( )   = 
  + * StringUtils.trim()= 
  + * StringUtils.trim(null)  = null
  + * /pre
*
* @see java.lang.String#trim()
  - * @param str the String to check
  + * @param str the String to be trimmed
* @return the trimmed text (or codenull/code)
*/
   public static String trim(String str) {
   return (str == null ? null : str.trim());
   }
   
  +/** 
  + * pRemoves control characters, including whitespace, from both  
  + * ends of this string returning codenull/code if the string is 
  + * empty after the trim or if it is codenull/code.
  + * 
  + 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2003-01-19 Thread scolebourne
scolebourne2003/01/19 10:15:38

  Modified:lang/src/test/org/apache/commons/lang StringUtilsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Fix infinite recursion in replace() when blank string used
  from Holger Krauth
  
  Revision  ChangesPath
  1.12  +26 -25
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StringUtilsTest.java  7 Dec 2002 21:50:30 -   1.11
  +++ StringUtilsTest.java  19 Jan 2003 18:15:38 -  1.12
  @@ -1,5 +1,3 @@
  -package org.apache.commons.lang;
  -
   /* 
* The Apache Software License, Version 1.1
*
  @@ -53,6 +51,7 @@
* information on the Apache Software Foundation, please see
* http://www.apache.org/.
*/
  +package org.apache.commons.lang;
   
   import java.util.Arrays;
   
  @@ -65,13 +64,14 @@
*
* @author a href=mailto:[EMAIL PROTECTED];Daniel Rall/a
* @author a href=mailto:[EMAIL PROTECTED];Henri Yandell/a
  - * @author a href=mailto:[EMAIL PROTECTED];Stephen Colebourne/a
  + * @author Stephen Colebourne
* @author a href=mailto:[EMAIL PROTECTED];Ringo De Smet/a
* @author a href=mailto:[EMAIL PROTECTED]Fredrik Westermarck/a
  + * @author Holger Krauth
* @version $Id$
*/
  -public class StringUtilsTest extends TestCase
  -{
  +public class StringUtilsTest extends TestCase {
  +
   private static final String[] ARRAY_LIST = { foo, bar, baz };
   
   private static final String SEPARATOR = ,;
  @@ -108,8 +108,7 @@
   
   //---
   
  -public void testCaseFunctions()
  -{
  +public void testCaseFunctions() {
   assertEquals(capitalise(String) failed,
CAP_FOO, StringUtils.capitalise(FOO) );
   assertEquals(capitalise(empty-string) failed,
  @@ -144,8 +143,7 @@
Hello aPACHE, StringUtils.swapCase(hELLO Apache) );
   }
   
  -public void testJoin()
  -{
  +public void testJoin() {
   assertEquals(concatenate(Object[]) failed, 
foobarbaz, StringUtils.concatenate(ARRAY_LIST));
   assertEquals(join(Object[], String) failed, TEXT_LIST,
  @@ -155,8 +153,7 @@
 SEPARATOR));
   }
   
  -public void testSplit()
  -{
  +public void testSplit() {
   String[] result = StringUtils.split(TEXT_LIST, SEPARATOR, 2);
   String[] expected = { foo, bar,baz };
   assertEquals(split(Object[], String, int) yielded unexpected length,
  @@ -193,8 +190,7 @@
   assertEquals(split(Object[], null, int)[2] failed, three four five six, 
result[2]);
   }
   
  -public void testReplaceFunctions()
  -{
  +public void testReplaceFunctions() {
   assertEquals(replace(String, String, String, int) failed,
FOO, StringUtils.replace(oo + FOO, o, , 2));
   assertEquals(replace(String, String, String) failed,
  @@ -203,29 +199,35 @@
FOO, StringUtils.replaceOnce(FOO + FOO, FOO, ));
   assertEquals(carriage-return replace(String,String,String) failed,
test123, StringUtils.replace(test\r1\r2\r3, \r, ));
  +
  +assertEquals(replace(String, String, String) failed,
  +FOO, StringUtils.replace(FOO, , any));
  +assertEquals(replace(String, String, String) failed,
  +FOO, StringUtils.replace(FOO, null, any));
  +assertEquals(replace(String, String, String) failed,
  +FOO, StringUtils.replace(FOO, F, null));
  +assertEquals(replace(String, String, String) failed,
  +FOO, StringUtils.replace(FOO, null, null));
  +assertEquals(replace(String, String, String) failed,
  +null, StringUtils.replace(null, , any));
   }
   
  -public void testOverlayString()
  -{
  +public void testOverlayString() {
   assertEquals(overlayString(String, String, int, int) failed,
foo foor baz, StringUtils.overlayString(SENTENCE, FOO, 4, 6) 
);
   }
   
  -public void testRepeat()
  -{
  +public void testRepeat() {
   assertEquals(repeat(String, int) failed,
FOO + FOO + FOO, StringUtils.repeat(FOO, 3) );
   }
   
  -public void testCenter()
  -{
  +public void testCenter() {
   assertEquals(center(String, int) failed,
   +FOO+   , StringUtils.center(FOO, 9) );
   }
   
  -public void testChompFunctions()
  

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2002-11-27 Thread bayard
bayard  2002/11/27 14:54:29

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Added a the fix for bug #14883.
  
  Submitted-by: Thomas Hawtin [[EMAIL PROTECTED]]
  
  Revision  ChangesPath
  1.27  +4 -1  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- StringUtils.java  23 Nov 2002 00:54:24 -  1.26
  +++ StringUtils.java  27 Nov 2002 22:54:29 -  1.27
  @@ -1398,6 +1398,9 @@
* @throws NullPointerException if sub is codenull/code
*/
   public static int countMatches(String str, String sub) {
  +if (sub.equals()) {
  +return 0;
  +}
   if (str == null) {
   return 0;
   }
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2002-11-22 Thread bayard
bayard  2002/11/22 16:54:24

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Added the second fix from Mark McDowell [[EMAIL PROTECTED]] for bug #14062
  
  Revision  ChangesPath
  1.26  +8 -9  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- StringUtils.java  16 Nov 2002 10:41:03 -  1.25
  +++ StringUtils.java  23 Nov 2002 00:54:24 -  1.26
  @@ -487,22 +487,21 @@
   
   String[] list = new String[listSize];
   int i = 0;
  +int lastTokenBegin = 0;
  +int lastTokenEnd = 0;
   while (tok.hasMoreTokens()) {
   if (max  0  i == listSize - 1) {
   // In the situation where we hit the max yet have
   // tokens left over in our input, the last list
   // element gets all remaining text.
  -StringBuffer buf = new StringBuffer((int) 1.2 * str.length() * 
(listSize - i) / listSize);
  -while (tok.hasMoreTokens()) {
  -buf.append(tok.nextToken());
  -if (tok.hasMoreTokens()) {
  -buf.append(separator);
  -}
  -}
  -list[i] = buf.toString();
  +String endToken = tok.nextToken();
  +lastTokenBegin = str.indexOf(endToken, lastTokenEnd);
  +list[i] = str.substring(lastTokenBegin);
   break;
   } else {
   list[i] = tok.nextToken();
  +lastTokenBegin = str.indexOf(list[i], lastTokenEnd);
  +lastTokenEnd = lastTokenBegin + list[i].length();
   }
   i++;
   }
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2002-11-22 Thread bayard
bayard  2002/11/22 17:06:56

  Modified:lang/src/test/org/apache/commons/lang Tag: LANG_1_0_BRANCH
StringUtilsTest.java
   lang/src/java/org/apache/commons/lang Tag: LANG_1_0_BRANCH
StringUtils.java
  Log:
  Put in a Unit Test to check for bug #14062 and the fix.
  The fix is courtesy of Mark McDowell [[EMAIL PROTECTED]]
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.5.2.1   +7 -1  
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- StringUtilsTest.java  19 Sep 2002 07:02:30 -  1.5
  +++ StringUtilsTest.java  23 Nov 2002 01:06:56 -  1.5.2.1
  @@ -183,6 +183,12 @@
   assertEquals(split(Object[], String, int) failed, expected[i],
result[i]);
   }
  +
  +result = StringUtils.split(one two three four five six, null, 3);
  +assertEquals(split(Object[], null, int)[0] failed, one, result[0]);
  +assertEquals(split(Object[], null, int)[1] failed, two, result[1]);
  +assertEquals(split(Object[], null, int)[2] failed, three four five six, 
result[2]); 
  +
   }
   
   public void testReplaceFunctions()
  
  
  
  No   revision
  
  
  No   revision
  
  
  1.18.2.1  +9 -10 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.18
  retrieving revision 1.18.2.1
  diff -u -r1.18 -r1.18.2.1
  --- StringUtils.java  30 Sep 2002 00:50:10 -  1.18
  +++ StringUtils.java  23 Nov 2002 01:06:56 -  1.18.2.1
  @@ -459,25 +459,24 @@
   
   String[] list = new String[listSize];
   int i = 0;
  +   int lastTokenBegin = 0;
  +int lastTokenEnd = 0;
   while (tok.hasMoreTokens()) {
   if (max  0  i == listSize - 1) {
   // In the situation where we hit the max yet have
   // tokens left over in our input, the last list
   // element gets all remaining text.
  -StringBuffer buf = new StringBuffer((int) 1.2 * str.length() * 
(listSize - i) / listSize);
  -while (tok.hasMoreTokens()) {
  -buf.append(tok.nextToken());
  -if (tok.hasMoreTokens()) {
  -buf.append(separator);
  -}
  -}
  -list[i] = buf.toString();
  +String endToken = tok.nextToken();
  +lastTokenBegin = str.indexOf(endToken, lastTokenEnd);
  +list[i] = str.substring(lastTokenBegin);
   break;
   } else {
   list[i] = tok.nextToken();
  +lastTokenBegin = str.indexOf(list[i], lastTokenEnd);
  +lastTokenEnd = lastTokenBegin + list[i].length();
   }
   i++;
  -}
  +}  
   return list;
   }
   
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2002-11-14 Thread scolebourne
scolebourne2002/11/14 16:06:40

  Modified:lang/src/test/org/apache/commons/lang StringUtilsIsTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Change the isTrue() method to cope with strings case insensitively
  
  Revision  ChangesPath
  1.3   +5 -1  
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsIsTest.java
  
  Index: StringUtilsIsTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsIsTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StringUtilsIsTest.java28 Oct 2002 04:33:29 -  1.2
  +++ StringUtilsIsTest.java15 Nov 2002 00:06:40 -  1.3
   -139,6 +139,10 
   assertEquals(true, StringUtils.isTrue(true));
   assertEquals(true, StringUtils.isTrue(yes));
   assertEquals(true, StringUtils.isTrue(on));
  +assertEquals(true, StringUtils.isTrue(TRUE));
  +assertEquals(true, StringUtils.isTrue(ON));
  +assertEquals(true, StringUtils.isTrue(YES));
  +assertEquals(true, StringUtils.isTrue(TruE));
   }
   
   public void testIsAlphaspace() {
  
  
  
  1.23  +6 -8  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- StringUtils.java  14 Nov 2002 22:29:25 -  1.22
  +++ StringUtils.java  15 Nov 2002 00:06:40 -  1.23
   -1502,19 +1502,17 
   
   /**
* Checks if the String contains a 'true' value. These are defined 
  - * as the words 'true', 'on' and 'yes'.
  + * as the words 'true', 'on' and 'yes', case insensitive.
*
* param str the String to check
  - * return true if the string is 'true|on|yes'
  + * return true if the string is 'true|on|yes' case insensitive
*/
   public static boolean isTrue(String str) {
  -if(true.equals(str)) {
  +if (true.equalsIgnoreCase(str)) {
   return true;
  -} else
  -if(on.equals(str)) {
  +} else if (on.equalsIgnoreCase(str)) {
   return true;
  -} else
  -if(yes.equals(str)) {
  +} else if (yes.equalsIgnoreCase(str)) {
   return true;
   }
   return false;
  
  
  

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




cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java ArrayUtils.java

2002-11-14 Thread scolebourne
scolebourne2002/11/14 16:25:45

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
ArrayUtils.java
  Log:
  Javadoc fixes, from Fredrik Westermarck
  
  Revision  ChangesPath
  1.24  +2 -2  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- StringUtils.java  15 Nov 2002 00:06:40 -  1.23
  +++ StringUtils.java  15 Nov 2002 00:25:45 -  1.24
   -1525,7 +1525,7 
* Returns either the passed in Object as a String, or,
* if the Object is codenull/code, an empty String.
* 
  - * param str the Object to check
  + * param obj the Object to check
* return the passed in Object's toString, or blank if it was null
*/
   public static String defaultString(Object obj) {
  
  
  
  1.3   +26 -17
jakarta-commons/lang/src/java/org/apache/commons/lang/ArrayUtils.java
  
  Index: ArrayUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/ArrayUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ArrayUtils.java   14 Nov 2002 22:29:25 -  1.2
  +++ ArrayUtils.java   15 Nov 2002 00:25:45 -  1.3
   -64,6 +64,7 
*
* author a href=mailto:scolebourne;apache.orgStephen Colebourne/a
* author Moritz Petersen
  + * author a href=mailto:fredrik;westermarck.comFredrik Westermarck/a
* version $Id$
*/
   public class ArrayUtils {
   -397,7 +398,8 
* 
* param array1 the first array, may be codenull/code
* param array2 the second array, may be codenull/code
  - * param true if length of arrays matches, treating codenull/code as an 
empty array
  + * return codetrue/code if length of arrays matches, treating
  + *  codenull/code as an empty array
*/
   public static boolean isSameLength(Object[] array1, Object[] array2) {
   if ((array1 == null  array2 != null  array2.length  0) ||
   -415,8 +417,9 
* 
* param array1 the first array, may be codenull/code
* param array2 the second array, may be codenull/code
  - * param true if length of arrays matches, treating codenull/code as an 
empty array
  - */
  + * return codetrue/code if length of arrays matches, treating
  + *  codenull/code as an empty array
  + */
   public static boolean isSameLength(long[] array1, long[] array2) {
   if ((array1 == null  array2 != null  array2.length  0) ||
   (array2 == null  array1 != null  array1.length  0) ||
   -433,8 +436,9 
* 
* param array1 the first array, may be codenull/code
* param array2 the second array, may be codenull/code
  - * param true if length of arrays matches, treating codenull/code as an 
empty array
  - */
  + * return codetrue/code if length of arrays matches, treating
  + *  codenull/code as an empty array
  + */
   public static boolean isSameLength(int[] array1, int[] array2) {
   if ((array1 == null  array2 != null  array2.length  0) ||
   (array2 == null  array1 != null  array1.length  0) ||
   -451,8 +455,9 
* 
* param array1 the first array, may be codenull/code
* param array2 the second array, may be codenull/code
  - * param true if length of arrays matches, treating codenull/code as an 
empty array
  - */
  + * return codetrue/code if length of arrays matches, treating
  + *  codenull/code as an empty array
  + */
   public static boolean isSameLength(short[] array1, short[] array2) {
   if ((array1 == null  array2 != null  array2.length  0) ||
   (array2 == null  array1 != null  array1.length  0) ||
   -469,8 +474,9 
* 
* param array1 the first array, may be codenull/code
* param array2 the second array, may be codenull/code
  - * param true if length of arrays matches, treating codenull/code as an 
empty array
  - */
  + * return codetrue/code if length of arrays matches, treating
  + *  codenull/code as an empty array
  + */
   public static boolean isSameLength(byte[] array1, byte[] array2) {
   if ((array1 == null  array2 != null  array2.length  0) ||
   (array2 == null  array1 != null  array1.length  0) ||
   -487,8 +493,9 
* 
* param array1 the first array, may be codenull/code
* param array2 the second array, may be codenull/code
  - * param true if length of arrays matches, treating codenull/code as an 
empty array
  - */
  + * return 

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2002-10-19 Thread bayard
bayard  2002/10/19 10:18:50

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Javadoc fixing patch applied form Fredrik Westermark
  
  Revision  ChangesPath
  1.19  +240 -226  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- StringUtils.java  30 Sep 2002 00:50:10 -  1.18
  +++ StringUtils.java  19 Oct 2002 17:18:49 -  1.19
   -70,9 +70,9 
* author a href=mailto:gcoladonato;yahoo.comGreg Coladonato/a
* author a href=mailto:bayard;generationjava.comHenri Yandell/a
* author a href=mailto:ed;apache.orgEd Korthof/a
  - * author a href=mailto:rand_mcneely;yahoo.comRand McNeely/a
  - * author a href=mailto:scolebourne;joda.orgStephen Colebourne/a
  - * author a href=mailto:fredrik;westermarck.comFredrik Westermarck/a
  + * author a href=mailto:rand_mcneely;yahoo.comRand McNeely/a
  + * author a href=mailto:scolebourne;joda.orgStephen Colebourne/a
  + * author a href=mailto:fredrik;westermarck.comFredrik Westermarck/a
* version $Id$
*/
   public class StringUtils {
   -90,11 +90,11 
   //--
   
   /**
  - * Removes control characters, including whitespace,  from both ends of this 
  - * string, handling null by returning an empty string.
  + * Removes control characters, including whitespace, from both ends of this
  + * String, handling codenull/code by returning an empty String.
*
* see java.lang.String#trim()
  - * param str  the string to check
  + * param str the String to check
* return the trimmed text (never codenull/code)
*/
   public static String clean(String str) {
   -102,11 +102,11 
   }
   
   /**
  - * Removes control characters,  including whitespace, from both ends of this
  - * string, handling null by returning null. 
  + * Removes control characters, including whitespace, from both ends of this
  + * String, handling codenull/code by returning codenull/code.
*
* see java.lang.String#trim()
  - * param str  the string to check
  + * param str the String to check
* return the trimmed text (or codenull/code)
*/
   public static String trim(String str) {
   -118,8 +118,8 
* Spaces are defined as {' ', '\t', '\r', '\n', '\b'}
* in line with the deprecated Character.isSpace
*
  - * param str  String target to delete spaces from
  - * return the text without spaces
  + * param str String target to delete spaces from
  + * return the String without spaces
* throws NullPointerException
*/
   public static String deleteSpaces(String str) {
   -127,11 +127,11 
   }
   
   /**
  - * Deletes all whitespace from a String.
  + * Deletes all whitespaces from a String.
* Whitespace is defined by Character.isWhitespace
*
  - * param str  String target to delete whitespace from
  - * return the text without whitespace
  + * param str String target to delete whitespace from
  + * return the String without whitespaces
* throws NullPointerException
*/
   public static String deleteWhitespace(String str) {
   -148,7 +148,7 
   /**
* Checks if a String is non null and is not empty (length  0).
*
  - * param str  the string to check
  + * param str the String to check
* return true if the String is non-null, and not length zero
*/
   public static boolean isNotEmpty(String str) {
   -156,10 +156,10 
   }
   
   /**
  - * Checks if a (trimmed) String is null or empty.
  + * Checks if a (trimmed) String is codenull/code or empty.
*
  - * param str  the string to check
  - * return true if the String is null, or length zero once trimmed
  + * param str the String to check
  + * return true if the String is codenull/code, or length zero once trimmed
*/
   public static boolean isEmpty(String str) {
   return (str == null || str.trim().length() == 0);
   -169,40 +169,41 
   //--
   
   /**
  - * Compares two Strings, returning true if they are equal.
  - * Nulls are handled without exceptions. Two codenull/code
  - * references are considered equal. Comparison is case sensitive.
  + * Compares two Strings, returning codetrue/code if they are equal.
  + * codenull/codes are handled without exceptions. Two codenull/code
  + * references are considered to be equal. The comparison is case sensitive.
*
  

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2002-09-26 Thread bayard

bayard  2002/09/26 22:53:37

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Added a patch with many improvements to the javadoc from Steve Downey.
  
  Submitted by: Steve Downey
  
  Revision  ChangesPath
  1.14  +47 -14
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- StringUtils.java  25 Sep 2002 03:30:19 -  1.13
  +++ StringUtils.java  27 Sep 2002 05:53:37 -  1.14
  @@ -95,8 +95,8 @@
   //--
   
   /**
  - * Removes white space from both ends of this string, handling null
  - * by returning an empty string.
  + * Removes control characters, including whitespace,  from both ends of this 
  + * string, handling null by returning an empty string.
*
* @see java.lang.String#trim()
* @param str  the string to check
  @@ -107,8 +107,8 @@
   }
   
   /**
  - * Removes white space from both ends of this string, handling null
  - * by returning null.
  + * Removes control characters,  including whitespace, from both ends of this
  + * string, handling null by returning null. 
*
* @see java.lang.String#trim()
* @param str  the string to check
  @@ -120,9 +120,11 @@
   
   /**
* Deletes all whitespace from a String.
  + * Whitespace is defined as {' ', '\t', '\r', '\n', '\b'}
*
* @param str  String target to delete whitespace from
* @return the text without whitespace
  + * @throws NullPointerException
*/
   public static String deleteWhitespace(String str) {
   return CharSetUtils.delete(str,  \t\r\n\b);
  @@ -156,6 +158,7 @@
* Nulls are handled without exceptions. Two codenull/code
* references are considered equal. Comparison is case sensitive.
*
  + * @see java.lang.String#equals(String)
* @param str1  the first string
* @param str2  the second string
* @return true if the Strings are equal, case sensitive, or both null
  @@ -168,7 +171,7 @@
* Compares two Strings, returning true if they are equal ignoring case.
* Nulls are handled without exceptions. Two codenull/code
* references are considered equal. Comparison is case insensitive.
  - *
  + * @see java.lang.String#equalsIgnoreCase(String)
* @param str1  the first string
* @param str2  the second string
* @return true if the Strings are equal, case insensitive, or both null
  @@ -184,6 +187,7 @@
* @param str  the string to check
* @param searchStrs  the strings to search for
* @return the earliest index of any of the strings
  + * @throws NullPointerException if any of searchStrs[i] is null
*/
   public static int indexOfAny(String str, String[] searchStrs) {
   if ((str == null) || (searchStrs == null)) {
  @@ -216,6 +220,7 @@
* @param str  the string to check
* @param searchStrs  the strings to search for
* @return the last index of any of the strings
  + * @throws NullPointerException if any of searchStrs[i] is null
*/
   public static int lastIndexOfAny(String str, String[] searchStrs) {
   if ((str == null) || (searchStrs == null)) {
  @@ -569,6 +574,7 @@
* @param max  maximum number of values to replace, or
* code-1/code if no maximum
* @return the text with any replacements processed
  + * @throws NullPointerException if repl is null
*/
   public static String replace(String text, String repl, String with,
int max) {
  @@ -598,6 +604,7 @@
* @param start int to start overlaying at
* @param end   int to stop overlaying before
* @return String with overlayed text
  + * @throws NullPointerException if text or overlay is null
*/
   public static String overlayString(String text, String overlay, int start, int 
end) {
   return new StringBuffer(start + overlay.length() + text.length() - end + 1)
  @@ -612,11 +619,13 @@
   
   /**
* Center a string in a larger string of size n.
  - * Uses spaces as the value to buffer the string with..
  + * Uses spaces as the value to buffer the string with.
  + * Equivalent to codecenter(str, size, )/code
*
* @param str  String to center
* @param size  int size of new String
* @return String containing centered String
  + * @throws NullPointerException if str is null
*/
   public static String center(String str, int size) {
   

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2002-09-26 Thread bayard

bayard  2002/09/26 23:08:17

  Modified:lang/src/test/org/apache/commons/lang
StringUtilsTrimEmptyTest.java
   lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Changed the deleteWhitespace method to delete according to Character.isWhitespce
  Renamed the existing deleteWhitespace functionality to deleteSpaces.
  This is in accordance with Character.isSpace.
  
  Submitted by: Steve Downey's idea
  
  Revision  ChangesPath
  1.5   +17 -4 
jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
  
  Index: StringUtilsTrimEmptyTest.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StringUtilsTrimEmptyTest.java 21 Jul 2002 20:19:50 -  1.4
  +++ StringUtilsTrimEmptyTest.java 27 Sep 2002 06:08:16 -  1.5
  @@ -122,13 +122,26 @@
   assertEquals(true, StringUtils.isEmpty(null));
   }
   
  -public void testDeleteWhitespace() {
  +public void testDeleteSpace() {
   assertEquals(deleteWhitespace(String) failed,
, StringUtils.deleteWhitespace());
   assertEquals(deleteWhitespace(String) failed,
  - , StringUtils.deleteWhitespace(\t\t\n\n   ));
  + , StringUtils.deleteWhitespace(  \u000C  \t\t\u001F\n\n 
\u000B  ));
  +// Note: u-2007 and u-000A both cause problems in the source code
  +// it should ignore 2007 but delete 000A
   assertEquals(deleteWhitespace(String) failed,
  - test, StringUtils.deleteWhitespace(t  \t\ne\rs\n\n   \tt));
  + \u00A0\u202F, StringUtils.deleteWhitespace(  \u00A0  
\t\t\n\n \u202F  ));
  +assertEquals(deleteWhitespace(String) failed,
  + \u00A0\u202F, StringUtils.deleteWhitespace(\u00A0\u202F));
  +assertEquals(deleteWhitespace(String) failed,
  + test, StringUtils.deleteWhitespace(\u000Bt  
\t\n\u0009e\rs\n\n   \tt));
  +
  +assertEquals(deleteSpaces(String) failed,
  + , StringUtils.deleteSpaces());
  +assertEquals(deleteSpaces(String) failed,
  + , StringUtils.deleteSpaces(\t\t\n\n   ));
  +assertEquals(deleteSpaces(String) failed,
  + test, StringUtils.deleteSpaces(t  \t\ne\rs\n\n   \tt));
   }
   
   public void testStrip() {
  
  
  
  1.15  +23 -3 
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- StringUtils.java  27 Sep 2002 05:53:37 -  1.14
  +++ StringUtils.java  27 Sep 2002 06:08:16 -  1.15
  @@ -119,15 +119,35 @@
   }
   
   /**
  + * Deletes all 'space' characters from a String.
  + * Spaces are defined as {' ', '\t', '\r', '\n', '\b'}
  + * in line with the deprecated Character.isSpace
  + *
  + * @param str  String target to delete spaces from
  + * @return the text without spaces
  + * @throws NullPointerException
  + */
  +public static String deleteSpaces(String str) {
  +return CharSetUtils.delete(str,  \t\r\n\b);
  +}
  +
  +/**
* Deletes all whitespace from a String.
  - * Whitespace is defined as {' ', '\t', '\r', '\n', '\b'}
  + * Whitespace is defined by Character.isWhitespace
*
* @param str  String target to delete whitespace from
* @return the text without whitespace
* @throws NullPointerException
*/
   public static String deleteWhitespace(String str) {
  -return CharSetUtils.delete(str,  \t\r\n\b);
  +StringBuffer buffer = new StringBuffer();
  +int sz = str.length();
  +for (int i=0; isz; i++) {
  +if(!Character.isWhitespace(str.charAt(i))) {
  +buffer.append(str.charAt(i));
  +}
  +}
  +return buffer.toString();
   }
   
   /**
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang StringUtils.java

2002-09-24 Thread bayard

bayard  2002/09/24 20:30:19

  Modified:lang/src/java/org/apache/commons/lang StringUtils.java
  Log:
  Changed my name from 'Bayard'. Yeah yeah.
  
  Revision  ChangesPath
  1.13  +9 -9  
jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java
  
  Index: StringUtils.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/StringUtils.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- StringUtils.java  21 Sep 2002 05:02:43 -  1.12
  +++ StringUtils.java  25 Sep 2002 03:30:19 -  1.13
  @@ -68,7 +68,7 @@
* @author a href=mailto:[EMAIL PROTECTED];Jon S. Stevens/a
* @author a href=mailto:[EMAIL PROTECTED];Daniel Rall/a
* @author a href=mailto:[EMAIL PROTECTED];Greg Coladonato/a
  - * @author a href=mailto:[EMAIL PROTECTED];Bayard/a
  + * @author a href=mailto:[EMAIL PROTECTED];Henri Yandell/a
* @author a href=mailto:[EMAIL PROTECTED];Ed Korthof/a
* @author a href=mailto:[EMAIL PROTECTED]Rand McNeely/a
* @author a href=mailto:[EMAIL PROTECTED]Stephen Colebourne/a
  @@ -80,7 +80,7 @@
   /**
* The size of the buffer to use when working with I/O (4 kB).
*/
  -public static int CHAR_BUFFER_SIZE = 4 * 1024;
  +public static final int CHAR_BUFFER_SIZE = 4 * 1024;
   
   /**
* StringUtils instances should NOT be constructed in standard programming.
  @@ -1483,7 +1483,7 @@
* 
* @param s  the first String
* @param t  the second String
  - * @param result distance
  + * @return int result distance
*/
   public static int getLevenshteinDistance(String s, String t) {
   int d[][]; // matrix
  @@ -1547,22 +1547,22 @@
* @return true if it only contains valid chars and is non-null
*/
   public static boolean containsOnly(String str, char[] valid) {
  -if(str == null || valid == null) {
  +if (str == null || valid == null) {
   return false;
   }
   
   int strSize = str.length();
   int validSize = valid.length;
   
  -for(int i=0; istrSize; i++) {
  +for (int i = 0; i  strSize; i++) {
   boolean contains = false;
  -for(int j=0; jvalidSize; j++) {
  -if(valid[j] == str.charAt(i)) {
  +for (int j = 0; j  validSize; j++) {
  +if (valid[j] == str.charAt(i)) {
   contains = true;
   break;
   }
   }
  -if(!contains) {
  +if (!contains) {
   return false;
   }
   }
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]