Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.selesse.jxlint.model.rules;
  
  
  import java.io.File;

A lint error representation. Uses the Builder pattern for its optional parameters. It knows about which rule was violated and the file that violated it. It may have other information, like the line number in which the violation was found, an error message, an Exception relating to its violation, and a custom severity.
 
 public class LintError {
     private LintRule violatedRule;
     private int lineNumber;
     private String errorMessage;
     private Exception e;
    
The file that failed the validation.
 
     private File faultyFile;
     private Severity severity;

    
Creates a LintError with the LintRule and java.io.File parameters. This constructor should be used when chaining multiple parameters, i.e. line number and error message and exception, and is finalized by calling LintError.LintErrorBuilder.create(). For example:
     LintError lintError = LintError.with(this, file).andLineNumber(lineNumber).andErrorMessage(
          "You forgot to do something!").create();
 
 
     public static LintErrorBuilder with(LintRule violatedRuleFile faultyFile) {
         return new LintErrorBuilder(violatedRulefaultyFile);
     }
 
     private LintError(LintRule violatedRuleFile faultyFile) {
         this. = violatedRule;
         this. = FileUtils.normalizeFile(faultyFile);
         this. = "";
     }
 
     public LintRule getViolatedRule() {
         return ;
     }
 
     public String getMessage() {
         return ;
     }
 
     public File getFile() {
         return ;
     }
 
     public Exception getException() {
         return ;
     }
 
     public int getLineNumber() {
         return ;
     }
 
     public void setLineNumber(int lineNumber) {
         this. = lineNumber;
     }
 
     public void setException(Exception e) {
         this. = e;
     }
 
     public void setErrorMessage(String errorMessage) {
         this. = errorMessage;
     }
 
     public void setSeverity(Severity severity) {
         this. = severity;
     }
 
     public Severity getSeverity() {
         if ( == null) {
             return .getSeverity();
         }
         return ;
     }
 
     public String toString() {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.append("'").append(.getName()).append("' failed");
         if ( > 0) {
             stringBuilder.append(" at line ").append();
         }
         if (.length() > 0) {
             stringBuilder.append(": ").append();
         }
 
        return stringBuilder.toString();
    }

    
Utility class for creating a LintError.
    public static class LintErrorBuilder {
        private final LintError lintError;
        public LintErrorBuilder(LintRule lintRuleFile file) {
            this. = new LintError(lintRulefile);
        }

        
Adds an associated java.lang.Exception to the error.
        public LintErrorBuilder andException(Exception e) {
            this..setException(e);
            return this;
        }

        
Adds an associated error message to the error. This message is printed in the reports if available.
        public LintErrorBuilder andErrorMessage(String errorMessage) {
            this..setErrorMessage(errorMessage);
            return this;
        }

        
Adds an associated line number to the error. This is printed in the reports if available.
        public LintErrorBuilder andLineNumber(int lineNumber) {
            this..setLineNumber(lineNumber);
            return this;
        }

        
Specifies a custom severity for this error.
        public LintErrorBuilder andSeverity(Severity severity) {
            this..setSeverity(severity);
            return this;
        }

        
Create the LintError for this builder. Should be called when all the optional arguments are provided.
        public LintError create() {
            return ;
        }
    }
New to GrepCode? Check out our FAQ X