< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java

Print this page




   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.toolkit.util;
  27 
  28 import javax.lang.model.element.ModuleElement;


  29 
  30 /**
  31  * Standard DocPath objects.
  32  *
  33  *  <p><b>This is NOT part of any supported API.
  34  *  If you write code that depends on this, you do so at your own risk.
  35  *  This code and its internal interfaces are subject to change or
  36  *  deletion without notice.</b>
  37  *
  38  */
  39 public class DocPaths {










  40     /** The name of the file for all classes, without using frames, when --no-frames is specified. */
  41     public static final DocPath ALLCLASSES = DocPath.create("allclasses.html");
  42 
  43     /** The name of the file for all classes, using frames. */
  44     public static final DocPath ALLCLASSES_FRAME = DocPath.create("allclasses-frame.html");
  45 
  46     /** The name of the file for all classes, without using frames. */
  47     public static final DocPath ALLCLASSES_NOFRAME = DocPath.create("allclasses-noframe.html");
  48 
  49     public static DocPath AllClasses(boolean frames) {
  50         return frames ? ALLCLASSES_NOFRAME : ALLCLASSES;
  51     }
  52 
  53     /** The name of the sub-directory for storing class usage info. */
  54     public static final DocPath CLASS_USE = DocPath.create("class-use");
  55 
  56     /** The name of the file for constant values. */
  57     public static final DocPath CONSTANT_VALUES = DocPath.create("constant-values.html");
  58 
  59     /** The name of the fie for deprecated elements. */


  63     public static final DocPath DOC_FILES = DocPath.create("doc-files");
  64 
  65     /** The name of the file for the element list. */
  66     public static final DocPath ELEMENT_LIST = DocPath.create("element-list");
  67 
  68     /** The name of the image file showing a magnifying glass on the search box. */
  69     public static final DocPath GLASS_IMG = DocPath.create("glass.png");
  70 
  71     /** The name of the file for help info. */
  72     public static final DocPath HELP_DOC = DocPath.create("help-doc.html");
  73 
  74     /** The name of the main index file. */
  75     public static final DocPath INDEX = DocPath.create("index.html");
  76 
  77     /** The name of the single index file for all classes. */
  78     public static final DocPath INDEX_ALL = DocPath.create("index-all.html");
  79 
  80     /** The name of the directory for the split index files. */
  81     public static final DocPath INDEX_FILES = DocPath.create("index-files");
  82 
  83     /** Generate the name of one of the files in the split index. */




  84     public static DocPath indexN(int n) {
  85         return DocPath.create("index-" + n + ".html");
  86     }
  87 
  88     /** The name of the default javascript file. */
  89     public static final DocPath JAVASCRIPT = DocPath.create("script.js");
  90 
  91     /** The name of the directory for the jQuery. */
  92     public static final DocPath JQUERY_FILES = DocPath.create("jquery");
  93 
  94     /** The name of the default jQuery stylesheet file. */
  95     public static final DocPath JQUERY_STYLESHEET_FILE = DocPath.create("jquery-ui.css");
  96 
  97     /** The name of the default jQuery javascript file. */
  98     public static final DocPath JQUERY_JS_1_10 = DocPath.create("jquery-1.10.2.js");
  99 
 100     /** The name of the default jQuery javascript file. */
 101     public static final DocPath JQUERY_JS = DocPath.create("jquery-ui.js");
 102 
 103     /** The name of the default jszip javascript file. */


 156     public static final DocPath PACKAGE_LIST = DocPath.create("package-list");
 157 
 158     /** The name of the package search index file. */
 159     public static final DocPath PACKAGE_SEARCH_INDEX_JSON = DocPath.create("package-search-index.json");
 160 
 161     /** The name of the package search index zip file. */
 162     public static final DocPath PACKAGE_SEARCH_INDEX_ZIP = DocPath.create("package-search-index.zip");
 163 
 164     /** The name of the package search index js file. */
 165     public static final DocPath PACKAGE_SEARCH_INDEX_JS = DocPath.create("package-search-index.js");
 166 
 167     /** The name of the file for the package summary. */
 168     public static final DocPath PACKAGE_SUMMARY = DocPath.create("package-summary.html");
 169 
 170     /** The name of the file for the package tree. */
 171     public static final DocPath PACKAGE_TREE = DocPath.create("package-tree.html");
 172 
 173     /** The name of the file for the package usage info. */
 174     public static final DocPath PACKAGE_USE = DocPath.create("package-use.html");
 175 
 176     /** The name of the output directory for module documentation files. */
 177     public static DocPath moduleDocFiles(ModuleElement mdle) {
 178         return DocPath.create(mdle.getQualifiedName() + "-doc-files");









 179     }
 180 
 181     /** The name of the file for the module frame. */
 182     public static DocPath moduleFrame(ModuleElement mdle) {
 183         return DocPath.create(mdle.getQualifiedName() + "-frame.html");















 184     }
 185 
 186     /** The name of the file for the module summary. */
 187     public static DocPath moduleSummary(ModuleElement mdle) {
 188         return DocPaths.moduleSummary(mdle.getQualifiedName().toString());




































































































 189     }
 190 
 191     /** The name of the file for the module summary. */
 192     public static DocPath moduleSummary(String mdleName) {
 193         return DocPath.create(mdleName + "-summary.html");
 194     }
 195 
 196     /** The name of the file for the module frame. */
 197     public static DocPath moduleTypeFrame(ModuleElement mdle) {
 198         return DocPath.create(mdle.getQualifiedName() + "-type-frame.html");
 199     }
 200 
 201     /** The name of the file for the module overview frame. */
 202     public static final DocPath MODULE_OVERVIEW_FRAME = DocPath.create("module-overview-frame.html");
 203 
 204     /** The name of the sub-package from which resources are read. */
 205     public static final DocPath RESOURCES = DocPath.create("resources");
 206 
 207     /** The name of the search javascript file. */
 208     public static final DocPath SEARCH_JS = DocPath.create("search.js");
 209 
 210     /** The name of the file for the serialized form info. */
 211     public static final DocPath SERIALIZED_FORM = DocPath.create("serialized-form.html");
 212 
 213     /** The name of the directory in which HTML versions of the source code
 214      *  are generated.
 215      */
 216     public static final DocPath SOURCE_OUTPUT = DocPath.create("src-html");
 217 
 218     /** The name of the default stylesheet. */




   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.toolkit.util;
  27 
  28 import javax.lang.model.element.ModuleElement;
  29 import javax.lang.model.element.PackageElement;
  30 import javax.lang.model.element.TypeElement;
  31 
  32 /**
  33  * Standard DocPath objects.
  34  *
  35  *  <p><b>This is NOT part of any supported API.
  36  *  If you write code that depends on this, you do so at your own risk.
  37  *  This code and its internal interfaces are subject to change or
  38  *  deletion without notice.</b>
  39  *
  40  */
  41 public class DocPaths {
  42     private final boolean useModuleDirectories;
  43     private final String moduleSeparator;
  44     private final Utils utils;
  45 
  46     public DocPaths(Utils utils, boolean useModuleDirectories) {
  47         this.utils = utils;
  48         this.useModuleDirectories = useModuleDirectories;
  49         moduleSeparator = useModuleDirectories ? "/module-" : "-";
  50     }
  51 
  52     /** The name of the file for all classes, without using frames, when --no-frames is specified. */
  53     public static final DocPath ALLCLASSES = DocPath.create("allclasses.html");
  54 
  55     /** The name of the file for all classes, using frames. */
  56     public static final DocPath ALLCLASSES_FRAME = DocPath.create("allclasses-frame.html");
  57 
  58     /** The name of the file for all classes, without using frames. */
  59     public static final DocPath ALLCLASSES_NOFRAME = DocPath.create("allclasses-noframe.html");
  60 
  61     public static DocPath AllClasses(boolean frames) {
  62         return frames ? ALLCLASSES_NOFRAME : ALLCLASSES;
  63     }
  64 
  65     /** The name of the sub-directory for storing class usage info. */
  66     public static final DocPath CLASS_USE = DocPath.create("class-use");
  67 
  68     /** The name of the file for constant values. */
  69     public static final DocPath CONSTANT_VALUES = DocPath.create("constant-values.html");
  70 
  71     /** The name of the fie for deprecated elements. */


  75     public static final DocPath DOC_FILES = DocPath.create("doc-files");
  76 
  77     /** The name of the file for the element list. */
  78     public static final DocPath ELEMENT_LIST = DocPath.create("element-list");
  79 
  80     /** The name of the image file showing a magnifying glass on the search box. */
  81     public static final DocPath GLASS_IMG = DocPath.create("glass.png");
  82 
  83     /** The name of the file for help info. */
  84     public static final DocPath HELP_DOC = DocPath.create("help-doc.html");
  85 
  86     /** The name of the main index file. */
  87     public static final DocPath INDEX = DocPath.create("index.html");
  88 
  89     /** The name of the single index file for all classes. */
  90     public static final DocPath INDEX_ALL = DocPath.create("index-all.html");
  91 
  92     /** The name of the directory for the split index files. */
  93     public static final DocPath INDEX_FILES = DocPath.create("index-files");
  94 
  95     /**
  96      * Generate the name of one of the files in the split index.
  97      * @param n the position in the index
  98      * @return the path
  99      */
 100     public static DocPath indexN(int n) {
 101         return DocPath.create("index-" + n + ".html");
 102     }
 103 
 104     /** The name of the default javascript file. */
 105     public static final DocPath JAVASCRIPT = DocPath.create("script.js");
 106 
 107     /** The name of the directory for the jQuery. */
 108     public static final DocPath JQUERY_FILES = DocPath.create("jquery");
 109 
 110     /** The name of the default jQuery stylesheet file. */
 111     public static final DocPath JQUERY_STYLESHEET_FILE = DocPath.create("jquery-ui.css");
 112 
 113     /** The name of the default jQuery javascript file. */
 114     public static final DocPath JQUERY_JS_1_10 = DocPath.create("jquery-1.10.2.js");
 115 
 116     /** The name of the default jQuery javascript file. */
 117     public static final DocPath JQUERY_JS = DocPath.create("jquery-ui.js");
 118 
 119     /** The name of the default jszip javascript file. */


 172     public static final DocPath PACKAGE_LIST = DocPath.create("package-list");
 173 
 174     /** The name of the package search index file. */
 175     public static final DocPath PACKAGE_SEARCH_INDEX_JSON = DocPath.create("package-search-index.json");
 176 
 177     /** The name of the package search index zip file. */
 178     public static final DocPath PACKAGE_SEARCH_INDEX_ZIP = DocPath.create("package-search-index.zip");
 179 
 180     /** The name of the package search index js file. */
 181     public static final DocPath PACKAGE_SEARCH_INDEX_JS = DocPath.create("package-search-index.js");
 182 
 183     /** The name of the file for the package summary. */
 184     public static final DocPath PACKAGE_SUMMARY = DocPath.create("package-summary.html");
 185 
 186     /** The name of the file for the package tree. */
 187     public static final DocPath PACKAGE_TREE = DocPath.create("package-tree.html");
 188 
 189     /** The name of the file for the package usage info. */
 190     public static final DocPath PACKAGE_USE = DocPath.create("package-use.html");
 191 
 192     /**
 193      * Returns the path for a type element.
 194      * For example, if the type element is {@code java.lang.Object},
 195      * the path is {@code java/lang/Object.html}.
 196      *
 197      * @param typeElement the type element
 198      * @return the path
 199      */
 200     public DocPath forClass(TypeElement typeElement) {
 201         return (typeElement == null)
 202                 ? DocPath.empty
 203                 : forPackage(utils.containingPackage(typeElement)).resolve(forName(typeElement));
 204     }
 205 
 206     /**
 207      * Returns the path for the simple name of a type element.
 208      * For example, if the type element is {@code java.lang.Object},
 209      * the path is {@code Object.html}.
 210      *
 211      * @param typeElement the type element
 212      * @return the path
 213      */
 214     public DocPath forName(TypeElement typeElement) {
 215         return (typeElement == null) 
 216                 ? DocPath.empty
 217                 : new DocPath(utils.getSimpleName(typeElement) + ".html");
 218     }
 219 
 220     public static DocPath forModule(ModuleElement mdle) {
 221         return mdle == null || mdle.isUnnamed()
 222                 ? DocPath.empty
 223                 : DocPath.create(mdle.getQualifiedName().toString());
 224     }
 225 
 226     /**
 227      * Returns the path for the package of a type element.
 228      * For example, if the type element is {@code java.lang.Object},
 229      * the path is {@code java/lang}.
 230      *
 231      * @param typeElement the type element
 232      * @return the path
 233      */
 234     public DocPath forPackage(TypeElement typeElement) {
 235         return (typeElement == null) ? DocPath.empty : forPackage(utils.containingPackage(typeElement));
 236     }
 237 
 238     /**
 239      * Returns the path for a package.
 240      * For example, if the package is {@code java.lang},
 241      * the path is {@code java/lang}.
 242      *
 243      * @param pkgElement the package element
 244      * @return the path
 245      */
 246     public DocPath forPackage(PackageElement pkgElement) {
 247         if (pkgElement == null || pkgElement.isUnnamed()) {
 248             return DocPath.empty;
 249         }
 250 
 251         DocPath pkgPath = DocPath.create(pkgElement.getQualifiedName().toString().replace('.', '/'));
 252         if (useModuleDirectories) {
 253             ModuleElement mdle = (ModuleElement) pkgElement.getEnclosingElement();
 254             return forModule(mdle).resolve(pkgPath);
 255         } else {
 256             return pkgPath;
 257         }
 258     }
 259 
 260     /**
 261      * Returns the inverse path for a package.
 262      * For example, if the package is {@code java.lang},
 263      * the inverse path is {@code ../..}.
 264      *
 265      * @param pkgElement the package element
 266      * @return the path
 267      */
 268     public static DocPath forRoot(PackageElement pkgElement) {
 269         String name = (pkgElement == null || pkgElement.isUnnamed())
 270                 ? ""
 271                 : pkgElement.getQualifiedName().toString();
 272         return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
 273     }
 274 
 275     /**
 276      * Returns a relative path from one package to another.
 277      *
 278      * @param from the origin of the relative path
 279      * @param to the destination of the relative path
 280      * @return the path
 281      */
 282     public DocPath relativePath(PackageElement from, PackageElement to) {
 283         return forRoot(from).resolve(forPackage(to));
 284     }
 285 
 286     /** 
 287      * The path for the output directory for module documentation files.
 288      * @param mdle the module
 289      * @return the path
 290      */
 291     public DocPath moduleDocFiles(ModuleElement mdle) {
 292         return createModulePath(mdle, "doc-files");
 293     }
 294 
 295     /** 
 296      * The path for the file for a module's frame page.
 297      * @param mdle the module
 298      * @return the path
 299      */
 300     public DocPath moduleFrame(ModuleElement mdle) {
 301         return createModulePath(mdle, "frame.html");
 302     }
 303 
 304     /** 
 305      * The path for the file for a module's summary page.
 306      * @param mdle the module
 307      * @return the path
 308      */
 309     public DocPath moduleSummary(ModuleElement mdle) {
 310         return createModulePath(mdle, "summary.html");
 311     }
 312 
 313     /**
 314      * The path for the file for a module's summary page.
 315      * @param mdleName the module
 316      * @return the path
 317      */
 318     public DocPath moduleSummary(String mdleName) {
 319         return createModulePath(mdleName, "summary.html");
 320     }
 321 
 322     /**
 323      * The path for the file for a module's type frame page.
 324      * @param mdle the module
 325      * @return the path
 326      */
 327     public DocPath moduleTypeFrame(ModuleElement mdle) {
 328         return createModulePath(mdle, "type-frame.html");
 329     }
 330 
 331     private DocPath createModulePath(ModuleElement mdle, String path) {
 332         return DocPath.create(mdle.getQualifiedName() + moduleSeparator + path);

 333     }
 334 
 335     private DocPath createModulePath(String moduleName, String path) {
 336         return DocPath.create(moduleName + moduleSeparator + path);

 337     }
 338 
 339     /** The name of the file for the module overview frame. */
 340     public static final DocPath MODULE_OVERVIEW_FRAME = DocPath.create("module-overview-frame.html");
 341 
 342     /** The name of the sub-package from which resources are read. */
 343     public static final DocPath RESOURCES = DocPath.create("resources");
 344 
 345     /** The name of the search javascript file. */
 346     public static final DocPath SEARCH_JS = DocPath.create("search.js");
 347 
 348     /** The name of the file for the serialized form info. */
 349     public static final DocPath SERIALIZED_FORM = DocPath.create("serialized-form.html");
 350 
 351     /** The name of the directory in which HTML versions of the source code
 352      *  are generated.
 353      */
 354     public static final DocPath SOURCE_OUTPUT = DocPath.create("src-html");
 355 
 356     /** The name of the default stylesheet. */


< prev index next >