| 1 | |
|
| 2 | |
package org.galagosearch.tupleflow.execution; |
| 3 | |
|
| 4 | |
import java.io.Serializable; |
| 5 | |
import org.xml.sax.Locator; |
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | 0 | public class FileLocation implements Serializable, Comparable<FileLocation> { |
| 12 | 0 | public FileLocation(String fileName, int lineNumber, int columnNumber) { |
| 13 | 0 | this.fileName = fileName; |
| 14 | 0 | this.lineNumber = lineNumber; |
| 15 | 0 | this.columnNumber = columnNumber; |
| 16 | 0 | } |
| 17 | |
|
| 18 | |
public FileLocation(String filename, Locator locator) { |
| 19 | 0 | this(filename, locator.getLineNumber(), locator.getColumnNumber()); |
| 20 | 0 | } |
| 21 | |
|
| 22 | |
public int compareTo(FileLocation location) { |
| 23 | 0 | int result = fileName.compareTo(location.fileName); |
| 24 | 0 | if (result == 0) { |
| 25 | 0 | result = lineNumber - location.lineNumber; |
| 26 | |
} |
| 27 | 0 | if (result == 0) { |
| 28 | 0 | result = columnNumber - location.columnNumber; |
| 29 | |
} |
| 30 | 0 | return result; |
| 31 | |
} |
| 32 | |
|
| 33 | |
@Override |
| 34 | |
public String toString() { |
| 35 | 0 | return String.format("%s [Line %d: Column %d]", fileName, lineNumber, columnNumber); |
| 36 | |
} |
| 37 | |
|
| 38 | |
public String fileName; |
| 39 | |
public int lineNumber; |
| 40 | |
public int columnNumber; |
| 41 | |
} |