// SSDLPediapackageil.ac.technion.cs.ssdl.parsing;
importstaticil.ac.technion.cs.ssdl.utils.DBC.nonnegative;
importil.ac.technion.cs.ssdl.stereotypes.Immutable;
importil.ac.technion.cs.ssdl.stereotypes.Instantiable;
importil.ac.technion.cs.ssdl.utils.DBC.Checkable;
importjava.io.Serializable;
/** * An immutable class to model a position in a text file, including a column and * line number. * * Author: Yossi Gil @since 13/06/2007 */@Immutable@InstantiablepublicfinalclassPositionimplementsComparable<Position>, Serializable, Checkable {
/** * The line of this position. First line is 0. */publicfinalintline;
/** * The column of this position. First column is 0. */publicfinalintcolumn;
@Overridepublicvoidinvariant() {
nonnegative(line);
nonnegative(column);
}
@OverridepublicStringtoString() {
return"(" + line + ":" + column + ")";
}
/** * Create a new instance * * line a non-negative integer specifying the line of this position * column non-negative integer specifying the column of this position */publicPosition(finalintline, finalintcolumn) {
this.line = line;
this.column = column;
}
@Overridepublicbooleanequals(finalObjecto) {
if (this == o)
returntrue;
if (o == null || getClass() != o.getClass())
returnfalse;
returnequals((Position) o);
}
/** * Determine whether two positions are the same * * p a position to compare with * Return: true iff both positions are the same */publicbooleanequals(finalPositionp) {
if (p == null)
returnfalse;
returncolumn == p.column && line == p.line;
}
@OverridepublicinthashCode() {
returnline ^ column >>> 1;
}
@OverridepublicintcompareTo(finalPositionp) {
returnline != p.line ? line - p.line : column - p.column;
}
/** * Total Inspector: Determine whether one position occurs before another. * * p a position to compare with * Return: true iff this position occurs prior to * p */publicbooleanbefore(finalPositionp) {
returncompareTo(p) < 0;
}
/** * Compute the next position * * Return: a new Position object, representing the next character * position. */publicPositionnextColumn() {
returnnewPosition(line, column + 1);
}
/** * Compute the position of the next line * * Return: a new Position object, representing the first character * in the next line. */publicPositionnextLine() {
returnnewPosition(line + 1, 0);
}
privatestaticfinallongserialVersionUID = -9094620074260625651L;
}
Metrics
Metric
Value
Acronym
Explanation
LOC
108
Lines Of Code
Total number of lines in the code
SCC
24
SemiColons Count
Total number of semicolon tokens found in the code.
NOT
362
Number Of Tokens
Comments, whitespace and text which cannot be made into a token not included.
VCC
2195
Visible Characters Count
The total number of non-white (i.e., not space, tab, newline, carriage return, form feed) characters.
CCC
1246
Code Characters Count
Total number of non-white characters in tokens. White space characters in string and character literals are not counted.
UIC
34
Unique Identifiers Count
The number of different identifiers found in the code