]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/diff/TableDiffPosition.java
Introduce a factory bean to use execution resources
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / main / java / 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 public Integer getLine() {
25 return line;
26 }
27
28 public Integer getColumn() {
29 return column;
30 }
31
32 public String getColumnName() {
33 return columnName;
34 }
35
36 public int compareTo(DiffPosition dp) {
37 if (!(dp instanceof TableDiffPosition))
38 throw new UnsupportedException("position", dp);
39
40 TableDiffPosition o = (TableDiffPosition) dp;
41 if (relatedFile.equals(o.relatedFile)) {
42 if (line == o.line) {
43 return column.compareTo(o.column);
44 } else {
45 return line.compareTo(o.line);
46 }
47 } else {
48 return relatedFile.compareTo(o.relatedFile);
49 }
50 }
51
52 @Override
53 public String toString() {
54 StringBuffer buf = new StringBuffer("");
55 buf.append(relatedFile).append('[').append(line);
56 if (column != null) {
57 buf.append(',').append(column);
58 if (columnName != null) {
59 buf.append('-').append(columnName);
60 }
61 }
62 buf.append(']');
63 return buf.toString();
64 }
65
66 }