コード例 #1
0
 /*
  * Logic for adding various end index entry elements for Eclipse help.
  *
  * @param term  The indexterm to be processed.
  * @param printWriter The Writer used for writing content to disk.
  * @param indexsee Boolean value for using the new markup for see references.
  */
 private void outputIndexTermEndElement(
     final IndexTerm term, final XMLStreamWriter serializer, final boolean indexsee)
     throws XMLStreamException {
   if (indexsee) {
     if (term.getTermPrefix() != null) {
       serializer.writeEndElement(); // see
       inIndexsee = false;
     } else if (term.getTermPrefix() == null && inIndexsee) {
       // NOOP
     } else {
       serializer.writeEndElement(); // entry
     }
   } else {
     serializer.writeEndElement(); // entry
   }
 }
コード例 #2
0
  private void outputIndexEntryEclipseIndexsee(
      final IndexTerm term, final XMLStreamWriter serializer) throws XMLStreamException {
    final List<IndexTermTarget> targets = term.getTargetList();
    final int targetNum = targets.size();

    // Index-see and index-see-also terms should also generate links to its
    // target
    // Otherwise, the term won't be displayed in the index tab.
    if (targets != null && !targets.isEmpty()) {
      for (int i = 0; i < targetNum; i++) {
        final IndexTermTarget target = targets.get(i);
        final String targetUri = target.getTargetURI();
        final String targetName = target.getTargetName();
        if (targetUri == null) {
          serializer.writeStartElement("topic");
          serializer.writeAttribute("title", target.getTargetName());
          serializer.writeEndElement(); // topic
        } else {
          serializer.writeStartElement("topic");
          serializer.writeAttribute("href", replaceExtName(targetUri));

          if (targetName.trim().length() > 0) {
            serializer.writeAttribute("title", target.getTargetName());
          }
          serializer.writeEndElement(); // topic
        }
      }
    } // end for
  }
コード例 #3
0
 /**
  * Output the given indexterm into the XML writer.
  *
  * @param term term to serialize
  * @param serializer XML output to write to
  * @param indexsee is term a see term
  * @throws SAXException if serialization failed
  */
 private void outputIndexTerm(
     final IndexTerm term, final XMLStreamWriter serializer, final boolean indexsee)
     throws XMLStreamException {
   final List<IndexTerm> subTerms = term.getSubTerms();
   final int subTermNum = subTerms.size();
   outputIndexTermStartElement(term, serializer, indexsee);
   if (subTerms != null && subTermNum > 0) {
     for (int i = 0; i < subTermNum; i++) {
       final IndexTerm subTerm = subTerms.get(i);
       outputIndexTerm(subTerm, serializer, indexsee);
     }
   }
   outputIndexTermEndElement(term, serializer, indexsee);
 }
コード例 #4
0
 /*
  * Logic for adding various start index entry elements for Eclipse help.
  *
  * @param term  The indexterm to be processed.
  * @param printWriter The Writer used for writing content to disk.
  * @param indexsee Boolean value for using the new markup for see references.
  */
 private void outputIndexTermStartElement(
     final IndexTerm term, final XMLStreamWriter serializer, final boolean indexsee)
     throws XMLStreamException {
   // RFE 2987769 Eclipse index-see
   if (indexsee) {
     if (term.getTermPrefix() != null) {
       inIndexsee = true;
       serializer.writeStartElement("see");
       serializer.writeAttribute("keyword", term.getTermName());
     } else if (term.getTermPrefix() == null && inIndexsee) { // subterm of an indexsee.
       serializer.writeStartElement("subpath");
       serializer.writeAttribute("keyword", term.getTermName());
       serializer.writeEndElement(); // subpath
     } else {
       serializer.writeStartElement("entry");
       serializer.writeAttribute("keyword", term.getTermName());
       outputIndexEntryEclipseIndexsee(term, serializer);
     }
   } else {
     serializer.writeStartElement("entry");
     serializer.writeAttribute("keyword", term.getTermFullName());
     outputIndexEntry(term, serializer);
   }
 }
コード例 #5
0
  /*
   * Method for see references in Eclipse. This version does not have a
   * dependency on a specific Eclipse version.
   *
   * @param term  The indexterm to be processed.
   * @param printWriter The Writer used for writing content to disk.
   */
  private void outputIndexEntry(final IndexTerm term, final XMLStreamWriter serializer)
      throws XMLStreamException {

    final List<IndexTermTarget> targets = term.getTargetList();
    final int targetNum = targets.size();

    boolean foundIndexTerm = false;
    boolean foundIndexsee = false;

    String indexSeeRefTerm = null;

    /*
     * Use the cloned List to find the index-see reference in the list. If
     * found use that target URI for the href value, otherwise return a
     * warning to the build. RFE 2987769 Eclipse index-see
     */
    final int termCloneNum = termCloneList.size();

    // Index-see and index-see-also terms should also generate links to its
    // target
    // Otherwise, the term won't be displayed in the index tab.
    if (targets != null && !targets.isEmpty()) {
      for (int i = 0; i < targetNum; i++) {
        final IndexTermTarget target = targets.get(i);
        final String targetUri = target.getTargetURI();
        final String targetName = target.getTargetName();
        if (targetUri == null) {
          serializer.writeStartElement("topic");
          serializer.writeAttribute("title", target.getTargetName());
          serializer.writeEndElement(); // topic
        } else if (targetName != null && targetName.trim().length() > 0) {
          /*
           * Check to see if the target Indexterm is a "see"
           * reference.Added inIndexsee so we know that we are still
           * processing contentfrom a referenced indexterm.
           */
          if (term.getTermPrefix() != null || inIndexsee) {
            indexSeeRefTerm = term.getTermName();
            inIndexsee = true;
            foundIndexsee = true;
            // Find the term with an href.
            for (int j = 0; j < termCloneNum; j++) {
              final IndexTerm termClone = termCloneList.get(j);
              if (term.getTermName().equals(termClone.getTermName())) {
                foundIndexTerm = true;
                if (termClone.getTargetList().size() > 0) {
                  serializer.writeStartElement("topic");
                  serializer.writeAttribute(
                      "href", replaceExtName(termClone.getTargetList().get(0).getTargetURI()));
                  if (targetName.trim().length() > 0) {
                    serializer.writeAttribute(
                        "title", termClone.getTargetList().get(0).getTargetName());
                  }
                  serializer.writeEndElement(); // topic
                }
                /*
                 * We found the term we are looking for, but it
                 * does not have a target name (title). We need
                 * to take a look at the subterms for the
                 * redirect and
                 */
                termCloneList = termClone.getSubTerms();
                break;
              }
            } // end for
            // If there are no subterms, then we are done.
            if (term.getSubTerms().size() == 0) {
              inIndexsee = false;
            }
          } else {
            serializer.writeStartElement("topic");
            serializer.writeAttribute("href", replaceExtName(targetUri));
            if (targetName.trim().length() > 0) {
              serializer.writeAttribute("title", target.getTargetName());
            }
            serializer.writeEndElement(); // topic
          }
        }
      } // end for
      if (!foundIndexTerm
          && foundIndexsee
          && indexSeeRefTerm != null
          && !indexSeeRefTerm.equals("***")) {
        logger.logWarn(
            MessageUtils.getInstance().getMessage("DOTJ050W", indexSeeRefTerm.trim()).toString());
      }
    }
  }