Package org.wikipediacleaner.api.data

Examples of org.wikipediacleaner.api.data.PageElementTag


          Page.areSameTitle(pageTitle, linkedPage.getRedirectTitle())) {
        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


          (contents.charAt(beginIndex) == '[')) {

        // Compute maximum index for link end
        int linkEndIndex = link.getEndIndex();
        int maxEnd = maxLength;
        PageElementTag refTag = analysis.getSurroundingTag(PageElementTag.TAG_WIKI_REF, linkBeginIndex);
        if ((refTag != null) &&
            (refTag.getMatchingTag() != null) &&
            (refTag.getMatchingTag().getBeginIndex() >= linkEndIndex)) {
          maxEnd = refTag.getMatchingTag().getBeginIndex();
        }

        // Search for possible end
        boolean searchDone = false;
        int possibleEnd = -1;
View Full Code Here

    // Analyze each <small> tag
    boolean result = false;
    List<PageElementTag> smallTags = analysis.getTags(PageElementTag.TAG_HTML_SMALL);
    for (PageElementTag smallTag : smallTags) {
      int index = smallTag.getBeginIndex();
      PageElementTag refTag = analysis.getSurroundingTag(PageElementTag.TAG_WIKI_REF, index);
      PageElementTag subTag = analysis.getSurroundingTag(PageElementTag.TAG_HTML_SUB, index);
      PageElementTag supTag = analysis.getSurroundingTag(PageElementTag.TAG_HTML_SUP, index);
      if ((refTag != null) || (subTag != null) || (supTag != null)) {
        if (errors == null) {
          return true;
        }
        result = true;
View Full Code Here

              endError = currentIndex;
            }
            currentIndex--;
          }
          if (contents.charAt(currentIndex) == '>') {
            PageElementTag tag = analysis.isInTag(currentIndex);
            if (tag != null) {
              String name = tag.getNormalizedName();
              if (PageElementTag.TAG_HTML_BR.equals(name)) {
                breakFound = true;
                shouldStop = false;
                beginError = tag.getBeginIndex();
                currentIndex = beginError - 1;
              } else if (!breakFound) {
                /*if (PageElementTag.TAG_WIKI_MATH.equals(name)) {
                  tagAfter = true;
                  shouldStop = false;
View Full Code Here

    boolean result = false;
    int index = 0;
    while (index < galleryTags.size()) {

      // Check for error
      PageElementTag galleryTag = galleryTags.get(index);
      boolean found = false;
      if (galleryTag.isFullTag() || !galleryTag.isComplete()) {
        found = true;
      }
      int beginIndex = galleryTag.getBeginIndex();
      if (found) {
        if (analysis.getSurroundingTag(PageElementTag.TAG_WIKI_NOWIKI, beginIndex) != null) {
          found = false;
        }
      }

      if (found) {
        if (errors == null) {
          return true;
        }
        result = true;

        // Check if an other <gallery> tag is just after and can be used
        PageElementTag nextTag = null;
        if (!galleryTag.isEndTag() && (index + 1 < galleryTags.size())) {
          nextTag = galleryTags.get(index + 1);
          int currentIndex = galleryTag.getEndIndex();
          while ((nextTag != null) && (currentIndex < nextTag.getBeginIndex())) {
            char currentChar = contents.charAt(currentIndex);
            if ((currentChar != ' ') && (currentChar != '\n')) {
              nextTag = null;
            }
            currentIndex++;
          }
          if (nextTag != null) {
            if ((galleryTag.getParametersCount() > 0) &&
                (nextTag.getParametersCount() > 0)) {
              nextTag = null;
            }
          }
        }

        // Report error
        int endIndex = (nextTag != null) ? nextTag.getEndIndex() : galleryTag.getEndIndex();
        CheckErrorResult errorResult = createCheckErrorResult(
            analysis, beginIndex, endIndex);
        if (nextTag == null) {
          errorResult.addReplacement("");
          index++;
        } else if (nextTag.getParametersCount() == 0) {
          errorResult.addReplacement(contents.substring(
              galleryTag.getBeginIndex(), galleryTag.getEndIndex()));
          errorResult.addReplacement(contents.substring(
              nextTag.getBeginIndex(), nextTag.getEndIndex()));
          index += 2;
        } else {
          errorResult.addReplacement(contents.substring(
              nextTag.getBeginIndex(), nextTag.getEndIndex()));
          errorResult.addReplacement(contents.substring(
              galleryTag.getBeginIndex(), galleryTag.getEndIndex()));
          index += 2;
        }
        errors.add(errorResult);
View Full Code Here

      // Check if inside a specific tag
      if (shouldCheck) {
        for (String tagName : exceptTags) {
          if (shouldCheck) {
            PageElementTag tag = analysis.getSurroundingTag(tagName, currentIndex);
            if (tag != null) {
              nextIndex = tag.getCompleteEndIndex();
              shouldCheck  = false;
            }
          }
        }
      }
View Full Code Here

    String contents = analysis.getContents();
    for (PageElementExternalLink link : links) {
      String text = link.getText();
      if ((text == null) || (text.trim().length() == 0)) {
        boolean hasError = false;
        PageElementTag refTag = analysis.getSurroundingTag(
            PageElementTag.TAG_WIKI_REF, link.getBeginIndex());
        if (link.hasSquare()) {
          hasError = true;
        } else {
          PageElementTemplate template = analysis.isInTemplate(link.getBeginIndex());
          if (template == null) {
            if (refTag != null) {
              hasError = true;
            }
          }
        }
        if (hasError) {
          if (errors == null) {
            return true;
          }
          result = true;
          String url = link.getLink();
          int endIndex = link.getEndIndex();
          String suffix =  "";
          if ((refTag != null) &&
              (refTag.getMatchingTag() != null) &&
              (refTag.getMatchingTag().getBeginIndex() > endIndex)) {
            while ((endIndex < refTag.getMatchingTag().getBeginIndex()) &&
                   (contents.charAt(endIndex) != '[') &&
                   (contents.charAt(endIndex) != ']')) {
              endIndex++;
            }
            if (endIndex > link.getEndIndex()) {
View Full Code Here

      for (Entry<String, List<PageElementTag>> entryValue : entryGroup.getValue().entrySet()) {
        List<PageElementTag> listTags = entryValue.getValue();
        if (listTags.size() > 1) {

          // Find main reference tag
          PageElementTag mainTag = PageElementTag.getMainRef(
              listTags, completeReferencesTags, analysis);
          if (mainTag != null) {

            // Create an error for each tag, except for the main tag
            String selectedName = mainTag.getParameter("name").getTrimmedValue();
            for (PageElementTag tag : listTags) {
              if (tag == mainTag) {
                CheckErrorResult errorResult = createCheckErrorResult(
                    analysis,
                    tag.getCompleteBeginIndex(), tag.getCompleteEndIndex(),
View Full Code Here

        // Check if a name already exists
        String replacement = null;
        List<String> possibleNames = refNamesByGroupAndValue.get(groupName).get(valueRef);
        if ((possibleNames != null) && (possibleNames.size() > 0)) {
          String selectedName = possibleNames.get(0);
          PageElementTag mainRef = PageElementTag.getMainRef(
              valueRefs, completeReferencesTags, analysis);
          if (mainRef != refTag) {
            String tmp = getClosedRefTag(groupName, selectedName, null);
            String message =
                GT._("A <ref> tag shares the same content, and is named \"{0}\".", selectedName) + "\n" +
View Full Code Here

      } else if (element instanceof PageElementLanguageLink) {
        style = doc.getStyle(ConfigurationValueStyle.LANGUAGE_LINK.getName());
      } else if (element instanceof PageElementParameter) {
        style = doc.getStyle(ConfigurationValueStyle.PROGRAMMING.getName());
      } else if (element instanceof PageElementTag) {
        PageElementTag tag = (PageElementTag) element;
        String name = tag.getNormalizedName();
        if (PageElementTag.TAG_WIKI_REF.equals(name) ||
            PageElementTag.TAG_WIKI_REFERENCES.equals(name)) {
          style = doc.getStyle(ConfigurationValueStyle.REFERENCE.getName());
          if (style != null) {
            endIndex = tag.getCompleteEndIndex();
          }
        }
        if (style == null) {
          style = doc.getStyle(ConfigurationValueStyle.TAG.getName());
        }
View Full Code Here

TOP

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

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.