Class JavadocLinkGenerator
- java.lang.Object
-
- org.apache.maven.tools.plugin.javadoc.JavadocLinkGenerator
-
public class JavadocLinkGenerator extends java.lang.Object
Generates links for elements (packages, classes, fields, constructors, methods) in external and/or an internal (potentially not yet existing) javadoc site. The external site must be accessible for it to be considered due to the different fragment formats.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JavadocLinkGenerator.JavadocToolVersionRange
Javadoc tool version ranges whose generated sites expose different link formats.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<JavadocSite>
externalJavadocSites
private JavadocSite
internalJavadocSite
private static org.slf4j.Logger
LOG
-
Constructor Summary
Constructors Constructor Description JavadocLinkGenerator(java.net.URI internalJavadocSiteUrl, java.lang.String internalJavadocVersion)
Constructor for an offline internal site only.JavadocLinkGenerator(java.net.URI internalJavadocSiteUrl, java.lang.String internalJavadocVersion, java.util.List<java.net.URI> externalJavadocSiteUrls, org.apache.maven.settings.Settings settings)
Constructor for both an internal (offline) and external (online) sites.JavadocLinkGenerator(java.util.List<java.net.URI> externalJavadocSiteUrls, org.apache.maven.settings.Settings settings)
Constructor for online external sites only.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.URI
createLink(java.lang.String binaryName)
Generates a (deep-)link to a HTML page in any of the sites given to the constructor.java.net.URI
createLink(FullyQualifiedJavadocReference javadocReference)
Generates a (deep-)link to a HTML page in any of the sites given to the constructor.java.net.URI
getInternalJavadocSiteBaseUrl()
static boolean
isLinkValid(java.net.URI url, java.nio.file.Path baseDirectory)
Checks if a given link is valid.
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
externalJavadocSites
private final java.util.List<JavadocSite> externalJavadocSites
-
internalJavadocSite
private final JavadocSite internalJavadocSite
-
-
Constructor Detail
-
JavadocLinkGenerator
public JavadocLinkGenerator(java.net.URI internalJavadocSiteUrl, java.lang.String internalJavadocVersion)
Constructor for an offline internal site only.- Parameters:
internalJavadocSiteUrl
- the url of the javadoc generated websiteinternalJavadocVersion
- the version of javadoc with which the internal site frominternalJavadocSiteUrl
has been generated
-
JavadocLinkGenerator
public JavadocLinkGenerator(java.util.List<java.net.URI> externalJavadocSiteUrls, org.apache.maven.settings.Settings settings)
Constructor for online external sites only.- Parameters:
externalJavadocSiteUrls
-settings
-
-
JavadocLinkGenerator
public JavadocLinkGenerator(java.net.URI internalJavadocSiteUrl, java.lang.String internalJavadocVersion, java.util.List<java.net.URI> externalJavadocSiteUrls, org.apache.maven.settings.Settings settings)
Constructor for both an internal (offline) and external (online) sites.- Parameters:
internalJavadocSiteUrl
-internalJavadocVersion
-externalJavadocSiteUrls
-settings
-
-
-
Method Detail
-
createLink
public java.net.URI createLink(FullyQualifiedJavadocReference javadocReference)
Generates a (deep-)link to a HTML page in any of the sites given to the constructor. The link is not validated (i.e. might point to a non-existing page). Only uses the offline site for references returningfalse
forFullyQualifiedJavadocReference.isExternal()
.- Parameters:
javadocReference
-- Returns:
- the (deep-) link towards a javadoc page
- Throws:
java.lang.IllegalArgumentException
- in case no javadoc link could be generated for the given referencejava.lang.IllegalStateException
- in case no javadoc source sites have been configured
-
createLink
public java.net.URI createLink(java.lang.String binaryName)
Generates a (deep-)link to a HTML page in any of the sites given to the constructor. The link is not validated (i.e. might point to a non-existing page). Preferably resolves from the online sites if they provide the given package.- Parameters:
binaryName
- a binary name according to JLS 13.1- Returns:
- the (deep-) link towards a javadoc page
- Throws:
java.lang.IllegalArgumentException
- in case no javadoc link could be generated for the given name
-
getInternalJavadocSiteBaseUrl
public java.net.URI getInternalJavadocSiteBaseUrl()
-
isLinkValid
public static boolean isLinkValid(java.net.URI url, java.nio.file.Path baseDirectory)
Checks if a given link is valid. For absolute links uses the underlingHttpURLConnection
, otherwise checks for existence of the file on the filesystem.- Parameters:
url
- the url to checkbaseDirectory
- the base directory to which relative file URLs refer- Returns:
true
in case the given link is valid otherwisefalse
-
-