PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/org/ubi/FileLocation.java

http://github.com/nddrylliog/ooc
Java | 71 lines | 37 code | 14 blank | 20 comment | 0 complexity | b045d7b2bb92bd1441bf03f01a494066 MD5 | raw file
 1package org.ubi;
 2
 3
 4
 5/**
 6 * Information about a location in a file
 7 *
 8 * @author Amos Wenger
 9 */  
10public class FileLocation {
11    
12	protected String fileName;
13    protected int lineNumber;
14    protected int linePos;
15    protected int index;
16    protected int length;
17
18    public FileLocation(String fileName, int lineNumber, int linePos, int index) {
19    	this(fileName, lineNumber, linePos, index, 1);
20    }
21    
22    public FileLocation(String fileName, int lineNumber, int linePos, int index, int length) {
23        this.fileName = fileName;
24        this.lineNumber = lineNumber;
25        this.linePos =  linePos;
26        this.index = index;
27        this.length = length;
28    }
29
30    /**
31     * @return the name of the file
32     */
33    public String getFileName() {
34        return fileName;
35    }
36
37    /**
38     * @return the line number
39     */
40    public int getLineNumber() {
41        return lineNumber;
42    }
43
44    /**
45     * @return the position in line (e.g. number of characters after the last newline)
46     */
47    public int getLinePos() {
48        return linePos;
49    }
50
51    /**
52     * @return the number of characters (including whitespace) since the beginning of the file
53     */
54    public int getIndex() {
55        return index;
56    }
57    
58    /**
59     * @return the length of the interesting location, in characters
60     */
61    public int getLength() {
62		return length;
63	}
64
65    
66    @Override
67	public String toString() {
68        return " "+fileName+":"+getLineNumber()+":"+getLinePos();
69    }
70    
71}