|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SourcePosition | Line # 25 | 10 | 7 | 100% |
1.0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(13) | |||
Result | |||
0.6666667
|
org.qedeq.base.io.SourceAreaTest.testGetEndPosition
![]() |
1 PASS | |
0.6666667
|
org.qedeq.base.io.SourceAreaTest.testGetStartPosition
![]() |
1 PASS | |
0.6111111
|
org.qedeq.base.io.SourcePositionTest.testEqualsObject
![]() |
1 PASS | |
0.5
|
org.qedeq.base.io.SourceAreaTest.testEqualsObject
![]() |
1 PASS | |
0.33333334
|
org.qedeq.base.io.SourcePositionTest.testHashCode
![]() |
1 PASS | |
0.33333334
|
org.qedeq.base.io.SourcePositionTest.testToString
![]() |
1 PASS | |
0.33333334
|
org.qedeq.base.io.SourceAreaTest.testHashCode
![]() |
1 PASS | |
0.22222222
|
org.qedeq.base.io.SourceAreaTest.testToString
![]() |
1 PASS | |
0.16666667
|
org.qedeq.base.test.EachClassHasATestCase.testIfEveryClassIsTested
![]() |
1 PASS | |
0.16666667
|
org.qedeq.base.io.SourcePositionTest.testSourcePosition
![]() |
1 PASS | |
0.16666667
|
org.qedeq.base.io.SourceAreaTest.testSourceArea
![]() |
1 PASS | |
0.11111111
|
org.qedeq.base.io.SourcePositionTest.testGetLine
![]() |
1 PASS | |
0.11111111
|
org.qedeq.base.io.SourcePositionTest.testGetEndPosition
![]() |
1 PASS | |
1 | /* This file is part of the project "Hilbert II" - http://www.qedeq.org | |
2 | * | |
3 | * Copyright 2000-2014, Michael Meyling <mime@qedeq.org>. | |
4 | * | |
5 | * "Hilbert II" is free software; you can redistribute | |
6 | * it and/or modify it under the terms of the GNU General Public | |
7 | * License as published by the Free Software Foundation; either | |
8 | * version 2 of the License, or (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | */ | |
15 | ||
16 | package org.qedeq.base.io; | |
17 | ||
18 | import java.io.Serializable; | |
19 | ||
20 | /** | |
21 | * Describes a file position within a text file. | |
22 | * | |
23 | * @author Michael Meyling | |
24 | */ | |
25 | public final class SourcePosition implements Serializable { | |
26 | ||
27 | /** Begin of file. */ | |
28 | public static final SourcePosition BEGIN = new SourcePosition(1, 1); | |
29 | ||
30 | /** Line number, starting with 1. */ | |
31 | private int row; | |
32 | ||
33 | /** Column number, starting with 1. */ | |
34 | private int column; | |
35 | ||
36 | /** | |
37 | * Constructs source position object. | |
38 | * | |
39 | * @param row Line number, starting with 1. | |
40 | * @param column Column number, starting with 1. | |
41 | */ | |
42 | 116 |
![]() |
43 | 116 | this.row = row; |
44 | 116 | this.column = column; |
45 | } | |
46 | ||
47 | /** | |
48 | * Get line number, starting with 1. | |
49 | * | |
50 | * @return Line number. | |
51 | */ | |
52 | 199 |
![]() |
53 | 199 | return row; |
54 | } | |
55 | ||
56 | /** | |
57 | * Get column number, starting with 1. | |
58 | * | |
59 | * @return column number | |
60 | */ | |
61 | 175 |
![]() |
62 | 175 | return column; |
63 | } | |
64 | ||
65 | 42 |
![]() |
66 | 42 | return getRow() ^ (getColumn() * 13); |
67 | } | |
68 | ||
69 | 36 |
![]() |
70 | 36 | if (!(obj instanceof SourcePosition)) { |
71 | 2 | return false; |
72 | } | |
73 | 34 | final SourcePosition other = (SourcePosition) obj; |
74 | 34 | return (getRow() == other.getRow()) |
75 | && (getColumn() == other.getColumn()); | |
76 | } | |
77 | ||
78 | 28 |
![]() |
79 | 28 | return getRow() + ":" + getColumn(); |
80 | } | |
81 | ||
82 | } |
|