Examples of CheckErrorResult


Examples of org.wikipediacleaner.api.check.CheckErrorResult

          return true;
        }
        result = true;
        PageElementCategory keepCategory = keepCategory(groupCategory, lastTitle);
        if (keepCategory == category) {
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis,
              category.getBeginIndex(),
              category.getEndIndex(),
              CheckErrorResult.ErrorLevel.CORRECT);
          errors.add(errorResult);
        } else {
          int beginIndex = category.getBeginIndex();
          while ((beginIndex > 0) && (contents.charAt(beginIndex - 1) == ' ')) {
            beginIndex--;
          }
          boolean beginLine = (beginIndex == 0) || (contents.charAt(beginIndex - 1) == '\n');
          int endIndex = category.getEndIndex();
          while ((endIndex < contents.length()) && (contents.charAt(endIndex) == ' ')) {
            endIndex++;
          }
          boolean endLine = (endIndex >= contents.length()) || (contents.charAt(endIndex) == '\n');
          if (beginLine && endLine) {
            endIndex = Math.min(endIndex + 1, contents.length());
          }
          if (!beginLine) {
            beginIndex = category.getBeginIndex();
          }
          if (!endLine) {
            endIndex = category.getEndIndex();
          }

          // Decide in the fix can be automatic
          boolean automatic = false;
          if (category.getBeginIndex() > keepCategory.getBeginIndex()) {
            int currentIndex = keepCategory.getEndIndex();
            boolean finished = false;
            while (!finished && (currentIndex < category.getBeginIndex())) {
              char currentChar = contents.charAt(currentIndex);
              if ((currentChar == ' ') || (currentChar == '\n')) {
                currentIndex++;
              } else {
                PageElementCategory nextCategory = analysis.isInCategory(currentIndex);
                if (nextCategory != null) {
                  currentIndex = nextCategory.getEndIndex();
                } else {
                  finished = true;
                }
              }
            }
            if (currentIndex >= keepCategory.getBeginIndex()) {
              if ((category.getSort() != null) &&
                  (category.getSort().length() > 0)) {
                if (category.getSort().equals(keepCategory.getSort())) {
                  automatic = true;
                }
              } else {
                if ((keepCategory.getSort() == null) ||
                    (keepCategory.getSort().length() == 0)) {
                  automatic = true;
                }
              }
            }
          }

          // Mark the error
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, beginIndex, endIndex);
          errorResult.addReplacement("", GT._("Delete"), automatic);
          errors.add(errorResult);
        }
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.