JAL-354 JAL-1738 add returns SearchResultMatchI instance so it can be cached
[jalview.git] / src / jalview / datamodel / SearchResultsI.java
1 package jalview.datamodel;
2
3
4 import java.util.BitSet;
5 import java.util.List;
6
7 public interface SearchResultsI
8 {
9
10   /**
11    * This method replaces the old search results which merely held an alignment
12    * index of search matches. This broke when sequences were moved around the
13    * alignment
14    * 
15    * @param seq
16    *          Sequence
17    * @param start
18    *          int
19    * @param end
20    *          int
21    * @return SearchResultMatchI instance created for this instance
22    */
23   public abstract SearchResultMatchI addResult(SequenceI seq, int start,
24           int end);
25
26   /**
27    * Quickly check if the given sequence is referred to in the search results
28    * 
29    * @param sequence
30    *          (specific alignment sequence or a dataset sequence)
31    * @return true if the results involve sequence
32    */
33   public abstract boolean involvesSequence(SequenceI sequence);
34
35   /**
36    * This Method returns the search matches which lie between the start and end
37    * points of the sequence in question . It is optimised for returning objects
38    * for drawing on SequenceCanvas
39    * 
40    * @param sequence
41    *          sequence to highlight columns according to matches
42    * @param start
43    *          - first column of visible region
44    * @param end
45    *          - last column of visible region
46    * @return int[] ranges within start/end index on sequence
47    */
48   public abstract int[] getResults(SequenceI sequence, int start, int end);
49
50   public abstract int getSize();
51
52   public abstract SequenceI getResultSequence(int index);
53
54   /**
55    * Returns the start position of the i'th match in the search results.
56    * 
57    * @param i
58    * @return
59    */
60   public abstract int getResultStart(int i);
61
62   /**
63    * Returns the end position of the i'th match in the search results.
64    * 
65    * @param i
66    * @return
67    */
68   public abstract int getResultEnd(int i);
69
70   /**
71    * Returns true if no search result matches are held.
72    * 
73    * @return
74    */
75   public abstract boolean isEmpty();
76
77   /**
78    * Returns the list of matches.
79    * 
80    * @return
81    */
82   public abstract List<SearchResultMatchI> getResults();
83
84   /**
85    * Set bits in a bitfield for all columns in the given sequence collection
86    * that are highlighted
87    * 
88    * @param sqcol
89    *          the set of sequences to search for highlighted regions
90    * @param bs
91    *          bitset to set
92    * @return number of bits set
93    */
94   public abstract int markColumns(SequenceCollectionI sqcol, BitSet bs);
95 }