From 435792460e417edc981c308f917f2ff5a7829971 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 1 Nov 2016 21:32:48 +0000 Subject: [PATCH] JAL-966 JAL-345 JAL-1738 decontaminate SearchResultI with references to Match --- src/jalview/datamodel/SearchResults.java | 32 +++++++++++++++++------------ src/jalview/datamodel/SearchResultsI.java | 3 +-- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/jalview/datamodel/SearchResults.java b/src/jalview/datamodel/SearchResults.java index 3cb34de..58f8517 100755 --- a/src/jalview/datamodel/SearchResults.java +++ b/src/jalview/datamodel/SearchResults.java @@ -35,7 +35,7 @@ import java.util.List; public class SearchResults implements SearchResultsI { - private List matches = new ArrayList(); + private List matches = new ArrayList(); /** * One match consists of a sequence reference, start and end positions. @@ -164,12 +164,13 @@ public class SearchResults implements SearchResultsI @Override public boolean equals(Object obj) { - if (obj == null || !(obj instanceof Match)) + if (obj == null || !(obj instanceof SearchResultMatchI)) { return false; } - Match m = (Match) obj; - return (this.sequence == m.sequence && this.start == m.start && this.end == m.end); + SearchResultMatchI m = (SearchResultMatchI) obj; + return (sequence == m.getSequence() && start == m.getStart() && end == m + .getEnd()); } } @@ -189,8 +190,10 @@ public class SearchResults implements SearchResultsI public boolean involvesSequence(SequenceI sequence) { SequenceI ds = sequence.getDatasetSequence(); - for (Match m : matches) + Match m; + for (SearchResultMatchI _m : matches) { + m = (Match) _m; if (m.sequence != null && (m.sequence == sequence || m.sequence == ds)) { @@ -215,8 +218,11 @@ public class SearchResults implements SearchResultsI int[] tmp = null; int resultLength, matchStart = 0, matchEnd = 0; boolean mfound; - for (Match m : matches) + Match m; + for (SearchResultMatchI _m : matches) { + m = (Match) _m; + mfound = false; if (m.sequence == sequence) { @@ -311,7 +317,7 @@ public class SearchResults implements SearchResultsI @Override public SequenceI getResultSequence(int index) { - return matches.get(index).sequence; + return matches.get(index).getSequence(); } /* (non-Javadoc) @@ -320,7 +326,7 @@ public class SearchResults implements SearchResultsI @Override public int getResultStart(int i) { - return matches.get(i).start; + return matches.get(i).getStart(); } /* (non-Javadoc) @@ -329,7 +335,7 @@ public class SearchResults implements SearchResultsI @Override public int getResultEnd(int i) { - return matches.get(i).end; + return matches.get(i).getEnd(); } /* (non-Javadoc) @@ -345,7 +351,7 @@ public class SearchResults implements SearchResultsI * @see jalview.datamodel.SearchResultsI#getResults() */ @Override - public List getResults() + public List getResults() { return matches; } @@ -403,11 +409,11 @@ public class SearchResults implements SearchResultsI @Override public boolean equals(Object obj) { - if (obj == null || !(obj instanceof SearchResults)) + if (obj == null || !(obj instanceof SearchResultsI)) { return false; } - SearchResults sr = (SearchResults) obj; - return ((ArrayList) this.matches).equals(sr.matches); + SearchResultsI sr = (SearchResultsI) obj; + return matches.equals(sr.getResults()); } } diff --git a/src/jalview/datamodel/SearchResultsI.java b/src/jalview/datamodel/SearchResultsI.java index d59f453..bc62a66 100644 --- a/src/jalview/datamodel/SearchResultsI.java +++ b/src/jalview/datamodel/SearchResultsI.java @@ -1,6 +1,5 @@ package jalview.datamodel; -import jalview.datamodel.SearchResults.Match; import java.util.BitSet; import java.util.List; @@ -78,7 +77,7 @@ public interface SearchResultsI * * @return */ - public abstract List getResults(); + public abstract List getResults(); /** * Set bits in a bitfield for all columns in the given sequence collection -- 1.7.10.2