You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "analogue (JIRA)" <ji...@apache.org> on 2006/06/05 20:54:30 UTC
[jira] Created: (LANG-263) [lang] Add
StringUtils.containsIgnoreCase(...)
[lang] Add StringUtils.containsIgnoreCase(...)
----------------------------------------------
Key: LANG-263
URL: http://issues.apache.org/jira/browse/LANG-263
Project: Commons Lang
Type: New Feature
Versions: 2.2, 3.0
Reporter: analogue
Priority: Minor
To complement StringUtils.equalsIgnoreCase(...), StringUtils.containsIgnoreCase(...) would be quite useful. A simple implementation would uppercase both strings and delegate to StringUtils.contains(...).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Resolved: (LANG-263) [lang] Add
StringUtils.containsIgnoreCase(...)
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-263?page=all ]
Henri Yandell resolved LANG-263:
--------------------------------
Fix Version: 2.2
(was: 3.0)
Resolution: Fixed
Thanks for the patch. Committed and will appear in Lang 2.2 (and nightly builds tonight).
svn ci -m "Added containsIgnoreCase method - LANG-263" src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java src/java/org/apache/commons/lang/StringUtils.java
Sending src/java/org/apache/commons/lang/StringUtils.java
Sending src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java
Transmitting file data ..
Committed revision 412200.
> [lang] Add StringUtils.containsIgnoreCase(...)
> ----------------------------------------------
>
> Key: LANG-263
> URL: http://issues.apache.org/jira/browse/LANG-263
> Project: Commons Lang
> Type: New Feature
> Reporter: analogue
> Priority: Minor
> Fix For: 2.2
>
> To complement StringUtils.equalsIgnoreCase(...), StringUtils.containsIgnoreCase(...) would be quite useful. A simple implementation would uppercase both strings and delegate to StringUtils.contains(...).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (LANG-263) [lang] Add
StringUtils.containsIgnoreCase(...)
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-263?page=all ]
Henri Yandell updated LANG-263:
-------------------------------
Issue Type: Improvement (was: New Feature)
> [lang] Add StringUtils.containsIgnoreCase(...)
> ----------------------------------------------
>
> Key: LANG-263
> URL: http://issues.apache.org/jira/browse/LANG-263
> Project: Commons Lang
> Issue Type: Improvement
> Reporter: analogue
> Priority: Minor
> Fix For: 2.2
>
>
> To complement StringUtils.equalsIgnoreCase(...), StringUtils.containsIgnoreCase(...) would be quite useful. A simple implementation would uppercase both strings and delegate to StringUtils.contains(...).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (LANG-263) [lang] Add
StringUtils.containsIgnoreCase(...)
Posted by "analogue (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-263?page=comments#action_12414966 ]
analogue commented on LANG-263:
-------------------------------
/**
* <p>Checks if String contains a search String irrespective of case,
* handling <code>null</code>. This method uses
* {@link #contains(String, String)}.</p>
*
* <p>A <code>null</code> String will return <code>false</code>.</p>
*
* <pre>
* StringUtils.contains(null, *) = false
* StringUtils.contains(*, null) = false
* StringUtils.contains("", "") = true
* StringUtils.contains("abc", "") = true
* StringUtils.contains("abc", "a") = true
* StringUtils.contains("abc", "z") = false
* StringUtils.contains("abc", "A") = true
* StringUtils.contains("abc", "Z") = false
* </pre>
*
* @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 String irrespective of
* case or false if not or <code>null</code> string input
*/
public static boolean containsIgnoreCase(String str, String searchStr) {
if (str == null || searchStr == null) {
return false;
}
return contains(str.toUpperCase(), searchStr.toUpperCase());
}
public void testContainsIgnoreCase_StringString() {
assertFalse(StringUtils.containsIgnoreCase(null, null));
// Null tests
assertFalse(StringUtils.containsIgnoreCase(null, ""));
assertFalse(StringUtils.containsIgnoreCase(null, "a"));
assertFalse(StringUtils.containsIgnoreCase(null, "abc"));
assertFalse(StringUtils.containsIgnoreCase("", null));
assertFalse(StringUtils.containsIgnoreCase("a", null));
assertFalse(StringUtils.containsIgnoreCase("abc", null));
// Match len = 0
assertTrue(StringUtils.containsIgnoreCase("", ""));
assertTrue(StringUtils.containsIgnoreCase("a", ""));
assertTrue(StringUtils.containsIgnoreCase("abc", ""));
// Match len = 1
assertFalse(StringUtils.containsIgnoreCase("", "a"));
assertTrue(StringUtils.containsIgnoreCase("a", "a"));
assertTrue(StringUtils.containsIgnoreCase("abc", "a"));
assertFalse(StringUtils.containsIgnoreCase("", "A"));
assertTrue(StringUtils.containsIgnoreCase("a", "A"));
assertTrue(StringUtils.containsIgnoreCase("abc", "A"));
// Match len > 1
assertFalse(StringUtils.containsIgnoreCase("", "abc"));
assertFalse(StringUtils.containsIgnoreCase("a", "abc"));
assertTrue(StringUtils.containsIgnoreCase("xabcz", "abc"));
assertFalse(StringUtils.containsIgnoreCase("", "ABC"));
assertFalse(StringUtils.containsIgnoreCase("a", "ABC"));
assertTrue(StringUtils.containsIgnoreCase("xabcz", "ABC"));
}
> [lang] Add StringUtils.containsIgnoreCase(...)
> ----------------------------------------------
>
> Key: LANG-263
> URL: http://issues.apache.org/jira/browse/LANG-263
> Project: Commons Lang
> Type: New Feature
> Reporter: analogue
> Priority: Minor
> Fix For: 3.0
>
> To complement StringUtils.equalsIgnoreCase(...), StringUtils.containsIgnoreCase(...) would be quite useful. A simple implementation would uppercase both strings and delegate to StringUtils.contains(...).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (LANG-263) [lang] Add
StringUtils.containsIgnoreCase(...)
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-263?page=all ]
Henri Yandell updated LANG-263:
-------------------------------
Fix Version: 3.0
Version: (was: 2.2)
Seems like a fair feature.
Feel free to submit a patch + unit test and it'll make its way into 2.2 :)
> [lang] Add StringUtils.containsIgnoreCase(...)
> ----------------------------------------------
>
> Key: LANG-263
> URL: http://issues.apache.org/jira/browse/LANG-263
> Project: Commons Lang
> Type: New Feature
> Reporter: analogue
> Priority: Minor
> Fix For: 3.0
>
> To complement StringUtils.equalsIgnoreCase(...), StringUtils.containsIgnoreCase(...) would be quite useful. A simple implementation would uppercase both strings and delegate to StringUtils.contains(...).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (LANG-263) [lang] Add
StringUtils.containsIgnoreCase(...)
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-263?page=all ]
Henri Yandell updated LANG-263:
-------------------------------
Version: (was: 3.0)
> [lang] Add StringUtils.containsIgnoreCase(...)
> ----------------------------------------------
>
> Key: LANG-263
> URL: http://issues.apache.org/jira/browse/LANG-263
> Project: Commons Lang
> Type: New Feature
> Reporter: analogue
> Priority: Minor
> Fix For: 3.0
>
> To complement StringUtils.equalsIgnoreCase(...), StringUtils.containsIgnoreCase(...) would be quite useful. A simple implementation would uppercase both strings and delegate to StringUtils.contains(...).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org