langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java
author ksrini
Sat, 28 Nov 2015 18:52:17 -0800
changeset 35426 374342e56a56
parent 33920 langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java@bd731341c405
child 40303 96a1226aca18
permissions -rw-r--r--
8035473: [javadoc] Revamp the existing Doclet APIs 8146529: Update the new Doclet API 8146427: "-nohelp" option issue 8146475: "-helpfile" option issue Reviewed-by: alanb, bpatel, ihse, jjg, jlahoda, mchung, ogb, vromero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
     2
 * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    26
package jdk.javadoc.internal.doclets.formats.html;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    28
import java.io.*;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    29
import java.util.ArrayList;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    30
import java.util.Collection;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    31
import java.util.List;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    32
import java.util.ListIterator;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    33
import java.util.Set;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    34
import java.util.TreeSet;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    35
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    36
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    37
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    38
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    39
import jdk.javadoc.internal.doclets.toolkit.Content;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    40
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    41
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    42
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    43
import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 7681
diff changeset
    44
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * Generate Separate Index Files for all the member names with Indexing in
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * Unicode Order. This will create "index-files" directory in the current or
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * destination directory and will generate separate file for each unicode index.
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    51
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    52
 *  If you write code that depends on this, you do so at your own risk.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    53
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    54
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    55
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * @see java.lang.Character
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * @author Atul M Dambalkar
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    58
 * @author Bhavesh Patel (Modified)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
public class SplitIndexWriter extends AbstractIndexWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * Previous unicode character index in the built index.
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    protected int prev;
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     * Next unicode character in the built index.
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    protected int next;
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    72
    private List<Character> indexElements;
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
    73
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     * Construct the SplitIndexWriter. Uses path to this file and relative path
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * from this file.
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * @param path       Path to the file which is getting generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * @param indexbuilder Unicode based Index from {@link IndexBuilder}
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    public SplitIndexWriter(ConfigurationImpl configuration,
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14260
diff changeset
    82
                            DocPath path,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    83
                            IndexBuilder indexbuilder,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    84
                            Collection<Character> elements,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
                            int prev, int next) throws IOException {
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14260
diff changeset
    86
        super(configuration, path, indexbuilder);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
    87
        this.indexElements = new ArrayList<>(elements);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
        this.prev = prev;
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
        this.next = next;
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * Generate separate index files, for each Unicode character, listing all
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * the members starting with the particular unicode character.
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * @param indexbuilder IndexBuilder built by {@link IndexBuilder}
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * @throws DocletAbortException
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    public static void generate(ConfigurationImpl configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
                                IndexBuilder indexbuilder) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        SplitIndexWriter indexgen;
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14260
diff changeset
   102
        DocPath filename = DocPath.empty;
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14260
diff changeset
   103
        DocPath path = DocPaths.INDEX_FILES;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
        try {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   105
            Set<Character> keys = new TreeSet<>(indexbuilder.getIndexMap().keySet());
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   106
            keys.addAll(configuration.tagSearchIndexKeys);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   107
            ListIterator<Character> li = new ArrayList<>(keys).listIterator();
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   108
            while (li.hasNext()) {
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   109
                Object ch = li.next();
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   110
                filename = DocPaths.indexN(li.nextIndex());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
                indexgen = new SplitIndexWriter(configuration,
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   112
                        path.resolve(filename),
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 33920
diff changeset
   113
                        indexbuilder, keys, li.previousIndex(), li.nextIndex());
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   114
                indexgen.generateIndexFile((Character) ch);
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   115
                if (!li.hasNext()) {
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   116
                    indexgen.createSearchIndexFiles();
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   117
                }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
                indexgen.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        } catch (IOException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
            configuration.standardmessage.error(
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
                        "doclet.exception_encountered",
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14260
diff changeset
   123
                        exc.toString(), filename.getPath());
19667
fdfce85627a9 8001669: javadoc internal DocletAbortException should set cause when appropriate
jjg
parents: 14366
diff changeset
   124
            throw new DocletAbortException(exc);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     * Generate the contents of each index file, with Header, Footer,
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     * Member Field, Method and Constructor Description.
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     * @param unicode Unicode character referring to the character for the
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * index.
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    protected void generateIndexFile(Character unicode) throws IOException {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   136
        String title = configuration.getText("doclet.Window_Split_Index",
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   137
                unicode.toString());
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   138
        HtmlTree body = getBody(true, getWindowTitle(title));
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   139
        HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   140
                ? HtmlTree.HEADER()
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   141
                : body;
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   142
        addTop(htmlTree);
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   143
        addNavLinks(true, htmlTree);
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   144
        if (configuration.allowTag(HtmlTag.HEADER)) {
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   145
            body.addContent(htmlTree);
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   146
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   147
        HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   148
        divTree.addStyle(HtmlStyle.contentContainer);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   149
        addLinksForIndexes(divTree);
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   150
        if (configuration.tagSearchIndexMap.get(unicode) == null) {
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   151
            addContents(unicode, indexbuilder.getMemberList(unicode), divTree);
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   152
        } else if (indexbuilder.getMemberList(unicode) == null) {
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   153
            addSearchContents(unicode, configuration.tagSearchIndexMap.get(unicode), divTree);
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   154
        } else {
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   155
            addContents(unicode, indexbuilder.getMemberList(unicode),
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   156
                    configuration.tagSearchIndexMap.get(unicode), divTree);
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   157
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   158
        addLinksForIndexes(divTree);
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   159
        body.addContent((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(divTree) : divTree);
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   160
        if (configuration.allowTag(HtmlTag.FOOTER)) {
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   161
            htmlTree = HtmlTree.FOOTER();
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   162
        }
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   163
        addNavLinks(false, htmlTree);
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   164
        addBottom(htmlTree);
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   165
        if (configuration.allowTag(HtmlTag.FOOTER)) {
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   166
            body.addContent(htmlTree);
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 25874
diff changeset
   167
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   168
        printHtmlDocument(null, true, body);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   172
     * Add links for all the Index Files per unicode character.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   173
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   174
     * @param contentTree the content tree to which the links for indexes will be added
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   176
    protected void addLinksForIndexes(Content contentTree) {
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   177
        for (int i = 0; i < indexElements.size(); i++) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
            int j = i + 1;
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14260
diff changeset
   179
            contentTree.addContent(getHyperLink(DocPaths.indexN(j),
33920
bd731341c405 8141492: Implement search feature in javadoc
bpatel
parents: 29957
diff changeset
   180
                    new StringContent(indexElements.get(i).toString())));
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   181
            contentTree.addContent(getSpace());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   186
     * Get link to the previous unicode character.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   187
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   188
     * @return a content tree for the link
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   190
    public Content getNavLinkPrevious() {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   191
        Content prevletterLabel = getResource("doclet.Prev_Letter");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        if (prev == -1) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   193
            return HtmlTree.LI(prevletterLabel);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   194
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   195
        else {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   196
            Content prevLink = getHyperLink(DocPaths.indexN(prev),
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   197
                    prevletterLabel);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   198
            return HtmlTree.LI(prevLink);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   203
     * Get link to the next unicode character.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   204
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   205
     * @return a content tree for the link
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   207
    public Content getNavLinkNext() {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   208
        Content nextletterLabel = getResource("doclet.Next_Letter");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        if (next == -1) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   210
            return HtmlTree.LI(nextletterLabel);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   211
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   212
        else {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   213
            Content nextLink = getHyperLink(DocPaths.indexN(next),
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   214
                    nextletterLabel);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   215
            return HtmlTree.LI(nextLink);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
}