From 66d479709f80154ea834491afce7ac894128617e Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 12 Feb 2016 14:53:02 +0000 Subject: [PATCH] JAL-2008 updates for String[] to List change --- src/jalview/analysis/AlignmentSorter.java | 31 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/jalview/analysis/AlignmentSorter.java b/src/jalview/analysis/AlignmentSorter.java index 007d538..5ee4bcb 100755 --- a/src/jalview/analysis/AlignmentSorter.java +++ b/src/jalview/analysis/AlignmentSorter.java @@ -32,6 +32,7 @@ import jalview.util.MessageManager; import jalview.util.QuickSort; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -719,12 +720,13 @@ public class AlignmentSorter int start, int stop, AlignmentI alignment, String method) { sortByFeature(featureLabel == null ? null - : new String[] { featureLabel }, groupLabel == null ? null - : new String[] { groupLabel }, start, stop, alignment, method); + : Arrays.asList(new String[] { featureLabel }), + groupLabel == null ? null + : Arrays.asList(new String[]{ groupLabel }), start, stop, alignment, method); } private static boolean containsIgnoreCase(final String lab, - final String[] labs) + final List labs) { if (labs == null) { @@ -734,9 +736,9 @@ public class AlignmentSorter { return false; } - for (int q = 0; q < labs.length; q++) + for (String label : labs) { - if (labs[q] != null && lab.equalsIgnoreCase(labs[q])) + if (lab.equalsIgnoreCase(label)) { return true; } @@ -744,8 +746,8 @@ public class AlignmentSorter return false; } - public static void sortByFeature(String[] featureLabels, - String[] groupLabels, int start, int stop, AlignmentI alignment, + public static void sortByFeature(List featureLabels, + List groupLabels, int start, int stop, AlignmentI alignment, String method) { if (method != FEATURE_SCORE && method != FEATURE_LABEL @@ -761,14 +763,19 @@ public class AlignmentSorter scoreLabel.append(start + stop + method); // This doesn't quite work yet - we'd like to have a canonical ordering that // can be preserved from call to call - for (int i = 0; featureLabels != null && i < featureLabels.length; i++) + if (featureLabels != null) { - scoreLabel.append(featureLabels[i] == null ? "null" - : featureLabels[i]); + for (String label : featureLabels) + { + scoreLabel.append(label); + } } - for (int i = 0; groupLabels != null && i < groupLabels.length; i++) + if (groupLabels != null) { - scoreLabel.append(groupLabels[i] == null ? "null" : groupLabels[i]); + for (String label : groupLabels) + { + scoreLabel.append(label); + } } /* -- 1.7.10.2