Last change
on this file was
53,
checked in by zeiss, 14 years ago
|
|
-
Property svn:mime-type set to
text/plain
|
File size:
1.3 KB
|
Line | |
---|
1 | package de.ugoe.cs.swe.bnftools.validation;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | public class RuleDuplication {
|
---|
7 | List<DuplicateEntry> dupes = new ArrayList<DuplicateEntry>();
|
---|
8 |
|
---|
9 | public List<DuplicateEntry> getDupes() {
|
---|
10 | return dupes;
|
---|
11 | }
|
---|
12 |
|
---|
13 | public void setDupes(List<DuplicateEntry> dupes) {
|
---|
14 | this.dupes = dupes;
|
---|
15 | }
|
---|
16 |
|
---|
17 | public void addDupe(DuplicateEntry dupe) {
|
---|
18 | dupes.add(dupe);
|
---|
19 | }
|
---|
20 |
|
---|
21 | public List<DuplicateEntry> getFilteredDupes() {
|
---|
22 | ArrayList<DuplicateEntry> dupesFiltered = new ArrayList<DuplicateEntry>();
|
---|
23 |
|
---|
24 | dupesFiltered.addAll(dupes);
|
---|
25 |
|
---|
26 | boolean change = true;
|
---|
27 | while (change) {
|
---|
28 | change = false;
|
---|
29 | for (int i=0; i < dupesFiltered.size(); i++) {
|
---|
30 | for (int j=0; j < dupesFiltered.size(); j++) {
|
---|
31 | DuplicateEntry dupeA = dupesFiltered.get(i);
|
---|
32 | DuplicateEntry dupeB = dupesFiltered.get(j);
|
---|
33 |
|
---|
34 | if (dupeA.getSnippet().contains(dupeB.getSnippet()) && !dupeA.getSnippet().equals(dupeB.getSnippet())) {
|
---|
35 | dupesFiltered.remove(j);
|
---|
36 | change = true;
|
---|
37 | } else if (dupeB.getSnippet().contains(dupeA.getSnippet()) && !dupeB.getSnippet().equals(dupeA.getSnippet())) {
|
---|
38 | dupesFiltered.remove(i);
|
---|
39 | change = true;
|
---|
40 | }
|
---|
41 | if (change)
|
---|
42 | break;
|
---|
43 | }
|
---|
44 | if (change)
|
---|
45 | break;
|
---|
46 | }
|
---|
47 | }
|
---|
48 |
|
---|
49 | return dupesFiltered;
|
---|
50 | }
|
---|
51 |
|
---|
52 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.