Start line:  
End line:  

Snippet Preview

Snippet HTML Code

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

Abstract LintRules. Provides most of the implementation that should be expected from LintRules. All the methods (except getLintRule(java.lang.String)) assume that the elements are valid. In other words, calling getAllRulesExcept( { "rule1", "rule2" } ) assumes that these rules do exist and will fail silently if they don't.

The program is expected to fail if these rules don't exist, specifically in com.selesse.jxlint.model.ProgramOptions.getRuleListFromOptionString(java.lang.String).

 
 public abstract class AbstractLintRules implements LintRules {
     protected List<LintRulelintRules;
    
The source/root directory in which we will be performing all validations.
 
     protected File sourceDirectory;
 
     public AbstractLintRules() {
         this. = Lists.newArrayList();
         initializeLintRules();
     }

    
Add all desired LintRules to lintRules.
 
     public abstract void initializeLintRules();
 
     @Override
     public LintRule getLintRule(String ruleNamethrows NonExistentLintRuleException {
         LintRule lintRule = null;
 
         for (LintRule rule : ) {
             if (rule.getName().equalsIgnoreCase(ruleName)) {
                 lintRule = rule;
                 break;
             }
         }
 
         if (lintRule == null) {
             throw new NonExistentLintRuleException(ruleName);
         }
 
         return lintRule;
     }
 
     @Override
     public List<LintRulegetAllRules() {
         return Collections.unmodifiableList();
     }
 
     @Override
     public List<LintRulegetAllEnabledRules() {
         return Collections.unmodifiableList(getModifiableAllEnabledRules());
     }
 
     private List<LintRulegetModifiableAllEnabledRules() {
         List<LintRulefilteredLintRules = Lists.newArrayList();
 
         for (LintRule lintRule : getAllRules()) {
             if (lintRule.isEnabled()) {
                 filteredLintRules.add(lintRule);
             }
         }
 
         return filteredLintRules;
     }
 
     @Override
     public List<LintRulegetAllRulesExcept(List<StringdisabledRules) {
         if (disabledRules.size() == 0) {
             return getAllRules();
         }
 
         List<LintRulefilteredLintRules = Lists.newArrayList();
 
         for (LintRule lintRule : getAllRules()) {
             if (!lintRule.hasNameInList(disabledRules)) {
                 filteredLintRules.add(lintRule);
             }
         }
 
         return Collections.unmodifiableList(filteredLintRules);
     }
 
     @Override
     public List<LintRulegetAllEnabledRulesExcept(List<StringdisabledRules) {
         if (disabledRules.size() == 0) {
             return getAllEnabledRules();
         }
        List<LintRulefilteredLintRules = Lists.newArrayList();
        for (LintRule lintRule : getAllEnabledRules()) {
            if (!lintRule.hasNameInList(disabledRules)) {
                filteredLintRules.add(lintRule);
            }
        }
        return Collections.unmodifiableList(filteredLintRules);
    }
    @Override
    public List<LintRulegetAllEnabledRulesAsWellAs(List<StringenabledRulesList) {
        if (enabledRulesList.size() == 0) {
            return getAllEnabledRules();
        }
        List<LintRulebloatedLintRules = getModifiableAllEnabledRules();
        for (String enabledLintString : enabledRulesList) {
            try {
                LintRule lintRule = getLintRule(enabledLintString);
                bloatedLintRules.add(lintRule);
            }
            catch (NonExistentLintRuleException e) {
                // do nothing, we assume these are already all validated
            }
        }
        return Collections.unmodifiableList(bloatedLintRules);
    }
    @Override
    public List<LintRulegetRulesWithCategoryNames(List<StringcategoryNames) {
        List<LintRulecategoryRules = Lists.newArrayList();
        List<LintRulelintRules = getAllEnabledRules();
        for (LintRule lintRule : lintRules) {
            for (String categoryName : categoryNames) {
                if (lintRule.getCategory().toString().equalsIgnoreCase(categoryName)) {
                    categoryRules.add(lintRule);
                }
            }
        }
        return categoryRules;
    }
    @Override
    public List<LintRulegetOnlyRules(List<StringcheckRules) {
        List<LintRulefilteredLintRules = Lists.newArrayList();
        for (String enabledLintString : checkRules) {
            try {
                LintRule lintRule = getLintRule(enabledLintString);
                filteredLintRules.add(lintRule);
            }
            catch (NonExistentLintRuleException e) {
                // do nothing, we assume these are already all validated
            }
        }
        return Collections.unmodifiableList(filteredLintRules);
    }
    @Override
    public List<LintRulegetAllRulesWithSeverity(Severity severity) {
        List<LintRuleseverityRules = Lists.newArrayList();
        for (LintRule lintRule : getAllRules()) {
            if (lintRule.getSeverity() == severity) {
                severityRules.add(lintRule);
            }
        }
        return Collections.unmodifiableList(severityRules);
    }
    @Override
    public void setSourceDirectory(File sourceDirectory) {
        this. = FileUtils.normalizeFile(sourceDirectory);
    }
    @Override
    public File getSourceDirectory() {
        return ;
    }
New to GrepCode? Check out our FAQ X