JAL-2292 Wrote utility method for comparing two char either case sensitively or insen...
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 4 Nov 2016 15:26:44 +0000 (15:26 +0000)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Fri, 4 Nov 2016 15:26:44 +0000 (15:26 +0000)
src/jalview/util/Comparison.java

index 0beb45b..a8ad086 100644 (file)
@@ -415,4 +415,23 @@ public class Comparison
             .size()]);
     return isNucleotide(oneDArray);
   }
+
+  public static boolean compareChars(char c1, char c2, boolean caseSensitive)
+  {
+    boolean sameCase = (Character.isUpperCase(c1) && Character
+            .isUpperCase(c2))
+            || (Character.isLowerCase(c1) && Character.isLowerCase(c2));
+    if (sameCase)
+    {
+      return c1 == c2;
+    }
+    else if (caseSensitive)
+    {
+      return false;
+    }
+    else
+    {
+      return Character.toUpperCase(c1) == Character.toUpperCase(c2);
+    }
+  }
 }