]> git.argeo.org Git - gpl/argeo-slc.git/blob - legacy/org.argeo.slc.support/src/org/argeo/slc/diff/TableDiffPosition.java
Clarify overall project structure.
[gpl/argeo-slc.git] / legacy / org.argeo.slc.support / src / org / argeo / slc / diff / TableDiffPosition.java
1 package org.argeo.slc.diff;
2
3 import org.argeo.slc.UnsupportedException;
4
5 /**
6 * A diff position within a table structure such a CSV file or an SQL result
7 * set.
8 */
9 public class TableDiffPosition extends DiffPosition {
10 private Integer line;
11 /** Can be null */
12 private Integer column;
13 /** Can be null */
14 private String columnName;
15
16 public TableDiffPosition(RelatedFile relatedFile, Integer line,
17 Integer column, String columnName) {
18 super(relatedFile);
19 this.line = line;
20 this.column = column;
21 this.columnName = columnName;
22 }
23
24 @SuppressWarnings("unused")
25 private TableDiffPosition() {
26 }
27
28 public Integer getLine() {
29 return line;
30 }
31
32 public Integer getColumn() {
33 return column;
34 }
35
36 public String getColumnName() {
37 return columnName;
38 }
39
40 public int compareTo(DiffPosition dp) {
41 if (!(dp instanceof TableDiffPosition))
42 throw new UnsupportedException("position", dp);
43
44 TableDiffPosition o = (TableDiffPosition) dp;
45 if (relatedFile.equals(o.relatedFile)) {
46 if (line == o.line) {
47 return column.compareTo(o.column);
48 } else {
49 return line.compareTo(o.line);
50 }
51 } else {
52 return relatedFile.compareTo(o.relatedFile);
53 }
54 }
55
56 @Override
57 public String toString() {
58 StringBuffer buf = new StringBuffer("");
59 buf.append(relatedFile).append('[').append(line);
60 if (column != null) {
61 buf.append(',').append(column);
62 if (columnName != null) {
63 buf.append('-').append(columnName);
64 }
65 }
66 buf.append(']');
67 return buf.toString();
68 }
69
70 // Hibernate
71 @SuppressWarnings("unused")
72 private void setLine(Integer line) {
73 this.line = line;
74 }
75
76 @SuppressWarnings("unused")
77 private void setColumn(Integer column) {
78 this.column = column;
79 }
80
81 @SuppressWarnings("unused")
82 private void setColumnName(String columnName) {
83 this.columnName = columnName;
84 }
85
86 }