Template:Javadoc:SE/doc
![]() | This is a documentation subpage for Template:Javadoc:SE. It may contain usage information, categories and other content that is not part of the original template page. |
![]() | This template should not be substituted. |
__EXPECTUNUSEDTEMPLATE__
Template for creating an external link into the Javadoc for a class in the current version of the Java SE API. This template should be used instead of an explicit URL to allow the link to be automatically updated to the latest API when this template is updated.
Please update Template:Javadoc:SE/Home_URL to update the java version that this link sends users to.
Usage
These are the common forms of usage for this template:
Type this To get this <syntaxhighlight lang="wikitext" inline>Java SE 19 API Javadocs</syntaxhighlight> Java SE 19 API Javadocs <syntaxhighlight lang="wikitext" inline> Object
</syntaxhighlight>Object
<syntaxhighlight lang="wikitext" inline> Object.clone()
</syntaxhighlight>Object.clone()
<syntaxhighlight lang="wikitext" inline> java.lang
</syntaxhighlight>java.lang
<syntaxhighlight lang="wikitext" inline> java.lang.Object
</syntaxhighlight>java.lang.Object
<syntaxhighlight lang="wikitext" inline> java.lang.Object.clone()
</syntaxhighlight>java.lang.Object.clone()
<syntaxhighlight lang="wikitext" inline> StandardDoclet
</syntaxhighlight>StandardDoclet
In the above example, clone()
can be any member documented in the Javadoc that isn't a class or interface, so <syntaxhighlight lang="wikitext" inline>System.out
</syntaxhighlight> produces System.out
. For a class or interface member, the class name is OuterClass.InnerClass
, so <syntaxhighlight lang="wikitext" inline>Character.Subset
</syntaxhighlight> produces Character.Subset
.
The Javadoc URLs don't include the generic parameterized types. To get the type parameters to display, specify a class
and/or member
parameter to the template to override the name of the displayed class and/or member name. Note that the parameterized type notation uses angle brackets (<
and >
), so type parameter names that match HTML markup tags need to use the character encodings <
for <
and >
for >
.
Type this To get this <syntaxhighlight lang="wikitext"> Class<T>
</syntaxhighlight>Class<T>
<syntaxhighlight lang="wikitext"> [https://docs.oracle.com/en/java/javase/19/docs/api/java.base/
java/lang/Class.html#asSubclass(java.lang.Class) Class<T>.asSubclass(Class<U>)]
</syntaxhighlight>Class<T>.asSubclass(Class<U>)
<syntaxhighlight lang="wikitext"> [https://docs.oracle.com/en/java/javase/19/docs/api/java.base/
java/lang/Class.html java.lang.Class<T>]
</syntaxhighlight>java.lang.Class<T>
<syntaxhighlight lang="wikitext"> [https://docs.oracle.com/en/java/javase/19/docs/api/java.base/
java/lang/Class.html#asSubclass(java.lang.Class) java.lang.Class<T>.asSubclass(Class<U>)]
</syntaxhighlight>java.lang.Class<T>.asSubclass(Class<U>)
The URL to a method uses the fully-qualified path name of the parameter types. The member
parameter can be used to use the simple type name of method parameters, as shown in the preceding table, or even to eliminate the parameters entirely.
Finally, if none of the above work for the displayed text, supplying a name
parameter allows the entire package/class/member name displayed to be replaced. (However, the name
parameter won't override the text displayed when using the <syntaxhighlight lang="wikitext" inline>Java SE 19 API Javadocs</syntaxhighlight> form.)
Issues
Some versions of Javadoc, such as the version used to create the current Javadoc API pages, put spaces between the parameter names in the anchor tags used to link to the definitions of members. Unfortunately, that means to get a link to a method or constructor with two or more parameters to display correctly, the method/constructor signature needs both a displayed and link version like this:
Type this To get this <syntaxhighlight lang="wikitext" inline> String.indexOf(int, int)
</syntaxhighlight>String.indexOf(int, int)
- Links in the current version do not contain spaces, the spaces are simply removed in the anchor tags.
Type this To get this <syntaxhighlight lang="wikitext" inline> String.indexOf(int, int)
</syntaxhighlight>String.indexOf(int, int)
- Including square brackets ([, ]) in the parameter types of method or constructor member arguments seems to break the template. Instead, replace square brackets with their numeric character reference escape codes, [ and ], like this:
Type this To get this <syntaxhighlight lang="wikitext" inline> Arrays.sort(java.lang.Object[])
</syntaxhighlight>Arrays.sort(java.lang.Object[])
<syntaxhighlight lang="wikitext" inline> Arrays.sort(Object[])
</syntaxhighlight>Arrays.sort(Object[])
- Anything which is not within the
java.base
module of the Java API must declare themodule
parameter to ensure that the user is sent to the correct area of the documentation. Ifmodule
is not specified, the template will default tojava.base
- which, if the item in question is not withinjava.base
, will send the reader to a 404 page.
Type this To get this <syntaxhighlight lang="wikitext" inline> StandardDoclet
</syntaxhighlight>StandardDoclet
<syntaxhighlight lang="wikitext" inline> Graphics2D
</syntaxhighlight>Graphics2D
See also
- Template:Javadoc:SE
- Template:Javadoc:SE-guide
- Template:Javadoc:EE
- Template:Javadoc:Android
- Template:Javadoc:SE/Home_URL