org.incava.analysis
Class Violation

java.lang.Object
  extended by org.incava.analysis.Violation
All Implemented Interfaces:
java.lang.Comparable

public class Violation
extends java.lang.Object
implements java.lang.Comparable

An error or a warning, associated with a file by a starting and ending position, and a message.


Constructor Summary
Violation(java.lang.String message, int beginLine, int beginColumn, int endLine, int endColumn)
          Creates a violation from a message and begin and end positions.
Violation(java.lang.String message, Token token)
          Creates a violation from a message and a token.
Violation(java.lang.String message, Token beginToken, Token endToken)
          Creates a violation from a message and beginning and ending token.
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compares this violation to another.
 boolean equals(java.lang.Object obj)
          Returns whether the other object is equal to this one.
 int getBeginColumn()
          Returns the column where the violation starts.
 int getBeginLine()
          Returns the line where the violation starts.
 int getEndColumn()
          Returns the column where the violation ends.
 int getEndLine()
          Returns the line where the violation ends.
 java.lang.String getMessage()
          Returns the message for this violation.
 java.lang.String toString()
          Returns this violation, as a string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Violation

public Violation(java.lang.String message,
                 int beginLine,
                 int beginColumn,
                 int endLine,
                 int endColumn)
Creates a violation from a message and begin and end positions.

Parameters:
message - The message applying to this violation.
beginLine - The line where the violation begins.
beginColumn - The column where the violation begins.
endLine - The line where the violation ends.
endColumn - The column where the violation ends.

Violation

public Violation(java.lang.String message,
                 Token beginToken,
                 Token endToken)
Creates a violation from a message and beginning and ending token.

Parameters:
message - The message applying to this violation.
beginToken - The token where the violation begins.
endToken - The token where the violation ends.

Violation

public Violation(java.lang.String message,
                 Token token)
Creates a violation from a message and a token. The token image is considered to be the entire length of the violation, i.e., the ending location is token + token.image.length() - 1.

Parameters:
message - The message applying to this violation.
token - The token to which the violation applies.
Method Detail

getMessage

public java.lang.String getMessage()
Returns the message for this violation. This should be only one line, because it is used in single-line reports.


getBeginLine

public int getBeginLine()
Returns the line where the violation starts.


getBeginColumn

public int getBeginColumn()
Returns the column where the violation starts.


getEndLine

public int getEndLine()
Returns the line where the violation ends.


getEndColumn

public int getEndColumn()
Returns the column where the violation ends.


compareTo

public int compareTo(java.lang.Object obj)
Compares this violation to another. Violations are sorted in order by their beginning locations, then their end locations.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - The violation to compare this to.
Returns:
-1, 0, or 1, for less than, equivalent to, or greater than.

equals

public boolean equals(java.lang.Object obj)
Returns whether the other object is equal to this one. Note that messages are not compared, only line and column numbers.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The violation to compare this to.
Returns:
Whether the other violation is equal to this one.

toString

public java.lang.String toString()
Returns this violation, as a string.

Overrides:
toString in class java.lang.Object
Returns:
This violation, as a string.