SourcePositionInfopublic class SourcePositionInfo extends Object implements Comparable
Fields Summary |
---|
public String | file | public int | line | public int | column |
Constructors Summary |
---|
public SourcePositionInfo()
this.file = "<unknown>";
this.line = 0;
this.column = 0;
| public SourcePositionInfo(String file, int line, int column)
this.file = file;
this.line = line;
this.column = column;
| public SourcePositionInfo(SourcePositionInfo that)
this.file = that.file;
this.line = that.line;
this.column = that.column;
|
Methods Summary |
---|
public static com.android.apicheck.SourcePositionInfo | add(com.android.apicheck.SourcePositionInfo that, java.lang.String str, int index)Given this position and str which occurs at that position, as well as str an index into str,
find the SourcePositionInfo.
if (that == null) {
return null;
}
int line = that.line;
char prev = 0;
for (int i=0; i<index; i++) {
char c = str.charAt(i);
if (c == '\r" || (c == '\n" && prev != '\r")) {
line++;
}
prev = c;
}
return new SourcePositionInfo(that.file, line, 0);
| public int | compareTo(java.lang.Object o)
SourcePositionInfo that = (SourcePositionInfo)o;
int r = this.file.compareTo(that.file);
if (r != 0) return r;
return this.line - that.line;
| public static com.android.apicheck.SourcePositionInfo | findBeginning(com.android.apicheck.SourcePositionInfo that, java.lang.String str)
if (that == null) {
return null;
}
int line = that.line-1; // -1 because, well, it seems to work
int prev = 0;
for (int i=str.length()-1; i>=0; i--) {
char c = str.charAt(i);
if ((c == '\r" && prev != '\n") || (c == '\n")) {
line--;
}
prev = c;
}
return new SourcePositionInfo(that.file, line, 0);
| public static com.android.apicheck.SourcePositionInfo | fromXml(java.lang.String source)Build a SourcePositionInfo from the XML source= notation
if (source != null) {
for (int i = 0; i < source.length(); i++) {
if (source.charAt(i) == ':") {
return new SourcePositionInfo(source.substring(0, i),
Integer.parseInt(source.substring(i+1)), 0);
}
}
}
return new SourcePositionInfo("(unknown)", 0, 0);
| public java.lang.String | toString()
if (this.file == null) {
return "(unknown)";
} else {
if (this.line == 0) {
return this.file + ':";
} else {
return this.file + ':" + this.line + ':";
}
}
|
|