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