lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [29/52] [abbrv] lucenenet git commit: Added a CompareToOrdinal method to StringSupport to fix string comparison bugs introduced by using string.CompareTo (which isn't similar to Java's String.compareTo method).
Date Thu, 01 Sep 2016 14:39:50 GMT
Added a CompareToOrdinal method to StringSupport to fix string comparison bugs introduced by
using string.CompareTo (which isn't similar to Java's String.compareTo method).


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/1995da25
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/1995da25
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/1995da25

Branch: refs/heads/master
Commit: 1995da25378f745a7868a4d3924134bbe628b0a5
Parents: 053d3ef
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Tue Aug 23 18:24:39 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Tue Aug 23 18:24:39 2016 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Support/StringSupport.cs | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/1995da25/src/Lucene.Net.Core/Support/StringSupport.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/StringSupport.cs b/src/Lucene.Net.Core/Support/StringSupport.cs
index 94f9108..8683b96 100644
--- a/src/Lucene.Net.Core/Support/StringSupport.cs
+++ b/src/Lucene.Net.Core/Support/StringSupport.cs
@@ -14,5 +14,28 @@ namespace Lucene.Net.Support
         {
             return new BytesRef(str.GetBytes(enc));
         }
+
+        /// <summary>
+        /// This method mimics the Java String.compareTo(String) method in that it
+        /// <list type="number">
+        /// <item>Compares the strings using lexographic sorting rules</item>
+        /// <item>Performs a culture-insensitive comparison</item>
+        /// </list>
+        /// This method is a convenience to replace the .NET CompareTo method 
+        /// on all strings, provided the logic does not expect specific values
+        /// but is simply comparing them with <code>></code> or <code><</code>.
+        /// </summary>
+        /// <param name="str"></param>
+        /// <param name="value">The string to compare with.</param>
+        /// <returns>
+        /// An integer that indicates the lexical relationship between the two comparands.
+        /// Less than zero indicates the comparison value is greater than the current string.
+        /// Zero indicates the strings are equal.
+        /// Greater than zero indicates the comparison value is less than the current string.
+        /// </returns>
+        public static int CompareToOrdinal(this string str, string value)
+        {
+            return string.CompareOrdinal(str, value);
+        }
     }
 }
\ No newline at end of file


Mime
View raw message