Skip to content

Package: Position

Position

nameinstructionbranchcomplexitylinemethod
Position(Integer, Integer, String)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
compareTo(Position)
M: 0 C: 46
100%
M: 0 C: 12
100%
M: 0 C: 7
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
equals(Object)
M: 0 C: 28
100%
M: 0 C: 8
100%
M: 0 C: 5
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getColumn()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPath()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getRow()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hashCode()
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
toString()
M: 0 C: 23
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: package model;
2:
3: import scanner.ScannerConstants;
4:
5: /**
6: * This class represents the position of the symbol.
7: *
8: * @author HFW410
9: *
10: */
11: public class Position implements Comparable<Position> {
12:         /**
13:          * This attribute represents the row of the position.
14:          */
15:         private final Integer row;
16:         /**
17:          * This attribute represents the column of the position.
18:          */
19:         private final Integer column;
20:
21:         /**
22:          * This attribute is the path to the file.
23:          */
24:         private final String path;
25:
26:         /**
27:          * constructor initialize the position with a row and column.
28:          *
29:          * @param row
30:          * is the row of the symbol
31:          * @param column
32:          * is the row of the symbol
33:          * @param path
34:          * of the datastream expected \package\file
35:          */
36:         public Position(final Integer row, final Integer column, final String path) {
37:                 super();
38:                 this.row = row;
39:                 this.column = column;
40:                 this.path = path;
41:         }
42:
43:         /**
44:          *
45:          * @return row of the position.
46:          */
47:         public Integer getRow() {
48:                 return this.row;
49:         }
50:
51:         /**
52:          *
53:          * @return column of the position.
54:          */
55:         public Integer getColumn() {
56:                 return this.column;
57:         }
58:
59:         /**
60:          *
61:          * @return the path
62:          */
63:         public String getPath() {
64:                 return this.path;
65:         }
66:
67:         @Override
68:         public boolean equals(final Object obj) {
69:•                return obj instanceof Position && ((Position) obj).getRow().equals(this.getRow())
70:•                                && ((Position) obj).getColumn().equals(this.getColumn())
71:•                                && ((Position) obj).getPath().endsWith(this.getPath());
72:         }
73:
74:         @Override
75:         public int hashCode() {
76:                 return this.getRow().hashCode() + this.getColumn().hashCode() + this.getPath().hashCode();
77:         }
78:
79:         @Override
80:         public String toString() {
81:                 return ScannerConstants.POSITION + this.getPath().toString() + ScannerConstants.COMMASPACE
82:                                 + this.getRow().toString() + ScannerConstants.COMMASPACE + this.getColumn().toString();
83:         }
84:
85:         /**
86:          * Compares the product(row, colomn) of two prodcts.
87:          *
88:          * @param o
89:          * the position to compare.
90:          * @return returns int
91:          */
92:         @Override
93:         public int compareTo(final Position o) {
94:                 int compVal = 0;
95:•                if ((this.getRow() < o.getRow())
96:•                                || (this.getRow().equals(o.getRow()) && this.getColumn() < o.getColumn())) {
97:                         compVal--;
98:                 }
99:•                if (this.getRow() > o.getRow()
100:•                                || (this.getRow().equals(o.getRow()) && this.getColumn() > o.getColumn())) {
101:                         compVal++;
102:                 }
103:                 return compVal;
104:         }
105: }