From: tcofoegbu Date: Fri, 4 Nov 2016 15:26:44 +0000 (+0000) Subject: JAL-2292 Wrote utility method for comparing two char either case sensitively or insen... X-Git-Tag: Release_2_10_1^2~15 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=03588608e1a4d290bacfad482c827356e65aef51;p=jalview.git JAL-2292 Wrote utility method for comparing two char either case sensitively or insensitively --- diff --git a/src/jalview/util/Comparison.java b/src/jalview/util/Comparison.java index 0beb45b..a8ad086 100644 --- a/src/jalview/util/Comparison.java +++ b/src/jalview/util/Comparison.java @@ -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); + } + } }