[1734] | 1 | /* |
---|
| 2 | * |
---|
| 3 | */ |
---|
[1620] | 4 | package de.ugoe.cs.autoquest.tasktrees.alignment.algorithms; |
---|
| 5 | |
---|
[1717] | 6 | import java.io.Serializable; |
---|
[1620] | 7 | import java.util.ArrayList; |
---|
| 8 | import java.util.LinkedList; |
---|
| 9 | |
---|
[1734] | 10 | // TODO: Auto-generated Javadoc |
---|
| 11 | /** |
---|
| 12 | * The Class Match. |
---|
| 13 | */ |
---|
[1733] | 14 | public class Match implements Serializable { |
---|
[1734] | 15 | |
---|
| 16 | /** The Constant serialVersionUID. */ |
---|
[1717] | 17 | private static final long serialVersionUID = -3206992723755714741L; |
---|
| 18 | |
---|
[1734] | 19 | /** The matchseqs. */ |
---|
[1733] | 20 | private final ArrayList<NumberSequence> matchseqs; |
---|
[1621] | 21 | |
---|
[1734] | 22 | /** The occurences. */ |
---|
[1621] | 23 | private LinkedList<MatchOccurence> occurences; |
---|
| 24 | |
---|
[1734] | 25 | /** |
---|
| 26 | * Instantiates a new match. |
---|
| 27 | */ |
---|
[1693] | 28 | public Match() { |
---|
[1620] | 29 | matchseqs = new ArrayList<NumberSequence>(2); |
---|
| 30 | occurences = new LinkedList<MatchOccurence>(); |
---|
| 31 | matchseqs.add(null); |
---|
| 32 | matchseqs.add(null); |
---|
| 33 | } |
---|
[1621] | 34 | |
---|
[1734] | 35 | /** |
---|
| 36 | * Adds the occurence. |
---|
| 37 | * |
---|
| 38 | * @param occurence the occurence |
---|
| 39 | */ |
---|
[1620] | 40 | public void addOccurence(MatchOccurence occurence) { |
---|
| 41 | occurences.add(occurence); |
---|
| 42 | } |
---|
[1621] | 43 | |
---|
[1734] | 44 | /** |
---|
| 45 | * Adds the occurences of. |
---|
| 46 | * |
---|
| 47 | * @param m the m |
---|
| 48 | */ |
---|
[1733] | 49 | public void addOccurencesOf(Match m) { |
---|
| 50 | occurences.addAll(m.getOccurences()); |
---|
[1621] | 51 | } |
---|
[1620] | 52 | |
---|
[1734] | 53 | /** |
---|
| 54 | * Equals. |
---|
| 55 | * |
---|
| 56 | * @param m the m |
---|
| 57 | * @return true, if successful |
---|
| 58 | */ |
---|
[1621] | 59 | public boolean equals(Match m) { |
---|
| 60 | if ((m.getFirstSequence().equals(this.getFirstSequence()) || m |
---|
| 61 | .getFirstSequence().equals(this.getSecondSequence())) |
---|
| 62 | && (m.getSecondSequence().equals(this.getFirstSequence()) || m |
---|
| 63 | .getSecondSequence().equals(this.getSecondSequence()))) { |
---|
| 64 | return true; |
---|
| 65 | } |
---|
| 66 | return false; |
---|
| 67 | } |
---|
| 68 | |
---|
[1734] | 69 | /** |
---|
| 70 | * Gets the first sequence. |
---|
| 71 | * |
---|
| 72 | * @return the first sequence |
---|
| 73 | */ |
---|
[1733] | 74 | public NumberSequence getFirstSequence() { |
---|
| 75 | return matchseqs.get(0); |
---|
| 76 | } |
---|
| 77 | |
---|
[1734] | 78 | /** |
---|
| 79 | * Gets the occurences. |
---|
| 80 | * |
---|
| 81 | * @return the occurences |
---|
| 82 | */ |
---|
[1621] | 83 | public LinkedList<MatchOccurence> getOccurences() { |
---|
| 84 | return occurences; |
---|
| 85 | } |
---|
| 86 | |
---|
[1734] | 87 | /** |
---|
| 88 | * Gets the second sequence. |
---|
| 89 | * |
---|
| 90 | * @return the second sequence |
---|
| 91 | */ |
---|
[1733] | 92 | public NumberSequence getSecondSequence() { |
---|
| 93 | return matchseqs.get(1); |
---|
| 94 | } |
---|
| 95 | |
---|
[1734] | 96 | /** |
---|
| 97 | * Occurence count. |
---|
| 98 | * |
---|
| 99 | * @return the int |
---|
| 100 | */ |
---|
[1733] | 101 | public int occurenceCount() { |
---|
| 102 | return occurences.size(); |
---|
| 103 | } |
---|
| 104 | |
---|
[1734] | 105 | /** |
---|
| 106 | * Sets the first sequence. |
---|
| 107 | * |
---|
| 108 | * @param seq the new first sequence |
---|
| 109 | */ |
---|
[1733] | 110 | public void setFirstSequence(NumberSequence seq) { |
---|
| 111 | matchseqs.set(0, seq); |
---|
| 112 | } |
---|
| 113 | |
---|
[1734] | 114 | /** |
---|
| 115 | * Sets the occurences. |
---|
| 116 | * |
---|
| 117 | * @param occurences the new occurences |
---|
| 118 | */ |
---|
[1621] | 119 | public void setOccurences(LinkedList<MatchOccurence> occurences) { |
---|
| 120 | this.occurences = occurences; |
---|
| 121 | } |
---|
| 122 | |
---|
[1734] | 123 | /** |
---|
| 124 | * Sets the second sequence. |
---|
| 125 | * |
---|
| 126 | * @param seq the new second sequence |
---|
| 127 | */ |
---|
[1733] | 128 | public void setSecondSequence(NumberSequence seq) { |
---|
| 129 | matchseqs.set(1, seq); |
---|
[1621] | 130 | } |
---|
| 131 | |
---|
[1734] | 132 | /** |
---|
| 133 | * Size. |
---|
| 134 | * |
---|
| 135 | * @return the int |
---|
| 136 | */ |
---|
[1733] | 137 | public int size() { |
---|
| 138 | // Both sequences should be equally long |
---|
| 139 | return matchseqs.get(0).size(); |
---|
| 140 | } |
---|
| 141 | |
---|
[1620] | 142 | } |
---|