From 03588608e1a4d290bacfad482c827356e65aef51 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Fri, 4 Nov 2016 15:26:44 +0000 Subject: [PATCH] JAL-2292 Wrote utility method for comparing two char either case sensitively or insensitively --- src/jalview/util/Comparison.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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); + } + } } -- 1.7.10.2