Examples of PageElementExternalLink


Examples of org.wikipediacleaner.api.data.PageElementExternalLink

            firstCrIndex = currentIndex;
          }

          // Check for an other external link
          if (!posDone) {
            PageElementExternalLink externalLink = analysis.isInExternalLink(currentIndex);
            if (externalLink != null) {
              possibleEnd = currentIndex;
              searchDone = true;
              posDone = true;
            }
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementExternalLink

           (analysis.getSurroundingTag(PageElementTag.TAG_WIKI_SOURCE, ampersandIndex) != null) ||
           (analysis.getSurroundingTag(PageElementTag.TAG_WIKI_SYNTAXHIGHLIGHT, ampersandIndex) != null))) {
        shouldMatch = false;
      }
      if (shouldMatch) {
        PageElementExternalLink link = analysis.isInExternalLink(ampersandIndex);
        if (link != null) {
          int offset = link.getTextOffset();
          if ((offset < 0) || (ampersandIndex < link.getBeginIndex() + offset)) {
            shouldMatch = false;
          }
        }
      }
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementExternalLink

        if ((link != null) && (link.getBeginIndex() == currentIndex)) {
          shouldCount = false;
        }
      }
      if (shouldCount) {
        PageElementExternalLink link = analysis.isInExternalLink(currentIndex + 1);
        if ((link != null) && (link.getBeginIndex() == currentIndex + 1)) {
          shouldCount = false;
        }
      }
      if (shouldCount) {
        if ((analysis.isInComment(currentIndex) != null) ||
            (analysis.getSurroundingTag(PageElementTag.TAG_WIKI_NOWIKI, currentIndex) != null) ||
            (analysis.getSurroundingTag(PageElementTag.TAG_WIKI_MATH, currentIndex) != null) ||
            (analysis.getSurroundingTag(PageElementTag.TAG_WIKI_SCORE, currentIndex) != null) ||
            (analysis.getSurroundingTag(PageElementTag.TAG_WIKI_SOURCE, currentIndex) != null) ||
            (analysis.getSurroundingTag(PageElementTag.TAG_WIKI_SYNTAXHIGHLIGHT, currentIndex) != null) ||
            (analysis.isInTag(currentIndex) != null)) {
          shouldCount = false;
        }
      }
      if (shouldCount) {
        PageElementTemplate template = analysis.isInTemplate(currentIndex + 2);
        if ((template != null) && (contents.startsWith("]]", template.getEndIndex()))) {
          shouldCount = false;
        }
      }
      if (shouldCount) {
        if (errors == null) {
          return true;
        }
        result = true;
       
        // Check if there is a potential end
        int tmpIndex = currentIndex + 2;
        boolean errorReported = false;
        boolean finished = false;
        while (!finished && (tmpIndex < maxLength)) {
          char tmpChar = contents.charAt(tmpIndex);
          if (REJECTED_CHARS.indexOf(tmpChar) >= 0) {
            finished = true;
          } else if (tmpChar == ']') {
            int tmpIndex2 = tmpIndex + 1;
            while ((tmpIndex2 < maxLength) &&
                   (contents.charAt(tmpIndex2) != ']') &&
                   (REJECTED_CHARS.indexOf(contents.charAt(tmpIndex2)) < 0)) {
              tmpIndex2++;
            }
            String suffix = "";
            if ((tmpIndex2 < maxLength) && (contents.charAt(tmpIndex2) == ']')) {
              suffix = contents.substring(tmpIndex + 1, tmpIndex2 + 1);
            } else {
              tmpIndex2 = tmpIndex;
            }
            CheckErrorResult errorResult = createCheckErrorResult(
                analysis, currentIndex, tmpIndex2 + 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, tmpIndex2 + 1));
            }

            errorResult.addReplacement(contents.substring(currentIndex, tmpIndex + 1) + "]" + suffix);
            if (suffix.length() > 0) {
              errorResult.addReplacement(contents.substring(currentIndex, tmpIndex) + suffix + "]");
            }
            errors.add(errorResult);
            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);
            errorReported = true;
            finished = true;
          }
          tmpIndex++;
        }

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

    // Analyze each internal link to see if it contains a [
    for (PageElementInternalLink link : analysis.getInternalLinks()) {
      String text = link.getText();
      if (text != null) {
        text = cleanText(text);
        if (text != null) {
          if (errors == null) {
            return true;
          }
          result = true;
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, link.getBeginIndex(), link.getEndIndex());
          errorResult.addReplacement(PageElementInternalLink.createInternalLink(
              link.getLink(), link.getAnchor(), text));
          errors.add(errorResult);
        }
      }
    }

    // Analyze each image to see if it contains a [
    for (PageElementImage image : analysis.getImages()) {
      String text = image.getDescription();
      String modifiedText = cleanText(text);
      String alt = image.getAlternateDescription();
      String modifiedAlt = cleanText(alt);
      if ((modifiedText != null) || (modifiedAlt != null)) {
        if (errors == null) {
          return true;
        }
        result = true;
        CheckErrorResult errorResult = createCheckErrorResult(
            analysis, image.getBeginIndex(), image.getEndIndex());
        errorResult.addReplacement(image.getDescriptionReplacement(
            (modifiedText != null) ? modifiedText : text,
            (modifiedAlt != null) ? modifiedAlt : alt));
        errors.add(errorResult);
      }
    }

    // Analyze each external link to see if it has a [ before
    for (PageElementExternalLink link : analysis.getExternalLinks()) {
      int begin = link.getBeginIndex();
      if (link.hasSquare()) {
        if ((begin > 0) && (contents.charAt(begin - 1) == '[')) {
          int end = link.getEndIndex();
          if ((end >= contents.length()) || (contents.charAt(end) != ']')) {
            if (errors == null) {
              return true;
            }
            result = true;
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementExternalLink

            (Character.isLetterOrDigit(text.charAt(index + prefix.length())))) {
          boolean shouldCount = true;
          int currentIndex = beginIndex + index;
          if (shouldCount) {
            // Check for external link
            PageElementExternalLink link = analysis.isInExternalLink(currentIndex);
            if (link != null) {
              shouldCount = false;
            }
          }
          if (shouldCount) {
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementExternalLink

      return createDefaultPopupImage(textPane, position, pageAnalysis, image);
    }

    // Menu for external link
    if (element instanceof PageElementExternalLink) {
      PageElementExternalLink externalLink = (PageElementExternalLink) element;
      return createDefaultPopupExternalLink(pageAnalysis, position, externalLink);
    }

    // Menu for template
    if (element instanceof PageElementTemplate) {
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementExternalLink

            (contents.startsWith("[[", template.getBeginIndex() - 2))) {
          shouldCount = false;
        }
      }
      if (shouldCount) {
        PageElementExternalLink link = analysis.isInExternalLink(currentIndex);
        if ((link != null) &&
            (link.getEndIndex() == currentIndex + 1)) {
          if ((link.getBeginIndex() == 0) ||
              (contents.charAt(link.getBeginIndex() - 1) != '[')) {
            if (errors == null) {
              return true;
            }
            result = true;
            CheckErrorResult errorResult = createCheckErrorResult(
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementExternalLink

          }
          if (!isbn.isTemplateParameter()) {
            if (error.toUpperCase().startsWith("ISBN")) {
              error = error.substring(4).trim();
            }
            PageElementExternalLink link = analysis.isInExternalLink(beginIndex);
            if (link != null) {
              if (!link.hasSquare() ||
                  (link.getText() == null) ||
                  link.getText().isEmpty()) {
                keep = false;
              } else if (beginIndex < link.getBeginIndex() + link.getLink().length()) {
                keep = false;
              }
            }
          }
        }
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.