org.sonar.api.rules
Class Violation

java.lang.Object
  extended by org.sonar.api.rules.Violation

public class Violation
extends Object

A class that represents a violation. A violation happens when a resource does not respect a defined rule.


Constructor Summary
Violation(Rule rule)
          Creates of a violation from a rule.
Violation(Rule rule, Resource resource)
          Creates a fully qualified violation
 
Method Summary
 boolean equals(Object obj)
           
 Integer getLineId()
           
 String getMessage()
           
 RulePriority getPriority()
           
 Resource getResource()
           
 Rule getRule()
           
 int hashCode()
           
 Violation setLineId(Integer lineId)
          Sets the violation line
 Violation setMessage(String message)
          Sets the violation message
 Violation setPriority(RulePriority priority)
          Sets the violation priority
 Violation setResource(Resource resource)
          Sets the resource the violation applies to
 Violation setRule(Rule rule)
          Sets the rule violated
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Violation

public Violation(Rule rule)
Creates of a violation from a rule. Will need to define the resource later on


Violation

public Violation(Rule rule,
                 Resource resource)
Creates a fully qualified violation

Parameters:
rule - the rule that has been violated
resource - the resource the violation should be attached to
Method Detail

getResource

public Resource getResource()

setResource

public Violation setResource(Resource resource)
Sets the resource the violation applies to

Returns:
the current object

getRule

public Rule getRule()

setRule

public Violation setRule(Rule rule)
Sets the rule violated

Returns:
the current object

getMessage

public String getMessage()

setMessage

public Violation setMessage(String message)
Sets the violation message

Returns:
the current object

getLineId

public Integer getLineId()

setLineId

public Violation setLineId(Integer lineId)
Sets the violation line

Returns:
the current object

getPriority

public RulePriority getPriority()

setPriority

public Violation setPriority(RulePriority priority)
Sets the violation priority

Returns:
the current object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009 SonarSource SA. All Rights Reserved.