org.aspectj.bridge
Class SourceLocation

java.lang.Object
  extended by org.aspectj.bridge.SourceLocation
All Implemented Interfaces:
java.io.Serializable, ISourceLocation

public class SourceLocation
extends java.lang.Object
implements ISourceLocation

Immutable source location. This guarantees that the source file is not null and that the numeric values are positive and line <= endLine.

See Also:
SourceLocation, org.aspectj.compiler.base.parser.SourceInfo, org.aspectj.tools.ide.SourceLine, org.aspectj.testing.harness.ErrorLine, Serialized Form

Field Summary
static ISourceLocation UNKNOWN
          used when SourceLocation is not available
 
Fields inherited from interface org.aspectj.bridge.ISourceLocation
EMPTY, MAX_COLUMN, MAX_LINE, NO_COLUMN, NO_FILE
 
Constructor Summary
SourceLocation(java.io.File file, int line)
          Same as SourceLocation(file, line, line, 0), except that column is not rendered during toString()
SourceLocation(java.io.File file, int line, int endLine)
          same as SourceLocation(file, line, endLine, ISourceLocation.NO_COLUMN)
SourceLocation(java.io.File file, int line, int endLine, int column)
           
SourceLocation(java.io.File file, int line, int endLine, int column, java.lang.String context)
           
SourceLocation(java.io.File file, int line, int endLine, int column, java.lang.String context, java.lang.String sourceFileName)
           
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 int getColumn()
           
 java.lang.String getContext()
           
 int getEndLine()
           
 int getLine()
           
 int getOffset()
           
 java.io.File getSourceFile()
           
 java.lang.String getSourceFileName()
          In the cases where getSourceFile().getName() returns a class file (for example when we have a binary aspect) this should return the name of the source file (for example BinaryAspect.aj)
 int hashCode()
           
 void setOffset(int i)
           
 java.lang.String toString()
           
static void validColumn(int column)
           
static void validLine(int line)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final ISourceLocation UNKNOWN
used when SourceLocation is not available

Constructor Detail

SourceLocation

public SourceLocation(java.io.File file,
                      int line)
Same as SourceLocation(file, line, line, 0), except that column is not rendered during toString()


SourceLocation

public SourceLocation(java.io.File file,
                      int line,
                      int endLine)
same as SourceLocation(file, line, endLine, ISourceLocation.NO_COLUMN)


SourceLocation

public SourceLocation(java.io.File file,
                      int line,
                      int endLine,
                      int column)
Parameters:
file - File of the source; if null, use ISourceLocation.NO_FILE, not null
line - int starting line of the location - positive number
endLine - int ending line of the location - <= starting line
column - int character position of starting location - positive number

SourceLocation

public SourceLocation(java.io.File file,
                      int line,
                      int endLine,
                      int column,
                      java.lang.String context)

SourceLocation

public SourceLocation(java.io.File file,
                      int line,
                      int endLine,
                      int column,
                      java.lang.String context,
                      java.lang.String sourceFileName)
Method Detail

validLine

public static final void validLine(int line)
Throws:
java.lang.IllegalArgumentException - if the input would not be a valid line

validColumn

public static final void validColumn(int column)
Throws:
java.lang.IllegalArgumentException - if the input would not be a valid column

getSourceFile

public java.io.File getSourceFile()
Specified by:
getSourceFile in interface ISourceLocation
Returns:
File source or NO_FILE if the implementation requires a non-null result or null otherwise

getLine

public int getLine()
Specified by:
getLine in interface ISourceLocation
Returns:
0..MAX_LINE

getColumn

public int getColumn()
Specified by:
getColumn in interface ISourceLocation
Returns:
int actual column or 0 if not available per constructor treatment of ISourceLocation.NO_COLUMN

getEndLine

public int getEndLine()
Specified by:
getEndLine in interface ISourceLocation
Returns:
getLine()..MAX_LINE

getContext

public java.lang.String getContext()
Specified by:
getContext in interface ISourceLocation
Returns:
null String or application-specific context

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
String {context\n}{file:}line{:column}

getOffset

public int getOffset()
Specified by:
getOffset in interface ISourceLocation
Returns:
offset into file

setOffset

public void setOffset(int i)

getSourceFileName

public java.lang.String getSourceFileName()
Description copied from interface: ISourceLocation
In the cases where getSourceFile().getName() returns a class file (for example when we have a binary aspect) this should return the name of the source file (for example BinaryAspect.aj)

Specified by:
getSourceFileName in interface ISourceLocation
Returns:
the name of the source file

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object