Package org.wikipediacleaner.api.data

Examples of org.wikipediacleaner.api.data.PageElementTag$Parameter


    String contents = analysis.getContents();
    for (PageElementInternalLink link : links) {
      // Check if it is an error
      boolean errorFound = Page.areSameTitle(pageTitle, link.getFullLink());
      if (errorFound) {
        PageElementTag tagIncludeOnly = analysis.getSurroundingTag(
            PageElementTag.TAG_WIKI_INCLUDEONLY, link.getBeginIndex());
        if (tagIncludeOnly != null) {
          errorFound = false;
        }
      }

      // Report error
      if (errorFound) {
        if (errors == null) {
          return true;
        }
        result = true;
        PageElementTag tagImagemap = analysis.getSurroundingTag(
            PageElementTag.TAG_WIKI_IMAGEMAP, link.getBeginIndex());
        if (tagImagemap != null) {
          int previousCR = getPreviousCR(contents, link.getBeginIndex());
          int nextCR = getNextCR(contents, link.getEndIndex());
          nextCR = Math.min(nextCR, tagImagemap.getMatchingTag().getBeginIndex());
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, previousCR, nextCR);
          if ((previousCR > tagImagemap.getEndIndex()) &&
              (contents.charAt(nextCR) == '\n')) {
            errorResult.addReplacement("", GT._("Delete"));
          }
          errors.add(errorResult);
        } else {
View Full Code Here


    String pageTitle = analysis.getPage().getTitle();
    Collection<PageElementInternalLink> links = analysis.getInternalLinks();
    int currentIndex = 0;
    for (PageElementInternalLink link : links) {
      if (Page.areSameTitle(pageTitle, link.getFullLink())) {
        PageElementTag tagImagemap = analysis.getSurroundingTag(
            PageElementTag.TAG_WIKI_IMAGEMAP, link.getBeginIndex());
        if (tagImagemap != null) {
          int previousCR = getPreviousCR(contents, link.getBeginIndex());
          int nextCR = getNextCR(contents, link.getEndIndex());
          nextCR = Math.min(nextCR, tagImagemap.getMatchingTag().getBeginIndex());
          if ((previousCR > tagImagemap.getEndIndex()) &&
              (contents.charAt(nextCR) == '\n')) {
            if (previousCR > currentIndex) {
              newContents.append(contents.substring(currentIndex, previousCR));
              currentIndex = nextCR;
            }
View Full Code Here

        if ((group != null) && (group.getValue() != null)) {
          groupName = group.getValue();
        }
 
        // Check if a <references> tag already exist for this group
        PageElementTag firstTag = firstTags.get(groupName);
        if (firstTag == null) {
          firstTags.put(groupName, referencesTag);
        } else {
          if (errors == null) {
            return true;
          }
          result = true;
          if (!tagUsed.contains(groupName)) {
            tagUsed.add(groupName);
            CheckErrorResult errorResult = createCheckErrorResult(
                analysis,
                firstTag.getCompleteBeginIndex(),
                firstTag.getCompleteEndIndex(),
                ErrorLevel.CORRECT);
            errorResult.addReplacement("");
            errors.add(errorResult);
          }
          CheckErrorResult errorResult = createCheckErrorResult(
View Full Code Here

              int tmpIndex = paramValueStartIndex + currentPos;
              PageElementComment comment = analysis.isInComment(tmpIndex);
              if (comment != null) {
                currentPos = comment.getEndIndex() - 1 - paramValueStartIndex;
              } else {
                PageElementTag tag = analysis.isInTag(tmpIndex);
                if ((tag != null) &&
                    (tag.getBeginIndex() == tmpIndex) &&
                    ((PageElementTag.TAG_WIKI_MATH.equals(tag.getNormalizedName())) ||
                     (PageElementTag.TAG_WIKI_NOWIKI.equals(tag.getNormalizedName())) ||
                     (PageElementTag.TAG_WIKI_SOURCE.equals(tag.getNormalizedName())) ||
                     (PageElementTag.TAG_WIKI_SCORE.equals(tag.getNormalizedName())) ||
                     (PageElementTag.TAG_WIKI_SYNTAXHIGHLIGHT.equals(tag.getNormalizedName())))) {
                  currentPos = tag.getCompleteEndIndex() - 1 - paramValueStartIndex;
                }
              }
              break;
            case '[':
              squareBracketsCount++;
View Full Code Here

    List<PageElementTag> refTags = analysis.getTags(PageElementTag.TAG_WIKI_REF);
    if ((refTags != null) && (refTags.size() > 0)) {
      Iterator<PageElementTag> itRefTags = refTags.iterator();
      while (!refFound && itRefTags.hasNext()) {
        boolean usefulRef = true;
        PageElementTag refTag = itRefTags.next();
        if (analysis.getSurroundingTag(PageElementTag.TAG_WIKI_NOWIKI, refTag.getBeginIndex()) != null) {
          usefulRef =  false;
        }
        if (usefulRef) {
          refFound = true;
        }
      }
    }
    if (!refFound) {
      return false;
    }

    // Analyzing text for <references> tags
    List<PageElementTag> referencesTags = analysis.getTags(PageElementTag.TAG_WIKI_REFERENCES);
    if (referencesTags != null) {
      for (PageElementTag referencesTag : referencesTags) {
        if (referencesTag.isComplete()) {
          return false;
        }
      }
    }

    // Search for templates like {{References}}
    String templates = getSpecificProperty(
        "templates", true, true, false);
    if (templates == null) {
      templates = getSpecificProperty(
          "references_templates", true, true, false);
    }
    List<String> referencesTemplates = null;
    if (templates != null) {
      referencesTemplates = WPCConfiguration.convertPropertyToStringList(templates);
    }
    if (referencesTemplates != null) {
      List<PageElementTemplate> allTemplates = analysis.getTemplates();
      int templateNum = allTemplates.size();
      while (templateNum > 0) {
        templateNum--;
        PageElementTemplate template = allTemplates.get(templateNum);
        for (String referencesTemplate : referencesTemplates) {
          if (Page.areSameTitle(template.getTemplateName(), referencesTemplate)) {
            return false;
          }
        }
      }
    }

    // Try to make some suggestions
    if (errors == null) {
      return true;
    }
    String contents = analysis.getContents();
    if (referencesTags != null) {
      for (PageElementTag referencesTag : referencesTags) {
        CheckErrorResult errorResult = createCheckErrorResult(
            analysis, referencesTag.getBeginIndex(), referencesTag.getEndIndex());
        if (referencesTags.size() == 1) {
          errorResult.addReplacement(
              PageElementTag.createTag(PageElementTag.TAG_WIKI_REFERENCES, true, true),
              GT._("Close tag"));
        }
        errors.add(errorResult);
        if (referencesTags.size() == 1) {
          int index = referencesTag.getEndIndex();
          boolean ok = true;
          while (ok && (index < contents.length())) {
            char currentChar = contents.charAt(index);
            if (Character.isWhitespace(currentChar)) {
              index++;
            } else if (currentChar == '<') {
              PageElementTag tag = analysis.isInTag(index);
              if ((tag != null) &&
                  (tag.getBeginIndex() == index) &&
                  (PageElementTag.TAG_WIKI_REF.equals(tag.getNormalizedName()))) {
                index = tag.getCompleteEndIndex();
              } else {
                if (contents.startsWith("</references/>", index)) {
                  errorResult = createCheckErrorResult(analysis, index, index + 14);
                  errorResult.addReplacement(PageElementTag.createTag(
                      PageElementTag.TAG_WIKI_REFERENCES, true, false), true);
View Full Code Here

             (currentIndex < lastIndex) &&
             (contents.charAt(currentIndex) != '=')) {
        currentIndex = getFirstIndexAfterSpace(contents, currentIndex);
        if (currentIndex < lastIndex) {
          PageElementComment comment = null;
          PageElementTag tag = null;
          char currentChar = contents.charAt(currentIndex);
          if (currentChar == '<') {
            comment = analysis.isInComment(currentIndex);
            tag = analysis.isInTag(currentIndex, PageElementTag.TAG_WIKI_NOWIKI);
          }
          if (comment != null) {
            currentIndex = comment.getEndIndex();
          } else if (tag != null) {
            currentIndex = tag.getCompleteEndIndex();
          } else if (currentChar != '=') {
            if (!Character.isWhitespace(currentChar)) {
              textFound = true;
            }
            currentIndex++;
View Full Code Here

          while (!shouldStop) {
            shouldStop = true;
            currentValuePos = getLastIndexBeforeWhiteSpace(paramValue, currentValuePos);
            if ((currentValuePos > 0) &&
                (paramValue.charAt(currentValuePos) == '>')) {
              PageElementTag tag = analysis.isInTag(
                  paramValueStartIndex +
                  currentValuePos);
              if (tag != null) {
                String name = tag.getNormalizedName();
                if (PageElementTag.TAG_HTML_BR.equals(name)) {
                  breakFound = true;
                  shouldStop = false;
                  beginError = tag.getBeginIndex();
                  if (endError < 0) {
                    endError = tag.getEndIndex();
                  }
                  currentValuePos -= tag.getEndIndex() - tag.getBeginIndex();
                } else if (!breakFound) {
                  if (/*PageElementTag.TAG_WIKI_MATH.equals(name) ||*/
                      PageElementTag.TAG_WIKI_HIERO.equals(name)) {
                    tagAfter = true;
                    shouldStop = false;
                    endError = tag.getCompleteBeginIndex();
                    currentValuePos -= tag.getEndIndex() - tag.getCompleteBeginIndex();
                  }
                }
              } else {
                PageElementComment comment = analysis.isInComment(paramValueStartIndex + currentValuePos);
                if (comment != null) {
View Full Code Here

        valueIndex = comment.getEndIndex() - offset;

      // If current value position is the beginning of a reference, skip it
      } else if ((valueChar == '<') &&
                 (analysis.isInTag(offset + valueIndex, PageElementTag.TAG_WIKI_REF) != null)) {
        PageElementTag tag = analysis.isInTag(offset + valueIndex, PageElementTag.TAG_WIKI_REF);
        formatOk = true;
        valueIndex = tag.getCompleteEndIndex() - offset;

      } else if (formatIndex < format.length()) {
        char formatChar = format.charAt(formatIndex);

        // If format string has a quote, it can be for quoted text or really a quote
View Full Code Here

TOP

Related Classes of org.wikipediacleaner.api.data.PageElementTag$Parameter

Copyright © 2018 www.massapicom. 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.