Locationpublic class Location extends Object implements SerializableStores the location of a piece of text within a file (file name,
line number and column number). Note that the column number is
currently ignored. |
Fields Summary |
---|
private String | fileNameName of the file. | private int | lineNumberLine number within the file. | private int | columnNumberColumn number within the file. | public static final Location | UNKNOWN_LOCATIONLocation to use when one is needed but no information is available | private static final org.apache.tools.ant.util.FileUtils | FILE_UTILS |
Constructors Summary |
---|
private Location()Creates an "unknown" location.
this(null, 0, 0);
| public Location(String fileName)Creates a location consisting of a file name but no line number or
column number.
this(fileName, 0, 0);
| public Location(Locator loc)Creates a location from the SAX locator using the system ID as
the filename.
this(loc.getSystemId(), loc.getLineNumber(), loc.getColumnNumber());
| public Location(String fileName, int lineNumber, int columnNumber)Creates a location consisting of a file name, line number and
column number.
if (fileName != null && fileName.startsWith("file:")) {
this.fileName = FILE_UTILS.fromURI(fileName);
} else {
this.fileName = fileName;
}
this.lineNumber = lineNumber;
this.columnNumber = columnNumber;
|
Methods Summary |
---|
public boolean | equals(java.lang.Object other)Equality operation.
if (this == other) {
return true;
}
if (other == null) {
return false;
}
if (!(other.getClass() == getClass())) {
return false;
}
return toString().equals(other.toString());
| public int | getColumnNumber()
return columnNumber;
| public java.lang.String | getFileName()
return fileName;
| public int | getLineNumber()
return lineNumber;
| public int | hashCode()Hash operation.
return toString().hashCode();
| public java.lang.String | toString()Returns the file name, line number, a colon and a trailing space.
An error message can be appended easily. For unknown locations, an
empty string is returned.
StringBuffer buf = new StringBuffer();
if (fileName != null) {
buf.append(fileName);
if (lineNumber != 0) {
buf.append(":");
buf.append(lineNumber);
}
buf.append(": ");
}
return buf.toString();
|
|