]>
git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/diff/TableDiffPosition.java
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.argeo
.slc
.diff
;
19 import org
.argeo
.slc
.UnsupportedException
;
22 * A diff position within a table structure such a CSV file or an SQL result
25 public class TableDiffPosition
extends DiffPosition
{
28 private Integer column
;
30 private String columnName
;
32 public TableDiffPosition(RelatedFile relatedFile
, Integer line
,
33 Integer column
, String columnName
) {
37 this.columnName
= columnName
;
40 public Integer
getLine() {
44 public Integer
getColumn() {
48 public String
getColumnName() {
52 public int compareTo(DiffPosition dp
) {
53 if (!(dp
instanceof TableDiffPosition
))
54 throw new UnsupportedException("position", dp
);
56 TableDiffPosition o
= (TableDiffPosition
) dp
;
57 if (relatedFile
.equals(o
.relatedFile
)) {
59 return column
.compareTo(o
.column
);
61 return line
.compareTo(o
.line
);
64 return relatedFile
.compareTo(o
.relatedFile
);
69 public String
toString() {
70 StringBuffer buf
= new StringBuffer("");
71 buf
.append(relatedFile
).append('[').append(line
);
73 buf
.append(',').append(column
);
74 if (columnName
!= null) {
75 buf
.append('-').append(columnName
);
79 return buf
.toString();