< prev index next >

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

Print this page

        

*** 59,156 **** */ public static DocPath create(String p) { return (p == null) || p.isEmpty() ? empty : new DocPath(p); } - /** - * Returns the path for a class. - * For example, if the class is java.lang.Object, - * the path is java/lang/Object.html. - * @param utils utility class for handling type elements - * @param typeElement the type element - * @return the path - */ - public static DocPath forClass(Utils utils, TypeElement typeElement) { - return (typeElement == null) - ? empty - : forPackage(utils.containingPackage(typeElement)).resolve(forName(utils, typeElement)); - } - - /** - * Returns the path for the simple name of a class. - * For example, if the class is java.lang.Object, - * the path is Object.html. - * @param utils utility class for handling type elements - * @param typeElement the type element - * @return the path - */ - public static DocPath forName(Utils utils, TypeElement typeElement) { - return (typeElement == null) ? empty : new DocPath(utils.getSimpleName(typeElement) + ".html"); - } - - /** - * Returns the path for the name of a module. - * For example, if the module is java.base, - * the path is java.base. - * @param mdle the module element - * @return the path - */ - public static DocPath forModule(ModuleElement mdle) { - return mdle == null || mdle.isUnnamed() - ? empty - : DocPath.create(mdle.getQualifiedName().toString()); - } - - /** - * Returns the path for the package of a class. - * For example, if the class is java.lang.Object, - * the path is java/lang. - * @param utils utility class for handling type elements - * @param typeElement the type element - * @return the path - */ - public static DocPath forPackage(Utils utils, TypeElement typeElement) { - return (typeElement == null) ? empty : forPackage(utils.containingPackage(typeElement)); - } - - /** - * Returns the path for a package. - * For example, if the package is java.lang, - * the path is java/lang. - * @param pkgElement the package element - * @return the path - */ - public static DocPath forPackage(PackageElement pkgElement) { - return pkgElement == null || pkgElement.isUnnamed() - ? empty - : DocPath.create(pkgElement.getQualifiedName().toString().replace('.', '/')); - } - - /** - * Returns the inverse path for a package. - * For example, if the package is java.lang, - * the inverse path is ../... - * @param pkgElement the package element - * @return the path - */ - public static DocPath forRoot(PackageElement pkgElement) { - String name = (pkgElement == null || pkgElement.isUnnamed()) - ? "" - : pkgElement.getQualifiedName().toString(); - return new DocPath(name.replace('.', '/').replaceAll("[^/]+", "..")); - } - - /** - * Returns the relative path from one package to another. - * @param from the initial package - * @param to the target package - * @return the path - */ - public static DocPath relativePath(PackageElement from, PackageElement to) { - return forRoot(from).resolve(forPackage(to)); - } - protected DocPath(String p) { path = (p.endsWith("/") ? p.substring(0, p.length() - 1) : p); } /** {@inheritDoc} */ --- 59,68 ----
< prev index next >