View Javadoc

1   // BSD License (http://www.galagosearch.org/license)
2   package org.galagosearch.tupleflow.execution;
3   
4   import java.io.Serializable;
5   import org.xml.sax.Locator;
6   
7   /***
8    *
9    * @author trevor
10   */
11  public class FileLocation implements Serializable, Comparable<FileLocation> {
12      public FileLocation(String fileName, int lineNumber, int columnNumber) {
13          this.fileName = fileName;
14          this.lineNumber = lineNumber;
15          this.columnNumber = columnNumber;
16      }
17  
18      public FileLocation(String filename, Locator locator) {
19          this(filename, locator.getLineNumber(), locator.getColumnNumber());
20      }
21  
22      public int compareTo(FileLocation location) {
23          int result = fileName.compareTo(location.fileName);
24          if (result == 0) {
25              result = lineNumber - location.lineNumber;
26          }
27          if (result == 0) {
28              result = columnNumber - location.columnNumber;
29          }
30          return result;
31      }
32  
33      @Override
34      public String toString() {
35          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  }