src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.doclets.formats.html;
  27 
  28 import java.io.*;
  29 import java.util.*;
  30 
  31 import com.sun.tools.doclets.formats.html.markup.*;
  32 import com.sun.tools.doclets.internal.toolkit.*;
  33 import com.sun.tools.doclets.internal.toolkit.util.*;






  34 

  35 /**
  36  * Generate only one index file for all the Member Names with Indexing in
  37  * Unicode Order. The name of the generated file is "index-all.html" and it is
  38  * generated in current or the destination directory.
  39  *
  40  *  <p><b>This is NOT part of any supported API.
  41  *  If you write code that depends on this, you do so at your own risk.
  42  *  This code and its internal interfaces are subject to change or
  43  *  deletion without notice.</b>
  44  *
  45  * @see java.lang.Character
  46  * @author Atul M Dambalkar
  47  * @author Bhavesh Patel (Modified)
  48  */
  49 public class SingleIndexWriter extends AbstractIndexWriter {
  50 
  51     private List<Object> elements;
  52 
  53     /**
  54      * Construct the SingleIndexWriter with filename "index-all.html" and the
  55      * {@link IndexBuilder}
  56      *
  57      * @param filename     Name of the index file to be generated.
  58      * @param indexbuilder Unicode based Index from {@link IndexBuilder}
  59      */
  60     public SingleIndexWriter(ConfigurationImpl configuration,
  61                              DocPath filename,
  62                              IndexBuilder indexbuilder) throws IOException {
  63         super(configuration, filename, indexbuilder);
  64     }
  65 
  66     /**
  67      * Generate single index file, for all Unicode characters.
  68      *
  69      * @param indexbuilder IndexBuilder built by {@link IndexBuilder}
  70      * @throws DocletAbortException
  71      */


  86         }
  87     }
  88 
  89     /**
  90      * Generate the contents of each index file, with Header, Footer,
  91      * Member Field, Method and Constructor Description.
  92      */
  93     protected void generateIndexFile() throws IOException {
  94         String title = configuration.getText("doclet.Window_Single_Index");
  95         HtmlTree body = getBody(true, getWindowTitle(title));
  96         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
  97                 ? HtmlTree.HEADER()
  98                 : body;
  99         addTop(htmlTree);
 100         addNavLinks(true, htmlTree);
 101         if (configuration.allowTag(HtmlTag.HEADER)) {
 102             body.addContent(htmlTree);
 103         }
 104         HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
 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);
 109         addLinksForIndexes(divTree);
 110         for (Object ch : elements) {
 111             Character unicode = (Character) ch;
 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             }
 120         }
 121         addLinksForIndexes(divTree);
 122         body.addContent((configuration.allowTag(HtmlTag.MAIN))
 123                 ? HtmlTree.MAIN(divTree)
 124                 : divTree);
 125         if (configuration.allowTag(HtmlTag.FOOTER)) {
 126             htmlTree = HtmlTree.FOOTER();
 127         }
 128         addNavLinks(false, htmlTree);
 129         addBottom(htmlTree);
 130         if (configuration.allowTag(HtmlTag.FOOTER)) {
 131             body.addContent(htmlTree);


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.javadoc.internal.doclets.formats.html;
  27 
  28 import java.io.*;
  29 import java.util.*;
  30 
  31 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
  32 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
  33 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
  34 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
  35 import jdk.javadoc.internal.doclets.toolkit.Content;
  36 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
  37 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
  38 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
  39 import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
  40 
  41 
  42 /**
  43  * Generate only one index file for all the Member Names with Indexing in
  44  * Unicode Order. The name of the generated file is "index-all.html" and it is
  45  * generated in current or the destination directory.
  46  *
  47  *  <p><b>This is NOT part of any supported API.
  48  *  If you write code that depends on this, you do so at your own risk.
  49  *  This code and its internal interfaces are subject to change or
  50  *  deletion without notice.</b>
  51  *
  52  * @see java.lang.Character
  53  * @author Atul M Dambalkar
  54  * @author Bhavesh Patel (Modified)
  55  */
  56 public class SingleIndexWriter extends AbstractIndexWriter {
  57 
  58     private Set<Character> elements;
  59 
  60     /**
  61      * Construct the SingleIndexWriter with filename "index-all.html" and the
  62      * {@link IndexBuilder}
  63      *
  64      * @param filename     Name of the index file to be generated.
  65      * @param indexbuilder Unicode based Index from {@link IndexBuilder}
  66      */
  67     public SingleIndexWriter(ConfigurationImpl configuration,
  68                              DocPath filename,
  69                              IndexBuilder indexbuilder) throws IOException {
  70         super(configuration, filename, indexbuilder);
  71     }
  72 
  73     /**
  74      * Generate single index file, for all Unicode characters.
  75      *
  76      * @param indexbuilder IndexBuilder built by {@link IndexBuilder}
  77      * @throws DocletAbortException
  78      */


  93         }
  94     }
  95 
  96     /**
  97      * Generate the contents of each index file, with Header, Footer,
  98      * Member Field, Method and Constructor Description.
  99      */
 100     protected void generateIndexFile() throws IOException {
 101         String title = configuration.getText("doclet.Window_Single_Index");
 102         HtmlTree body = getBody(true, getWindowTitle(title));
 103         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
 104                 ? HtmlTree.HEADER()
 105                 : body;
 106         addTop(htmlTree);
 107         addNavLinks(true, htmlTree);
 108         if (configuration.allowTag(HtmlTag.HEADER)) {
 109             body.addContent(htmlTree);
 110         }
 111         HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
 112         divTree.addStyle(HtmlStyle.contentContainer);
 113         elements = new TreeSet<>(indexbuilder.getIndexMap().keySet());
 114         elements.addAll(configuration.tagSearchIndexKeys);

 115         addLinksForIndexes(divTree);
 116         for (Character unicode : elements) {

 117             if (configuration.tagSearchIndexMap.get(unicode) == null) {
 118                 addContents(unicode, indexbuilder.getMemberList(unicode), divTree);
 119             } else if (indexbuilder.getMemberList(unicode) == null) {
 120                 addSearchContents(unicode, configuration.tagSearchIndexMap.get(unicode), divTree);
 121             } else {
 122                 addContents(unicode, indexbuilder.getMemberList(unicode),
 123                         configuration.tagSearchIndexMap.get(unicode), divTree);
 124             }
 125         }
 126         addLinksForIndexes(divTree);
 127         body.addContent((configuration.allowTag(HtmlTag.MAIN))
 128                 ? HtmlTree.MAIN(divTree)
 129                 : divTree);
 130         if (configuration.allowTag(HtmlTag.FOOTER)) {
 131             htmlTree = HtmlTree.FOOTER();
 132         }
 133         addNavLinks(false, htmlTree);
 134         addBottom(htmlTree);
 135         if (configuration.allowTag(HtmlTag.FOOTER)) {
 136             body.addContent(htmlTree);