com.sun.tools.doclets.internal.toolkit.util
Class Extern

java.lang.Object
  extended by com.sun.tools.doclets.internal.toolkit.util.Extern

public class Extern
extends java.lang.Object

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. This code is not part of an API. It is implementation that is subject to change. Do not use it as an API


Nested Class Summary
private  class Extern.Item
          Stores the info for one external doc set
 
Field Summary
private  Configuration 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  java.util.Map<java.lang.String,Extern.Item> packageToItemMap
          Map package names onto Extern Item objects.
 
Constructor Summary
Extern(Configuration configuration)
           
 
Method Summary
private  java.lang.String adjustEndFileSeparator(java.lang.String url)
          If the URL or Directory path is missing end file separator, add that.
private  java.lang.String composeExternPackageList(java.lang.String urlOrDirPath, java.lang.String pkgListUrlOrDirPath)
          Adjusts the end file separator if it is missing from the URL or the directory path and depending upon the URL or file path, fetch or read the "package-list" file.
private  java.lang.String fetchURLComposeExternPackageList(java.lang.String urlpath, java.lang.String pkglisturlpath)
          Fetch the URL and read the "package-list" file.
private  Extern.Item findPackageItem(java.lang.String pkgName)
          Get the Extern Item object associated with this package name.
 java.lang.String getExternalLink(java.lang.String pkgName, java.lang.String relativepath, java.lang.String link)
          Convert a link to be an external link if appropriate.
 boolean isExternal(ProgramElementDoc doc)
          Determine if a doc item is externally documented.
 boolean isUrl(java.lang.String urlCandidate)
           
private  java.lang.String readFileComposeExternPackageList(java.lang.String path, java.lang.String pkgListPath)
          Read the "package-list" file which is available locally.
private  void readPackageList(java.io.InputStream input, java.lang.String path, boolean relative)
          Read the file "package-list" and for each package name found, create Extern object and associate it with the package name in the map.
 boolean url(java.lang.String url, java.lang.String pkglisturl, DocErrorReporter reporter, boolean linkoffline)
          Build the extern package list from given URL or the directory path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

packageToItemMap

private java.util.Map<java.lang.String,Extern.Item> packageToItemMap
Map package names onto Extern Item objects. Lazily initialized.


configuration

private final Configuration configuration
The global configuration information for this run.


linkoffline

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

Constructor Detail

Extern

public Extern(Configuration configuration)
Method Detail

isExternal

public boolean isExternal(ProgramElementDoc doc)
Determine if a doc item is externally documented.

Parameters:
doc - A ProgramElementDoc.

getExternalLink

public java.lang.String getExternalLink(java.lang.String pkgName,
                                        java.lang.String relativepath,
                                        java.lang.String link)
Convert a link to be an external link if appropriate.

Parameters:
pkgName - The package name.
relativepath - The relative path.
link - The link to convert.
Returns:
if external return converted link else return null

url

public boolean url(java.lang.String url,
                   java.lang.String pkglisturl,
                   DocErrorReporter reporter,
                   boolean linkoffline)
Build the extern package list from given URL or the directory path. Flag error if the "-link" or "-linkoffline" option is already used.

Parameters:
url - URL or Directory path.
pkglisturl - This can be another URL for "package-list" or ordinary file.
reporter - The DocErrorReporter used to report errors.
linkoffline - True if -linkoffline isused and false if -link is used.

findPackageItem

private Extern.Item findPackageItem(java.lang.String pkgName)
Get the Extern Item object associated with this package name.

Parameters:
pkgname - Package name.

composeExternPackageList

private java.lang.String composeExternPackageList(java.lang.String urlOrDirPath,
                                                  java.lang.String pkgListUrlOrDirPath)
Adjusts the end file separator if it is missing from the URL or the directory path and depending upon the URL or file path, fetch or read the "package-list" file.

Parameters:
urlOrDirPath - URL or the directory path.
pkgListUrlOrDirPath - URL or directory path for the "package-list" file or the "package-list" file itself.

adjustEndFileSeparator

private java.lang.String adjustEndFileSeparator(java.lang.String url)
If the URL or Directory path is missing end file separator, add that.


fetchURLComposeExternPackageList

private java.lang.String fetchURLComposeExternPackageList(java.lang.String urlpath,
                                                          java.lang.String pkglisturlpath)
Fetch the URL and read the "package-list" file.

Parameters:
urlpath - Path to the packages.
pkglisturlpath - URL or the path to the "package-list" file.

readFileComposeExternPackageList

private java.lang.String readFileComposeExternPackageList(java.lang.String path,
                                                          java.lang.String pkgListPath)
Read the "package-list" file which is available locally.

Parameters:
path - URL or directory path to the packages.
pkgListPath - Path to the local "package-list" file.

readPackageList

private void readPackageList(java.io.InputStream input,
                             java.lang.String path,
                             boolean relative)
                      throws java.io.IOException
Read the file "package-list" and for each package name found, create Extern object and associate it with the package name in the map.

Parameters:
input - InputStream from the "package-list" file.
path - URL or the directory path to the packages.
relative - Is path relative?
Throws:
java.io.IOException

isUrl

public boolean isUrl(java.lang.String urlCandidate)