Top Description Inners Fields Constructors Methods
jdk.javadoc.internal.doclets.toolkit.util

public Class Extern

extends Object
Class Inheritance
Imports
java.io.BufferedReader, .IOException, .InputStream, .InputStreamReader, java.net.HttpURLConnection, .MalformedURLException, .URISyntaxException, .URL, .URLConnection, java.util.HashMap, .Map, .Properties, .TreeMap, javax.lang.model.SourceVersion, javax.lang.model.element.Element, .ModuleElement, .PackageElement, javax.tools.Diagnostic, .Diagnostic.Kind, .DocumentationTool, jdk.javadoc.doclet.Reporter, jdk.javadoc.internal.doclets.toolkit.AbstractDoclet, .BaseConfiguration, .Resources

Process and manage "-link" and "-linkoffline" to external packages. The options "-link" and "-linkoffline" both depend on the fact that Javadoc now generates "package-list"(lists all the packages which are getting documented) file in the current or the destination directory, while generating the documentation.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
Extern.Item

Stores the info for one external doc set

Field Summary

Modifier and TypeField and Description
private final BaseConfiguration
configuration

The global configuration information for this run.

private boolean
linkoffline

True if we are using -linkoffline and false if -link is used instead.

private Map<String, Extern.Item>
moduleItems

Map element names onto Extern Item objects.

private Map<String, Map<String, Extern.Item>>
private final Resources
private final Utils

Constructor Summary

AccessConstructor and Description
public
Extern(BaseConfiguration configuration)

Method Summary

Modifier and TypeMethod and Description
private String
adjustEndFileSeparator(String url)

If the URL or Directory path is missing end file separator, add that.

private String

Returns:

the module name to use according to actual modularity of the package
checkLinkCompatibility
(String
the package name
packageName
,
String
the module name or null
moduleName
,
String
the documentation path
path
,
boolean
whether to print a diagnostic message in case of modularity mismatch
showDiagnostic
)

Check if the external documentation format matches our internal model of the code.

private Extern.Item
findElementItem(Element
Element
element
)

Get the Extern Item object associated with this element name.

private String

Returns:

the custom URL as String
getCustomPlatformDocs
(int
the platform version number
version
,
String
path pointing to a properties file
linkPlatformProperties
)

Retrieve and return the custom URL for the platform API documentation for the given version from the properties file at linkPlatformProperties.

private String

Returns:

the URL as String
getDefaultPlatformDocs
(int
the platform version number
version
)

Return the default URL for the platform API documentation for the given version.

private String
private String

Returns:

old-form HTML name
getOldFormHtmlName
(String
the string that needs to be converted to a valid HTML name
name
)

Converts a name to an old-form HTML name (old-form id).

private DocPath

Returns:

the resource path
getPlatformElementList
(int
the platform version number
version
)

Return the resource path for the package or element list for the given version.

private int

Returns:

the source version number
getSourceVersionNumber
()

Return the source version number used in the current execution of javadoc.

public boolean

Returns:

true if the element is externally documented
isExternal
(Element
an Element.
element
)

Determine if a element item is externally documented.

public boolean

Returns:

true if the element is a module
isModule
(String
name of the element.
elementName
)

Determine if a element item is a module or not.

private boolean

Returns:

True if docs use old-form anchors
isOldFormPlatformDocs
(int version)

Checks if platform docs for the specified version use old-form anchors.

private boolean

Returns:

true if it is a pre-release version
isPrerelease
(int
the source version number
sourceVersion
)

Return true if the given sourceVersion is the same as the current doclet version and is a pre-release version.

public boolean
isUrl(String urlCandidate)

private InputStream

Returns:

the stream
open
(URL
the URL
url
)

Open a stream to a URL, following a limited number of redirects if necessary.

private void
private void
readElementList(DocFile file, String path, boolean isOldFormDoc)

private void
readElementList(InputStream
InputStream from the "element-list" file.
input
,
String
URL or the directory path to the elements.
path
,
boolean
Is path relative?
relative
,
int
The version of platform libraries the element list belongs to, or 0 if it does not belong to a platform libraries doc bundle.
platformVersion
,
boolean isOldFormDoc)

Read the file "element-list" and for each element name found, create Extern object and associate it with the element name in the map.

private void
readElementListFromFile(String
URL or directory path to the elements.
path
,
DocFile
Path to the local "element-list" file.
elemListPath
)

Read the "element-list" file which is available locally.

private void
readElementListFromURL(String
Path to the elements.
urlpath
,
URL
URL or the path to the "element-list" file.
elemlisturlpath
)

Fetch the URL and read the "element-list" file.

private void
readPackageListFromURL(String
Path to the packages.
urlpath
,
URL
URL or the path to the "package-list" file.
elemlisturlpath
)

Fetch the URL and read the "package-list" file.

private URL
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

configurationback to summary
private final BaseConfiguration configuration

The global configuration information for this run.

linkofflineback to summary
private boolean linkoffline

True if we are using -linkoffline and false if -link is used instead.

moduleItemsback to summary
private Map<String, Extern.Item> moduleItems

Map element names onto Extern Item objects. Lazily initialized.

packageItemsback to summary
private Map<String, Map<String, Extern.Item>> packageItems
resourcesback to summary
private final Resources resources
utilsback to summary
private final Utils utils

Constructor Detail

Externback to summary
public Extern(BaseConfiguration configuration)

Method Detail

adjustEndFileSeparatorback to summary
private String adjustEndFileSeparator(String url)

If the URL or Directory path is missing end file separator, add that.

checkLinkCompatibilityback to summary
private String checkLinkCompatibility(String packageName, String moduleName, String path, boolean showDiagnostic)

Check if the external documentation format matches our internal model of the code. Returns the module name to use for external reference lookup according to the actual modularity of the external package (and regardless of modularity of documentation).

Parameters
packageName:String

the package name

moduleName:String

the module name or null

path:String

the documentation path

showDiagnostic:boolean

whether to print a diagnostic message in case of modularity mismatch

Returns:String

the module name to use according to actual modularity of the package

findElementItemback to summary
private Extern.Item findElementItem(Element element)

Get the Extern Item object associated with this element name.

Parameters
element:Element

Element

getCustomPlatformDocsback to summary
private String getCustomPlatformDocs(int version, String linkPlatformProperties) throws Fault

Retrieve and return the custom URL for the platform API documentation for the given version from the properties file at linkPlatformProperties.

Parameters
version:int

the platform version number

linkPlatformProperties:String

path pointing to a properties file

Returns:String

the custom URL as String

getDefaultPlatformDocsback to summary
private String getDefaultPlatformDocs(int version)

Return the default URL for the platform API documentation for the given version.

Parameters
version:int

the platform version number

Returns:String

the URL as String

getLastPathComponentback to summary
private String getLastPathComponent(URL u)
getOldFormHtmlNameback to summary
private String getOldFormHtmlName(String name)

Converts a name to an old-form HTML name (old-form id).

Parameters
name:String

the string that needs to be converted to a valid HTML name

Returns:String

old-form HTML name

getPlatformElementListback to summary
private DocPath getPlatformElementList(int version)

Return the resource path for the package or element list for the given version.

Parameters
version:int

the platform version number

Returns:DocPath

the resource path

getSourceVersionNumberback to summary
private int getSourceVersionNumber()

Return the source version number used in the current execution of javadoc.

Returns:int

the source version number

isExternalback to summary
public boolean isExternal(Element element)

Determine if a element item is externally documented.

Parameters
element:Element

an Element.

Returns:boolean

true if the element is externally documented

isModuleback to summary
public boolean isModule(String elementName)

Determine if a element item is a module or not.

Parameters
elementName:String

name of the element.

Returns:boolean

true if the element is a module

isOldFormPlatformDocsback to summary
private boolean isOldFormPlatformDocs(int version)

Checks if platform docs for the specified version use old-form anchors. Old-form anchors are used by Oracle docs for JDKs 8 and 9. It can be checked on https://docs.oracle.com/javase//docs/api

Returns:boolean

True if docs use old-form anchors

isPrereleaseback to summary
private boolean isPrerelease(int sourceVersion)

Return true if the given sourceVersion is the same as the current doclet version and is a pre-release version.

Parameters
sourceVersion:int

the source version number

Returns:boolean

true if it is a pre-release version

isUrlback to summary
public boolean isUrl(String urlCandidate)
openback to summary
private InputStream open(URL url) throws IOException

Open a stream to a URL, following a limited number of redirects if necessary.

Parameters
url:URL

the URL

Returns:InputStream

the stream

Exceptions
IOException:
if an error occurred accessing the URL
printModularityMismatchDiagnosticback to summary
private void printModularityMismatchDiagnostic(String key, Object arg)
readElementListback to summary
private void readElementList(DocFile file, String path, boolean isOldFormDoc) throws Fault, DocFileIOException
readElementListback to summary
private void readElementList(InputStream input, String path, boolean relative, int platformVersion, boolean isOldFormDoc) throws IOException

Read the file "element-list" and for each element name found, create Extern object and associate it with the element name in the map.

Parameters
input:InputStream

InputStream from the "element-list" file.

path:String

URL or the directory path to the elements.

relative:boolean

Is path relative?

platformVersion:int

The version of platform libraries the element list belongs to, or 0 if it does not belong to a platform libraries doc bundle.

Exceptions
IOException:
if there is a problem reading or closing the stream
readElementListFromFileback to summary
private void readElementListFromFile(String path, DocFile elemListPath) throws Fault, DocFileIOException

Read the "element-list" file which is available locally.

Parameters
path:String

URL or directory path to the elements.

elemListPath:DocFile

Path to the local "element-list" file.

Exceptions
Fault:
if an error occurs that can be treated as a warning
DocFileIOException:
if there is a problem opening the element list file
readElementListFromURLback to summary
private void readElementListFromURL(String urlpath, URL elemlisturlpath) throws Fault

Fetch the URL and read the "element-list" file.

Parameters
urlpath:String

Path to the elements.

elemlisturlpath:URL

URL or the path to the "element-list" file.

readPackageListFromURLback to summary
private void readPackageListFromURL(String urlpath, URL elemlisturlpath) throws Fault

Fetch the URL and read the "package-list" file.

Parameters
urlpath:String

Path to the packages.

elemlisturlpath:URL

URL or the path to the "package-list" file.

toURLback to summary
private URL toURL(String url) throws Fault
Annotations
@SuppressWarnings:deprecation
jdk.javadoc.internal.doclets.toolkit.util back to summary

private Class Extern.Fault

extends Exception
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
Fault(String msg, Exception cause)

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.Exception.serialVersionUID.

Constructor Detail

Faultback to summary
pack-priv Fault(String msg, Exception cause)
jdk.javadoc.internal.doclets.toolkit.util back to summary

private Class Extern.Item

extends Object
Class Inheritance

Stores the info for one external doc set

Field Summary

Modifier and TypeField and Description
pack-priv final String
elementName

Element name, found in the "element-list" file in the path.

pack-priv final DocPath
path

The URL or the directory path at which the element documentation will be available.

pack-priv final boolean
relative

If given path is directory path then true else if it is a URL then false.

pack-priv final boolean
useOldFormId

Indicates that docs use old-form of anchors.

Constructor Summary

AccessConstructor and Description
pack-priv
Item(String
Element name found in the "element-list" file.
elementName
,
DocPath
URL or Directory path from where the "element-list" file is picked.
path
,
boolean
True if path is URL, false if directory path.
relative
,
boolean useOldFormId)

Constructor to build a Extern Item object and map it with the element name.

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

String representation of "this" with elementname and the path.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

elementNameback to summary
pack-priv final String elementName

Element name, found in the "element-list" file in the path.

pathback to summary
pack-priv final DocPath path

The URL or the directory path at which the element documentation will be available.

relativeback to summary
pack-priv final boolean relative

If given path is directory path then true else if it is a URL then false.

useOldFormIdback to summary
pack-priv final boolean useOldFormId

Indicates that docs use old-form of anchors.

Constructor Detail

Itemback to summary
pack-priv Item(String elementName, DocPath path, boolean relative, boolean useOldFormId)

Constructor to build a Extern Item object and map it with the element name. If the same element name is found in the map, then the first mapped Item object or offline location will be retained.

Parameters
elementName:String

Element name found in the "element-list" file.

path:DocPath

URL or Directory path from where the "element-list" file is picked.

relative:boolean

True if path is URL, false if directory path.

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

String representation of "this" with elementname and the path.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override