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