langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java
changeset 33920 bd731341c405
parent 29957 7740f9657f56
child 38617 d93a7f64e231
equal deleted inserted replaced
33919:e9fccc09cfc6 33920:bd731341c405
    24  */
    24  */
    25 
    25 
    26 package com.sun.tools.doclets.formats.html;
    26 package com.sun.tools.doclets.formats.html;
    27 
    27 
    28 import java.io.*;
    28 import java.io.*;
       
    29 import java.util.*;
    29 
    30 
    30 import com.sun.tools.doclets.formats.html.markup.*;
    31 import com.sun.tools.doclets.formats.html.markup.*;
    31 import com.sun.tools.doclets.internal.toolkit.*;
    32 import com.sun.tools.doclets.internal.toolkit.*;
    32 import com.sun.tools.doclets.internal.toolkit.util.*;
    33 import com.sun.tools.doclets.internal.toolkit.util.*;
    33 
    34 
    44  * @see java.lang.Character
    45  * @see java.lang.Character
    45  * @author Atul M Dambalkar
    46  * @author Atul M Dambalkar
    46  * @author Bhavesh Patel (Modified)
    47  * @author Bhavesh Patel (Modified)
    47  */
    48  */
    48 public class SingleIndexWriter extends AbstractIndexWriter {
    49 public class SingleIndexWriter extends AbstractIndexWriter {
       
    50 
       
    51     private List<Object> elements;
    49 
    52 
    50     /**
    53     /**
    51      * Construct the SingleIndexWriter with filename "index-all.html" and the
    54      * Construct the SingleIndexWriter with filename "index-all.html" and the
    52      * {@link IndexBuilder}
    55      * {@link IndexBuilder}
    53      *
    56      *
    98         if (configuration.allowTag(HtmlTag.HEADER)) {
   101         if (configuration.allowTag(HtmlTag.HEADER)) {
    99             body.addContent(htmlTree);
   102             body.addContent(htmlTree);
   100         }
   103         }
   101         HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
   104         HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
   102         divTree.addStyle(HtmlStyle.contentContainer);
   105         divTree.addStyle(HtmlStyle.contentContainer);
       
   106         Set<Object> keys = new TreeSet<>(Arrays.asList(indexbuilder.elements()));
       
   107         keys.addAll(configuration.tagSearchIndexKeys);
       
   108         elements = new ArrayList<>(keys);
   103         addLinksForIndexes(divTree);
   109         addLinksForIndexes(divTree);
   104         for (int i = 0; i < indexbuilder.elements().length; i++) {
   110         for (Object ch : elements) {
   105             Character unicode = (Character)((indexbuilder.elements())[i]);
   111             Character unicode = (Character) ch;
   106             addContents(unicode, indexbuilder.getMemberList(unicode), divTree);
   112             if (configuration.tagSearchIndexMap.get(unicode) == null) {
       
   113                 addContents(unicode, indexbuilder.getMemberList(unicode), divTree);
       
   114             } else if (indexbuilder.getMemberList(unicode) == null) {
       
   115                 addSearchContents(unicode, configuration.tagSearchIndexMap.get(unicode), divTree);
       
   116             } else {
       
   117                 addContents(unicode, indexbuilder.getMemberList(unicode),
       
   118                         configuration.tagSearchIndexMap.get(unicode), divTree);
       
   119             }
   107         }
   120         }
   108         addLinksForIndexes(divTree);
   121         addLinksForIndexes(divTree);
   109         body.addContent((configuration.allowTag(HtmlTag.MAIN))
   122         body.addContent((configuration.allowTag(HtmlTag.MAIN))
   110                 ? HtmlTree.MAIN(divTree)
   123                 ? HtmlTree.MAIN(divTree)
   111                 : divTree);
   124                 : divTree);
   115         addNavLinks(false, htmlTree);
   128         addNavLinks(false, htmlTree);
   116         addBottom(htmlTree);
   129         addBottom(htmlTree);
   117         if (configuration.allowTag(HtmlTag.FOOTER)) {
   130         if (configuration.allowTag(HtmlTag.FOOTER)) {
   118             body.addContent(htmlTree);
   131             body.addContent(htmlTree);
   119         }
   132         }
       
   133         createSearchIndexFiles();
   120         printHtmlDocument(null, true, body);
   134         printHtmlDocument(null, true, body);
   121     }
   135     }
   122 
   136 
   123     /**
   137     /**
   124      * Add links for all the Index Files per unicode character.
   138      * Add links for all the Index Files per unicode character.
   125      *
   139      *
   126      * @param contentTree the content tree to which the links for indexes will be added
   140      * @param contentTree the content tree to which the links for indexes will be added
   127      */
   141      */
   128     protected void addLinksForIndexes(Content contentTree) {
   142     protected void addLinksForIndexes(Content contentTree) {
   129         for (int i = 0; i < indexbuilder.elements().length; i++) {
   143         for (Object ch : elements) {
   130             String unicode = (indexbuilder.elements())[i].toString();
   144             String unicode = ch.toString();
   131             contentTree.addContent(
   145             contentTree.addContent(
   132                     getHyperLink(getNameForIndex(unicode),
   146                     getHyperLink(getNameForIndex(unicode),
   133                     new StringContent(unicode)));
   147                             new StringContent(unicode)));
   134             contentTree.addContent(getSpace());
   148             contentTree.addContent(getSpace());
   135         }
   149         }
   136     }
   150     }
   137 }
   151 }