You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
commit cf2e48a05c250feb636dd337dae1ffb7a1d9d411
Author: Gary D. Gregory <[email protected]>
Date: Mon Mar 8 22:15:08 2010 +0000
Change StringUtils arguments from String to CharSequence.
Details: Working with (trunk) StringUtils (SU) I see the following emerge:
- In SVN already and continuing: Change StringUtils arguments from String to CharSequence (CS).
- This leads to replacing calls to String.substring(int[,int]) with calls to CharSequence.subSequence(int)
- This leads to creating a CharSequenceUtils class (in SVN now, more on this new class below) and CharSequenceUtils.subSequence(CharSequence,int) to avoid changing "str.substring(start)" over and over to "str.subSequence(start, str.length())". For examples, see new versions of capitalize and uncapitalize.
- We end up using a toString() on CharSequence to return a String from StringUtil when working with a CharSequence.
So we have StringUtils using CharSequence inputs as much as possible instead of String, which is nice.
The CharSequence method subSequence returns a CharSequence; though the Javadoc states "Returns a new CharSequence that is a subsequence of this sequence.", this does not guaranteed the return value to be the same kind of CharSequence as the receiver). Since we are after all in a class called StringUtil, calling toString() is a must.
I propose that we create when possible the methods that are now StringUtils CharSequence methods into CharSequenceUtils and let StringUtil call CharSequenceUtils and then do its toString() and other String specific logic. Later we could have other CharSequence type of utils (for CharBuffer, StringBuiler, StringBuffer, etc) that use the 'primitives' from CharSequenceUtils.
This means that for methods that are based solely on methods that are now in CharSequence, these can be moved to CharSequenceUtils without effort (all is* methods only call CharSequence#length() and charAt() for example and are now typed as CS, still in SU).
We can leave @deprecateds method in SU as a nicety to avoid too much porting pain: First change the package to lang3 then you can 'optimize' by changing call sites from SU to CSU.
As a start, I put in SVN a CharSequenceUtils (CSU) implementation for length() and subSequence().
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@920543 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -699,3 +699,3 @@
- public static boolean equals(String str1, String str2) {
- return str1 == null ? str2 == null : str1.equals(str2);
+ public static boolean equals(CharSequence cs1, CharSequence cs2) {
+ return cs1 == null ? cs2 == null : cs1.equals(cs2);
}
commit f349629500ff5a85683dff0a807ff8e9b5b88809
Author: Gary D. Gregory <[email protected]>
Date: Wed Apr 13 22:36:48 2005 +0000
Removed extra C style parens in return statements (as discussed on commons-dev).
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@161229 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/java/org/apache/commons/lang/StringUtils.java b/src/java/org/apache/commons/lang/StringUtils.java
--- a/src/java/org/apache/commons/lang/StringUtils.java
+++ b/src/java/org/apache/commons/lang/StringUtils.java
@@ -668,3 +668,3 @@
public static boolean equals(String str1, String str2) {
- return (str1 == null ? str2 == null : str1.equals(str2));
+ return str1 == null ? str2 == null : str1.equals(str2);
}
commit d23b22c78078ee7468e797e80188ae9508c0eee0
Author: Henri Yandell <[email protected]>
Date: Fri Jul 19 03:35:56 2002 +0000
Initial copy from jakarta-commons-sandbox
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@136932 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/java/org/apache/commons/lang/StringUtils.java b/src/java/org/apache/commons/lang/StringUtils.java
--- /dev/null
+++ b/src/java/org/apache/commons/lang/StringUtils.java
@@ -0,0 +157,3 @@
+ public static boolean equals(String str1, String str2) {
+ return (str1 == null ? str2 == null : str1.equals(str2));
+ }
Can you please look into this issue? Thanks!
The text was updated successfully, but these errors were encountered:
Hi,
I ran CodeShovel on Defects4J, and got some erroneous output.
Steps to reproduce
Install defects4j
Check out
Lang-14b
an reset to the actual buggy versionc8afaa
.defects4j checkout -p Lang -v 14b -w /tmp/Lang-14b cd /tmp/Lang-14b git reset --hard c8afaa
equals
(lines 781-783 insrc/main/java/org/apache/commons/lang3/StringUtils.java
)fec5e4
is the only retrieved commit.Issue
As you can see in the diff below, the retrieved commit
fec5e4
has nothing to do with the target method 'equals'.Git log output
git log -C -M -L 781,783:src/main/java/org/apache/commons/lang3/StringUtils.java
Can you please look into this issue? Thanks!
The text was updated successfully, but these errors were encountered: