1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.aequo.text;
14
15 import org.abstracthorizon.aequo.CompareEntry;
16 import org.abstracthorizon.aequo.DefaultCompareEntry;
17 import org.abstracthorizon.aequo.util.StringUtils;
18
19
20
21
22
23
24
25 public class TextCompareEntry extends DefaultCompareEntry<String> {
26
27
28 protected int[] lineNumbers;
29
30
31
32
33
34 public TextCompareEntry(String[] lines, int[] lineNumbers) {
35 super(lines);
36 this.lineNumbers = lineNumbers;
37 }
38
39
40
41
42
43
44 public int getLineNumber(int column) {
45 return lineNumbers[column];
46 }
47
48
49
50
51
52 public int[] getLineNumbers() {
53 return lineNumbers;
54 }
55
56
57
58
59
60
61 public void setLineNumber(int column, int lineNumber) {
62 lineNumbers[column] = lineNumber;
63 }
64
65 public void updateEntryStatus() {
66 String left = getData(0);
67 String right = getData(1);
68 if (left == right) {
69 status[0] = EQUAL;
70 } else if ((left != null) && (right != null)) {
71 if (left.equals(right)) {
72 status[0] = EQUAL;
73 status[1] = EQUAL;
74 } else {
75 left = StringUtils.collapseWhitespace(left);
76 right = StringUtils.collapseWhitespace(right);
77 if (left.equals(right)) {
78 status[0] = TextCompareEntry.SIMILAR;
79 status[1] = TextCompareEntry.SIMILAR;
80 } else {
81 status[0] = DIFFERENT;
82 status[1] = DIFFERENT;
83 }
84 }
85 } else {
86 if (left == null) {
87 status[0] = CompareEntry.EMPTY;
88 status[1] = DIFFERENT;
89 } else {
90 status[0] = DIFFERENT;
91 status[1] = CompareEntry.EMPTY;
92 }
93 }
94 }
95 }