Top Description Fields Constructors Methods
org.apache.tools.ant

public Class Location

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable, java.util.Objects, org.apache.tools.ant.util.FileUtils, org.xml.sax.Locator

Stores 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.

Field Summary

Modifier and TypeField and Description
private final int
columnNumber

Column number within the file.

private static final FileUtils
private final String
fileName

Name of the file.

private final int
lineNumber

Line number within the file.

private static final long
public static final Location
UNKNOWN_LOCATION

Location to use when one is needed but no information is available

Constructor Summary

AccessConstructor and Description
private
Location()

Creates an "unknown" location.

public
Location(String
The name of the file. May be null, in which case the location is equivalent to UNKNOWN_LOCATION.
fileName
)

Creates a location consisting of a file name but no line number or column number.

public
Location(Locator
Must not be null.
loc
)

Creates a location from the SAX locator using the system ID as the filename.

public
Location(String
The name of the file. May be null, in which case the location is equivalent to UNKNOWN_LOCATION.
fileName
,
int
Line number within the file. Use 0 for unknown positions within a file.
lineNumber
,
int
Column number within the line.
columnNumber
)

Creates a location consisting of a file name, line number and column number.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the other object contains the same information as this object.
equals
(Object
the object to compare to.
other
)

Overrides java.lang.Object.equals.

Equality operation.
public int

Returns:

the column number
getColumnNumber
()

public String

Returns:

the filename portion of the location
getFileName
()

public int

Returns:

the line number
getLineNumber
()

public int

Returns:

a hash code value for this location.
hashCode
()

Overrides java.lang.Object.hashCode.

Hash operation.
public String

Returns:

a String of the form "fileName:lineNumber: " if both file name and line number are known, "fileName: " if only the file name is known, and the empty string for unknown locations.
toString
()

Overrides java.lang.Object.toString.

Returns the file name, line number, a colon and a trailing space.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

columnNumberback to summary
private final int columnNumber

Column number within the file.

FILE_UTILSback to summary
private static final FileUtils FILE_UTILS
fileNameback to summary
private final String fileName

Name of the file.

lineNumberback to summary
private final int lineNumber

Line number within the file.

serialVersionUIDback to summary
private static final long serialVersionUID
UNKNOWN_LOCATIONback to summary
public static final Location UNKNOWN_LOCATION

Location to use when one is needed but no information is available

Constructor Detail

Locationback to summary
private Location()

Creates an "unknown" location.

Locationback to summary
public Location(String fileName)

Creates a location consisting of a file name but no line number or column number.

Parameters
fileName:String

The name of the file. May be null, in which case the location is equivalent to UNKNOWN_LOCATION.

Locationback to summary
public Location(Locator loc)

Creates a location from the SAX locator using the system ID as the filename.

Parameters
loc:Locator

Must not be null.

Since
Ant 1.6
Locationback to summary
public Location(String fileName, int lineNumber, int columnNumber)

Creates a location consisting of a file name, line number and column number.

Parameters
fileName:String

The name of the file. May be null, in which case the location is equivalent to UNKNOWN_LOCATION.

lineNumber:int

Line number within the file. Use 0 for unknown positions within a file.

columnNumber:int

Column number within the line.

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Equality operation.

Parameters
other:Object

the object to compare to.

Returns:boolean

true if the other object contains the same information as this object.

Annotations
@Override
Since
Ant 1.6.3
getColumnNumberback to summary
public int getColumnNumber()
Returns:int

the column number

Since
Ant 1.7
getFileNameback to summary
public String getFileName()
Returns:String

the filename portion of the location

Since
Ant 1.6
getLineNumberback to summary
public int getLineNumber()
Returns:int

the line number

Since
Ant 1.6
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Hash operation.

Returns:int

a hash code value for this location.

Annotations
@Override
Since
Ant 1.6.3
toStringback to summary
public String toString()

Overrides java.lang.Object.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.

Returns:String

a String of the form "fileName:lineNumber: " if both file name and line number are known, "fileName: " if only the file name is known, and the empty string for unknown locations.

Annotations
@Override