edu.rice.cs.drjava.model
Class DJError

java.lang.Object
  extended by edu.rice.cs.drjava.model.DJError
All Implemented Interfaces:
Serializable, Comparable<DJError>
Direct Known Subclasses:
CompilerError, JUnitError

public class DJError
extends Object
implements Comparable<DJError>, Serializable

A class to represent source errors and warnings generated by the compiler, JUnit, etc. This class enables DrJava to highlight the error text.

Version:
$Id: DJError.java 4504 2008-06-03 06:19:20Z rcartwright $
See Also:
Serialized Form

Constructor Summary
DJError(File file, int lineNumber, int startColumn, String message, boolean isWarning)
          Constructor.
DJError(File file, String message, boolean isWarning)
          Constructor for an DJError with an associated file but no location in the source
DJError(String message, boolean isWarning)
          Constructor for CompilerErrors without files.
 
Method Summary
 int compareTo(DJError other)
          Compares by file, then by line, then by column.
 File file()
          Gets the file.
 String fileName()
          Gets the full name of the file.
 String getFileMessage()
          This function returns a message telling the file this error is from appropriate to display to a user, indicating if there is no file associated with this error.
 String getLineMessage()
          This function returns a message telling the line this error is from appropriate to display to a user, indicating if there is no file associated with this error.
 boolean hasNoLocation()
          This function returns true if and only if the given error has no location
 boolean isWarning()
          Determines if the error is a warning.
 int lineNumber()
          Gets the zero-based line number of the error.
 String message()
          Gets the error message.
 int startColumn()
          Gets the column where the error begins.
 String toString()
          Gets a String representation of the error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DJError

public DJError(File file,
               int lineNumber,
               int startColumn,
               String message,
               boolean isWarning)
Constructor.

Parameters:
file - the file where the error occurred
lineNumber - the line number of the error
startColumn - the starting column of the error
message - the error message

DJError

public DJError(File file,
               String message,
               boolean isWarning)
Constructor for an DJError with an associated file but no location in the source


DJError

public DJError(String message,
               boolean isWarning)
Constructor for CompilerErrors without files.

Parameters:
message - the error message
Method Detail

hasNoLocation

public boolean hasNoLocation()
This function returns true if and only if the given error has no location


toString

public String toString()
Gets a String representation of the error. Abstract.

Overrides:
toString in class Object
Returns:
the error as a String

file

public File file()
Gets the file.

Returns:
the file with errors.

fileName

public String fileName()
Gets the full name of the file.

Returns:
the file name.

lineNumber

public int lineNumber()
Gets the zero-based line number of the error. NOTE: javac/javadoc produces zero-based line numbers internally, but prints one-based line numbers to the command line.

Returns:
the zero-based line number

startColumn

public int startColumn()
Gets the column where the error begins.

Returns:
the starting column

message

public String message()
Gets the error message.

Returns:
the error message.

getFileMessage

public String getFileMessage()
This function returns a message telling the file this error is from appropriate to display to a user, indicating if there is no file associated with this error.


getLineMessage

public String getLineMessage()
This function returns a message telling the line this error is from appropriate to display to a user, indicating if there is no file associated with this error. This is adjusted to show one-based numbers, since internally we store a zero-based index.


isWarning

public boolean isWarning()
Determines if the error is a warning.

Returns:
true if the error is a warning.

compareTo

public int compareTo(DJError other)
Compares by file, then by line, then by column. Errors without files are considered equal, but less than any errors with files. Warnings are considered greater than errors when they are otherwise equal.

Specified by:
compareTo in interface Comparable<DJError>