< prev index next >

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

Print this page

        

*** 424,471 **** /** * @throws DocFileIOException if there is a problem creating any of the search index files */ protected void createSearchIndexFiles() throws DocFileIOException { if (configuration.showModules) { ! createSearchIndexFile(DocPaths.MODULE_SEARCH_INDEX_JSON, DocPaths.MODULE_SEARCH_INDEX_ZIP, ! DocPaths.MODULE_SEARCH_INDEX_JS, configuration.moduleSearchIndex, "moduleSearchIndex"); } if (!configuration.packages.isEmpty()) { SearchIndexItem si = new SearchIndexItem(); si.setCategory(SearchIndexItem.Category.PACKAGES); si.setLabel(resources.getText("doclet.All_Packages")); si.setUrl(DocPaths.ALLPACKAGES_INDEX.getPath()); configuration.packageSearchIndex.add(si); } ! createSearchIndexFile(DocPaths.PACKAGE_SEARCH_INDEX_JSON, DocPaths.PACKAGE_SEARCH_INDEX_ZIP, ! DocPaths.PACKAGE_SEARCH_INDEX_JS, configuration.packageSearchIndex, "packageSearchIndex"); SearchIndexItem si = new SearchIndexItem(); si.setCategory(SearchIndexItem.Category.TYPES); si.setLabel(resources.getText("doclet.All_Classes")); si.setUrl(DocPaths.ALLCLASSES_INDEX.getPath()); configuration.typeSearchIndex.add(si); ! createSearchIndexFile(DocPaths.TYPE_SEARCH_INDEX_JSON, DocPaths.TYPE_SEARCH_INDEX_ZIP, ! DocPaths.TYPE_SEARCH_INDEX_JS, configuration.typeSearchIndex, "typeSearchIndex"); ! createSearchIndexFile(DocPaths.MEMBER_SEARCH_INDEX_JSON, DocPaths.MEMBER_SEARCH_INDEX_ZIP, ! DocPaths.MEMBER_SEARCH_INDEX_JS, configuration.memberSearchIndex, "memberSearchIndex"); ! createSearchIndexFile(DocPaths.TAG_SEARCH_INDEX_JSON, DocPaths.TAG_SEARCH_INDEX_ZIP, ! DocPaths.TAG_SEARCH_INDEX_JS, configuration.tagSearchIndex, "tagSearchIndex"); } /** * Creates a search index file. * - * @param searchIndexFile the file to be generated - * @param searchIndexZip the zip file to be generated * @param searchIndexJS the file for the JavaScript to be generated * @param searchIndex the search index items * @param varName the variable name to write in the JavaScript file * @throws DocFileIOException if there is a problem creating the search index file */ ! protected void createSearchIndexFile(DocPath searchIndexFile, DocPath searchIndexZip, ! DocPath searchIndexJS, Collection<SearchIndexItem> searchIndex, String varName) throws DocFileIOException { ! if (!searchIndex.isEmpty()) { StringBuilder searchVar = new StringBuilder("["); boolean first = true; for (SearchIndexItem item : searchIndex) { if (first) { searchVar.append(item.toString()); --- 424,477 ---- /** * @throws DocFileIOException if there is a problem creating any of the search index files */ protected void createSearchIndexFiles() throws DocFileIOException { if (configuration.showModules) { ! createSearchIndexFile(DocPaths.MODULE_SEARCH_INDEX_JS, ! configuration.moduleSearchIndex, ! "moduleSearchIndex"); } if (!configuration.packages.isEmpty()) { SearchIndexItem si = new SearchIndexItem(); si.setCategory(SearchIndexItem.Category.PACKAGES); si.setLabel(resources.getText("doclet.All_Packages")); si.setUrl(DocPaths.ALLPACKAGES_INDEX.getPath()); configuration.packageSearchIndex.add(si); } ! createSearchIndexFile(DocPaths.PACKAGE_SEARCH_INDEX_JS, ! configuration.packageSearchIndex, ! "packageSearchIndex"); SearchIndexItem si = new SearchIndexItem(); si.setCategory(SearchIndexItem.Category.TYPES); si.setLabel(resources.getText("doclet.All_Classes")); si.setUrl(DocPaths.ALLCLASSES_INDEX.getPath()); configuration.typeSearchIndex.add(si); ! createSearchIndexFile(DocPaths.TYPE_SEARCH_INDEX_JS, ! configuration.typeSearchIndex, ! "typeSearchIndex"); ! createSearchIndexFile(DocPaths.MEMBER_SEARCH_INDEX_JS, ! configuration.memberSearchIndex, ! "memberSearchIndex"); ! createSearchIndexFile(DocPaths.TAG_SEARCH_INDEX_JS, ! configuration.tagSearchIndex, ! "tagSearchIndex"); } /** * Creates a search index file. * * @param searchIndexJS the file for the JavaScript to be generated * @param searchIndex the search index items * @param varName the variable name to write in the JavaScript file * @throws DocFileIOException if there is a problem creating the search index file */ ! protected void createSearchIndexFile(DocPath searchIndexJS, ! Collection<SearchIndexItem> searchIndex, ! String varName) ! throws DocFileIOException ! { ! if (!searchIndex.isEmpty()) { // TODO: write to disk straight StringBuilder searchVar = new StringBuilder("["); boolean first = true; for (SearchIndexItem item : searchIndex) { if (first) { searchVar.append(item.toString());
*** 481,502 **** wr.write(" = "); wr.write(searchVar.toString()); } catch (IOException ie) { throw new DocFileIOException(jsFile, DocFileIOException.Mode.WRITE, ie); } - - DocFile zipFile = DocFile.createFileForOutput(configuration, searchIndexZip); - try (OutputStream fos = zipFile.openOutputStream(); - ZipOutputStream zos = new ZipOutputStream(fos)) { - try { - ZipEntry ze = new ZipEntry(searchIndexFile.getPath()); - zos.putNextEntry(ze); - zos.write(searchVar.toString().getBytes()); - } finally { - zos.closeEntry(); - } - } catch (IOException ie) { - throw new DocFileIOException(zipFile, DocFileIOException.Mode.WRITE, ie); - } } } } --- 487,494 ----
< prev index next >