Examples of CheckErrorResult


Examples of org.wikipediacleaner.api.check.CheckErrorResult

        if ((text.length() > 0) && (text.charAt(text.length() - 1) == ':')) {
          if (errors == null) {
            return true;
          }
          result = true;
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis,
              title.getBeginIndex(), title.getEndIndex());
          errorResult.addReplacement(PageElementTitle.createTitle(
              title.getLevel(),
              text.substring(0, text.length() - 1),
              title.getAfterTitle()));
          errors.add(errorResult);
        }
View Full Code Here

Examples of org.wikipediacleaner.api.check.CheckErrorResult

      if (toc.getBeginIndex() >= firstTitle.getEndIndex()) {
        if (errors == null) {
          return true;
        }
        result = true;
        CheckErrorResult errorResult = createCheckErrorResult(
            analysis,
            toc.getBeginIndex(), toc.getEndIndex());
        errors.add(errorResult);
      }
    }
View Full Code Here

Examples of org.wikipediacleaner.api.check.CheckErrorResult

        if (endIndex > link.getEndIndex()) {
          if (errors == null) {
            return true;
          }
          result = true;
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, link.getBeginIndex(), endIndex);
          String replacement = PageElementInternalLink.createInternalLink(
              link.getLinkNotNormalized(), link.getAnchor(),
              link.getDisplayedTextNotTrimmed() + contents.substring(link.getEndIndex(), endIndex));
          errorResult.addReplacement(replacement, GT._("Compact link"));
          errors.add(errorResult);
        }
      }
    }
    return result;
View Full Code Here

Examples of org.wikipediacleaner.api.check.CheckErrorResult

              (tmpChar == ']') ||
              (tmpChar == '}')) {
            finished = true;
          } else if (tmpChar == '{') {
            if ((tmpIndex == 0) || (contents.charAt(tmpIndex - 1) != '{')) {
              CheckErrorResult errorResult = createCheckErrorResult(
                  analysis, tmpIndex, currentIndex + 2);
              errorResult.addReplacement("{" + contents.substring(tmpIndex, currentIndex + 2));
              errors.add(errorResult);
              result = true;
            }
            errorReported = true;
            finished = true;
          } else if (tmpChar == '[') {
            int firstChar = tmpIndex;
            if ((firstChar > 0) && (contents.charAt(firstChar - 1) == '[')) {
              firstChar--;
            }
            CheckErrorResult errorResult = createCheckErrorResult(
                analysis, firstChar, currentIndex + 2);
            errorResult.addReplacement("{{" + contents.substring(tmpIndex + 1, currentIndex + 2));
            errorResult.addReplacement("[[" + contents.substring(tmpIndex + 1, currentIndex) + "]]");
            errors.add(errorResult);
            result = true;
            errorReported = true;
            finished = true;
          }
          tmpIndex--;
        }

        // Default
        if (!errorReported) {
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, currentIndex, currentIndex + 2);
          errorResult.addReplacement("", GT._("Delete"));
          errors.add(errorResult);
          result = true;
        }
      }
      currentIndex = contents.indexOf("}}", currentIndex + 2);
View Full Code Here

Examples of org.wikipediacleaner.api.check.CheckErrorResult

    Object attrInfo = attributes.getAttribute(MWPaneFormatter.ATTRIBUTE_INFO);
    if (!(attrInfo instanceof CheckErrorResult)) {
      return null;
    }

    CheckErrorResult info = (CheckErrorResult) attrInfo;
    MWPaneCheckWikiMenuCreator menu = new MWPaneCheckWikiMenuCreator();
    JPopupMenu popup = menu.createPopupMenu(null);
    menu.addInfo(popup, element, textPane, info);
    return popup;
  }
View Full Code Here

Examples of org.wikipediacleaner.api.check.CheckErrorResult

          return true;
        }
        result = true;
        PageElementTitle previousTitle = knownTitles.get(titleValue);
        if (previousTitle != null) {
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis,
              previousTitle.getBeginIndex(), previousTitle.getEndIndex(),
              ErrorLevel.CORRECT);
          errors.add(errorResult);
          knownTitles.put(titleValue, null);
        }
        CheckErrorResult errorResult = createCheckErrorResult(
            analysis,
            title.getBeginIndex(), title.getEndIndex());
        errorResult.addEditTocAction();
        errors.add(errorResult);
      }

      previousTitleLevel = titleLevel;
    }
View Full Code Here

Examples of org.wikipediacleaner.api.check.CheckErrorResult

              (tmpChar == '{')) {
            finished = true;
          } else if (tmpChar == '}') {
            if ((tmpIndex + 1 >= maxLength) ||
                (contents.charAt(tmpIndex + 1) != '}')) {
              CheckErrorResult errorResult = createCheckErrorResult(
                  analysis, currentIndex, tmpIndex + 1);
              errorResult.addReplacement(contents.substring(currentIndex, tmpIndex + 1) + "}");
 
              // Check if the situation is something like [[http://....] (replacement: [http://....])
              boolean protocolFound = PageElementExternalLink.isPossibleProtocol(contents, currentIndex + 2);
              if (protocolFound) {
                errorResult.addReplacement(contents.substring(currentIndex + 1, tmpIndex + 1));
              }
 
              errors.add(errorResult);
              result = true;
            }
            errorReported = true;
            finished = true;
          } else if (tmpChar == ']') {
            int lastChar = tmpIndex;
            if ((lastChar + 1 < maxLength) && (contents.charAt(lastChar + 1) == ']')) {
              lastChar++;
            }
            CheckErrorResult errorResult = createCheckErrorResult(
                analysis, currentIndex, lastChar + 1);
            errorResult.addReplacement(contents.substring(currentIndex, tmpIndex) + "}}");
            errorResult.addReplacement("[[" + contents.substring(currentIndex + 2, tmpIndex) + "]]");
            errors.add(errorResult);
            result = true;
            errorReported = true;
            finished = true;
          }
          tmpIndex++;
        }

        // Default
        if (!errorReported) {
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, currentIndex, currentIndex + 2);
          errorResult.addReplacement("", GT._("Delete"));
          errors.add(errorResult);
          result = true;
        }
      }
      currentIndex = contents.indexOf("{{", currentIndex + 2);
View Full Code Here

Examples of org.wikipediacleaner.api.check.CheckErrorResult

        if (count == 0) {
          if (errors == null) {
            return true;
          }
          result = true;
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, title.getBeginIndex(), title.getEndIndex());
          errorResult.addEditTocAction();
          errors.add(errorResult);
        }
      }
      previousLevel = title.getLevel();
    }
View Full Code Here

Examples of org.wikipediacleaner.api.check.CheckErrorResult

        if (arrows != null) {
          if (errors == null) {
            return true;
          }
          result = true;
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, currentIndex, currentIndex + arrowLen);
          for (int i = 1; i < arrows.length; i++) {
            errorResult.addReplacement(arrows[i]);
          }
          errors.add(errorResult);
        }
        nextIndex = currentIndex + arrowLen;
      }
View Full Code Here

Examples of org.wikipediacleaner.api.check.CheckErrorResult

      if (PageElementCategory.DEFAULT_NAME.equalsIgnoreCase(category.getCategory())) {
        if (errors == null) {
          return true;
        }
        result = true;
        CheckErrorResult errorResult = createCheckErrorResult(
            analysis, category.getBeginIndex(), category.getEndIndex());
        errorResult.addPossibleAction(
            GT._("Check category"),
            new CheckCategoryLinkActionProvider(
                EnumWikipedia.EN, analysis.getWikipedia(),
                category.getName(), category.getSort()));
        List<String> replacements = new ArrayList<String>();
        if ((preferredCategory != null) &&
            (categoryNamespace.isPossibleName(preferredCategory))) {
          replacements.add(preferredCategory);
        }
        if (!replacements.contains(categoryNamespace.getCanonicalTitle())) {
          replacements.add(categoryNamespace.getCanonicalTitle());
        }
        for (String alias : categoryNamespace.getAliases()) {
          if (!replacements.contains(alias)) {
            replacements.add(alias);
          }
        }
        for (String replacement : replacements) {
          if (!PageElementCategory.DEFAULT_NAME.equalsIgnoreCase(replacement)) {
            errorResult.addReplacement(
                "[[" + replacement + ":" + category.getName() +
                ((category.getSort() != null) ? "|" + category.getSort() : "") + "]]");
          }
        }
        errorResult.addReplacement(
            "<!-- " + contents.substring(category.getBeginIndex(), category.getEndIndex()) + " -->",
            GT._("Comment category out"));
        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.