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

public Class Utils

extends Object
Class Inheritance
Imports
java.lang.annotation.Documented, java.lang.ref.SoftReference, java.net.URI, java.text.CollationKey, .Collator, .ParseException, .RuleBasedCollator, java.util.ArrayDeque, .ArrayList, .Collection, .Collections, .Deque, .EnumSet, .HashMap, .HashSet, .Iterator, .LinkedHashMap, .LinkedHashSet, .List, .Locale, .Map, .Map.Entry, .NoSuchElementException, .Objects, .Set, .SortedSet, .TreeMap, .TreeSet, java.util.function.Predicate, java.util.stream.Collectors, javax.lang.model.AnnotatedConstruct, .SourceVersion, javax.lang.model.element.AnnotationMirror, .AnnotationValue, .Element, .ElementKind, .ExecutableElement, .Modifier, .ModuleElement, .ModuleElement.RequiresDirective, .PackageElement, .QualifiedNameable, .RecordComponentElement, .TypeElement, .TypeParameterElement, .VariableElement, javax.lang.model.type.ArrayType, .DeclaredType, .ErrorType, .ExecutableType, .PrimitiveType, .TypeMirror, .TypeVariable, .WildcardType, javax.lang.model.util.ElementFilter, .Elements, .SimpleAnnotationValueVisitor14, .SimpleElementVisitor14, .SimpleTypeVisitor14, .TypeKindVisitor9, .Types, javax.tools.FileObject, .JavaFileManager, .JavaFileManager.Location, .StandardLocation, com.sun.source.doctree.BlockTagTree, .DeprecatedTree, .DocCommentTree, .DocTree, .DocTree.Kind, .ParamTree, .ProvidesTree, .ReturnTree, .SeeTree, .SerialDataTree, .SerialFieldTree, .SerialTree, .SpecTree, .ThrowsTree, .UsesTree, com.sun.source.tree.CompilationUnitTree, .LineMap, com.sun.source.util.DocSourcePositions, .DocTrees, .TreePath, jdk.javadoc.internal.doclets.toolkit.BaseConfiguration, .BaseOptions, .CommentUtils, .CommentUtils.DocCommentInfo, .Resources

Utilities Class for Doclets.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Utils.CommentHelperCache

A memory-sensitive cache for CommentHelper objects, which are expensive to compute.

private static class
public static enum
private static class
public static enum
Utils.ElementFlag

An element can have flags that place it into some subcategories, like being a preview or a deprecated element.

public static record
private class
public static class
Utils.Pair<
the type of the first value
K
,
the type of the second value
L
>

A container holding a pair of values (tuple).

public static interface
public static class

Field Summary

Modifier and TypeField and Description
private final HashMap<Element, SortedSet<TypeElement>>
private final Utils.CommentHelperCache
public final Comparators
public final BaseConfiguration
private Utils.ConstantValueExpression
private final Map<Element, CommentUtils.DocCommentInfo>
dcTreeCache

A cache of doc comment info objects for elements.

private final DocFinder
public final DocTrees
public final Elements
private final TypeElement
private final JavaScriptScanner
private final Map<String, String>
private Map<ModuleElement, Set<PackageElement>>
private final Map<Element, String>
private final BaseOptions
private Utils.PreviewFlagProvider
private final Resources
private Utils.DocCollator
private SimpleElementVisitor14<Boolean, Void>
private SimpleElementVisitor14<String, Void>
private SimpleElementVisitor14<Boolean, Void>
private final Map<String, TypeMirror>
private Utils.DocCollator
public final Types

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
private Collection<TypeElement>
private Collection<TypeElement>
private Collection<TypeElement>
public TypeMirror

Returns:

the instantiated field type.
asInstantiatedFieldType
(TypeElement
the contextual type.
site
,
VariableElement
the field declaration.
ve
)

Returns the TypeMirror corresponding to the type of the field declaration seen as a member of a given declared type.

public ExecutableType

Returns:

the instantiated method type.
asInstantiatedMethodType
(TypeElement
the contextual type.
site
,
ExecutableElement
the method declaration.
ee
)

Returns the ExecutableType corresponding to the type of the method declaration seen as a member of a given declared type.

public TypeElement

Returns:

the TypeElement of this type, or null if it is a primitive type.
asTypeElement
(TypeMirror t)

Return this type as a TypeElement if it represents a class interface or annotation.

public void
private boolean
public int

Returns:

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
compareStrings
(String
first String to compare.
s1
,
String
second String to compare.
s2
)

A general purpose case insensitive String comparator, which compares two Strings using a Collator strength of "TERTIARY".

pack-priv int
compareStrings(boolean caseSensitive, String s1, String s2)

public String
public ModuleElement
public PackageElement
public Utils.PreviewSummary
private JavaFileManager.Location
public boolean
public static String
public DocFinder
public Set<Utils.ElementFlag>

Returns:

the set of all the element's flags.
elementFlags
(Element
the element to test
el
)

Return all flags for the given Element.

public SortedSet<TypeElement>

Returns:

list of filtered classes.
filterOutPrivateClasses
(Iterable<TypeElement>
a collection of TypeElements
classlist
,
boolean
set to true if in JavaFX mode.
javafx
)

In case of JavaFX mode on, filters out classes that are private, package private, these are not documented in JavaFX mode, also remove those classes that have @hidden or @treatAsPrivate comment tag.

public String

Returns:

signature with simple (unqualified) parameter types
flatSignature
(ExecutableElement
the executable element
e
,
TypeElement
the contextual site
site
)

Get the flat signature of an executable element with simple (unqualified) parameter types in the context of type element site.

public SortedSet<TypeElement>

Returns:

the classes and interfaces
getAllClasses
(PackageElement
the element
pkg
)

Returns a sorted set containing the documented classes and interfaces in a package.

public SortedSet<TypeElement>

Returns:

the interfaces
getAllClassesUnfiltered
(PackageElement
the package
pkg
)

Returns all the classes in a package.

public Set<TypeMirror>

Returns:

the list of superinterfaces.
getAllInterfaces
(TypeElement
the type element to get the superinterfaces for.
te
)

Returns all the implemented superinterfaces of a given type, in the case of classes, include all the superinterfaces of the supertype.

private <
the class of the filtered members
T extends Element
>
List<T>

Returns:

the list of enclosed elements
getAllItems
(Element
the element, such as a package element or type element
e
,
ElementKind
the element kind
kind
,
Class<T>
the class of the filtered members
clazz
)

Returns a list of elements of a given type with a given kind.

private Object
getAnnotationElement(Element e, TypeMirror annotationType, String annotationElementName)

Returns the Deprecated annotation element value of the given element, or null.

public List<Element>

Returns:

the fields and methods
getAnnotationMembers
(TypeElement
the annotation interface
te
)

Returns the fields and methods declared in an annotation interface.

public List<? extends DocTree>

Returns:

the list
getBlockTags
(Element
the element
element
)

Returns the "raw" list of block tags from the doc-comment tree for an element, or an empty list if there is no such comment.

public List<? extends DocTree>

Returns:

the list
getBlockTags
(DocCommentTree
the doc-comment tree
dcTree
)

Returns the "raw" list of block tags from a DocCommentTree, or an empty list if the doc-comment tree is null.

public List<? extends BlockTagTree>

Returns:

the list
getBlockTags
(Element
the element
element
,
Predicate<? super BlockTagTree>
the filter
filter
)

Returns the list of block tags for the doc-comment tree for an element that match a given filter, or an empty list if there is no such doc-comment.

public <
the type of the required block tags
T extends BlockTagTree
>
List<T>

Returns:

the list
getBlockTags
(Element
the element
element
,
Predicate<? super BlockTagTree>
the filter
filter
,
Class<T> tClass)

Returns the list of block tags for the doc-comment tree for an element that match a given filter, or an empty list if there is no such doc-comment.

public List<? extends BlockTagTree>

Returns:

the list
getBlockTags
(Element
the element
element
,
DocTree.Kind kind)

Returns the list of block tags for the doc-comment tree for an element, or an empty list if there is no such doc-comment.

public <
the type of the required block tags
T extends BlockTagTree
>
List<? extends T>

Returns:

the list
getBlockTags
(Element
the element
element
,
DocTree.Kind
the kind for the required block tags
kind
,
Class<T> tClass)

Returns the list of block tags for the doc-comment tree for an element that match a given kind, or an empty list if there is no such doc-comment.

public List<? extends BlockTagTree>

Returns:

the list
getBlockTags
(Element
the element
element
,
String
the name of the required block tags
tagName
)

Returns the list of block tags for the doc-comment tree for an element that match a given name, or an empty list if there is no such doc-comment.

public List<? extends DocTree>
getBody(Element element)

public List<? extends TypeMirror>
public CommentHelper
public TypeMirror
public List<ExecutableElement>

Returns:

the constructors
getConstructors
(TypeElement
the type element
te
)

Returns the documented constructors in a type element.

public TypeMirror
public TypeMirror
getDeclaredType(Collection<TypeMirror> values, TypeElement
a TypeElement whose type arguments we desire
enclosing
,
TypeMirror
the TypeMirror of the type as described by the enclosing
target
)

Finds the declaration of the enclosing's type parameter.

public Map<ModuleElement, String>
public String

Returns:

the Deprecated.since value for e, or null.
getDeprecatedSince
(Element
the Element to check.
e
)

Returns the value of the Deprecated.since element if it is set on the given Element.

public List<? extends DeprecatedTree>
public TypeMirror
public String

Returns:

the type's dimension information as a string.
getDimension
(TypeMirror t)

Return the type's dimension information, as a string.

private CommentUtils.DocCommentInfo
private CommentUtils.DocCommentInfo
public DocCommentTree
public DocCommentTree

Returns:

DocCommentTree for the Element
getDocCommentTree0
(Element
the element
element
)

Retrieves the doc comments for a given element.

private <
the class of the filtered members
T extends Element
>
List<T>

Returns:

the list of enclosed elements
getDocumentedItems
(Element
the element, such as a package element or type element
e
,
ElementKind
the element kind
kind
,
Class<T>
the class of the filtered members
clazz
)

Returns a list of documented elements of a given type with a given kind.

public Iterable<TypeElement>

Returns:

the elements
getEnclosedTypeElements
(PackageElement
the package
pkg
)

Returns the recursively enclosed documented type elements in a package

public TypeElement
public List<VariableElement>

Returns:

the interfaces
getEnumConstants
(TypeElement
the element
te
)

Returns the documented enum constants in a type element.

public TypeMirror
public List<VariableElement>

Returns:

the fields
getFields
(TypeElement
the element
te
)

Returns the documented fields in a type element.

public List<VariableElement>

Returns:

the fields
getFieldsUnfiltered
(TypeElement
the element
te
)

Returns the fields in a type element.

public FileObject
public List<? extends DocTree>
public TypeMirror

Returns:

the closest visible superclass. Return null if it cannot be found.
getFirstVisibleSuperClass
(TypeMirror
the TypeMirror to be interrogated
type
)

Given a class, return the closest visible superclass.

public TypeMirror

Returns:

the closest visible superclass. Return null if it cannot be found.
getFirstVisibleSuperClass
(TypeElement
the TypeElement to be interrogated
te
)

Given a class, return the closest visible superclass.

public TypeElement
public List<? extends DocTree>
public String

Returns:

the name
getFullyQualifiedName
(Element
the element to get FQN for.
e
)

A generic utility which returns the fully qualified names of an entity, if the entity is not qualifiable then its enclosing entity, it is up to the caller to add the elements name as required.

public String
getFullyQualifiedName(Element e, final boolean outer)

public TypeMirror
private <
the class of the filtered members
T extends Element
>
List<T>

Returns:

the list of enclosed elements
getItems
(Element
the element, such as a package element or type element
e
,
boolean
whether to search through all packages and classes, or just documented ones
all
,
Predicate<Element>
the predicate to select members
select
,
Class<T>
the class of the filtered members
clazz
)

Returns a list of elements of a given type that match a predicate.

private <
the class of the filtered members
T extends Element
>
List<T>

Returns:

the list of enclosed elements
getItems0
(Element
the element, such as a package element or type element
e
,
boolean
whether to search all packages and classes, or just documented ones
all
,
Predicate<Element>
the predicate for the selected members
select
,
Class<T>
the class of the filtered members
clazz
)

Returns a list of immediately enclosed elements of a given class that match a predicate.

public long
public JavaFileManager.Location
public JavaFileManager.Location
public List<ExecutableElement>

Returns:

the methods
getMethods
(TypeElement
the type element
te
)

Returns the documented methods in a type element.

public String
public String
getModuleName(ModuleElement
a ModuleElement
mdle
)

Get the module name for a given module element.

public Map<ModuleElement, Set<PackageElement>>
public TypeMirror
public String
getPackageName(PackageElement pkg)

Get the package name for a given package element.

public List<ParamTree>
private List<ParamTree>
getParamTrees(Element element, boolean isTypeParameters)

public List<? extends DocTree>
public Object

Returns:

the PreviewFeature.feature for e, or null
getPreviewFeature
(Element
the Element to check
e
)

Returns the value of the internal PreviewFeature.feature element.

public String
public String
public List<? extends ProvidesTree>
public String

Returns:

the fully qualified name of Reference type or the primitive name
getQualifiedTypeName
(TypeMirror
the type whose name is to be obtained.
t
)

Get the qualified type name of a TypeMirror compatible with the Element's getQualified name, returns the qualified name of the Reference type otherwise the primitive name.

public List<? extends ReturnTree>
public TypeMirror

Returns:

the return type
getReturnType
(TypeElement
the contextual type
site
,
ExecutableElement
the ExecutableElement
ee
)

Returns the TypeMirror of the ExecutableElement if it is a method, or null if it is a constructor.

public List<? extends SeeTree>
public List<? extends SerialDataTree>
public List<? extends SerialFieldTree>
public TypeMirror
public List<? extends SerialTree>
public String

Returns:

the name
getSimpleName
(Element
an element whose name is required
e
)

Returns the name of the element after the last dot of the package name.

private String
public List<? extends SpecTree>
public TypeMirror
getSymbol(String signature)

public TypeMirror
public List<ThrowsTree>
public TreePath

Returns:

TreePath
getTreePath
(Element
an Element
e
)

Gets a TreePath for an Element.

public String

Returns:

the name
getTypeElementKindName
(TypeElement
the type element
te
,
boolean
true if you want the name returned in lower case; if false, the first letter of the name is capitalized
lowerCaseOnly
)

Returns the name of the kind of a type element (Class, Interface, etc.).

public SortedSet<TypeElement>
public String
getTypeName(TypeMirror t, boolean fullyQualified)

public List<ParamTree>
public String
getTypeSignature(TypeMirror t, boolean qualifiedName, boolean noTypeParameters)

public List<? extends UsesTree>
public boolean
public boolean
hasBlockTag(Element element, DocTree.Kind kind, final String tagName)

pack-priv boolean
public boolean

Returns:

true if the element has a comment, and false otherwise
hasDocCommentTree
(Element
the element
element
)

Checks whether an element has an associated doc comment.

private boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
private boolean
public boolean
public boolean
isCoreClass(TypeElement e)

According to The Java Language Specification, all the outer classes and static inner classes are core classes.

public boolean
public boolean
public boolean

Returns:

true if the given Element is deprecated.
isDeprecated
(Element
the Element to check.
e
)

Return true if the given Element is deprecated.

public boolean

Returns:

true if the given Element is deprecated for removal.
isDeprecatedForRemoval
(Element
the Element to check.
e
)

Returns true if the given Element is deprecated for removal.

public boolean

Returns:

true return true if it should be documented and false otherwise.
isDocumentedAnnotation
(TypeElement
the annotation to check.
annotation
)

Given an annotation, return true if it should be documented and false otherwise.

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean

Returns:

true if type arguments were found
isGenericType
(TypeMirror
the type
type
)

Returns true if type or any of its enclosing types has non-empty type arguments.

public boolean

Returns:

true if element is hidden, false otherwise
isHidden
(Element
the queried element
e
)

Returns true if the element is hidden.

public boolean
public boolean
public boolean

Returns:

true if this class is linkable and false if we can't link to the desired class.
isLinkable
(TypeElement typeElem)

Returns true if this class is linkable and false if we can't link to it.

public boolean

Returns:

whether or not the element is linkable
isLinkable
(TypeElement
the type element
typeElem
,
Element
the element
elem
)

Returns true if an element is linkable in the context of a given type element.

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean

Returns:

true if and only if the given element should be marked as a preview API
isPreviewAPI
(Element
the element to check
el
)

Checks whether the given Element should be marked as a preview API.

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean

Returns:

true if and only if the given element should be marked as a reflective preview API
isReflectivePreviewAPI
(Element
the element to check
el
)

Checks whether the given Element should be marked as a reflective preview API.

public boolean

Returns:

true if and only if the given element should be marked as a restricted API
isRestrictedAPI
(Element
the element to check
el
)

Checks whether the given ExecutableElement should be marked as a restricted API.

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
isUndocumentedEnclosure(TypeElement enclosingTypeElement)

private boolean

Returns:

true if typeElement is in a package that is not unconditionally exported by its module
isUnexportedType
(TypeElement
a type element
typeElement
)

Returns true if typeElement is in a package that is not unconditionally exported by its module.

public boolean
public boolean

Returns:

true if the type element is visible
isVisible
(TypeElement
the type element
typeElement
)

Returns true if the type element is visible.

public boolean
public String
public String
makeSignature(ExecutableElement e, TypeElement site, boolean full, boolean ignoreTypeParameters)

private DocFinder
public String

Returns:

normalized string
normalizeWhitespace
(String
the string to be normalized
s
)

Replaces each group of one or more whitespace characters with a single canonical space

private boolean
public Utils.OverrideInfo
private Iterable<? extends ExecutableElement>
public Set<Utils.DeclarationPreviewLanguageFeatures>

Returns:

the set of preview language features used to declare the given element
previewLanguageFeaturesUsed
(Element
the Element to check.
e
)

Return the set of preview language features used to declare the given element.

public String

Returns:

the name of the property of the given setter of getter.
propertyName
(ExecutableElement
the input method.
e
)

A convenience method to get property name from the name of the getter or setter method.

private <
the class of the filtered members
T extends Element
>
void
recursiveGetItems(Collection<T> list, Element
the element, such as a package element or type element
e
,
boolean
whether to search all packages and classes, or just documented ones
all
,
Predicate<Element>
the filter
filter
,
Class<T>
the class of the filtered members
clazz
)

Searches for a list of recursively enclosed elements of a given class that match a predicate.

public void
public String

Returns:

the text with all tabs expanded
replaceTabs
(String
the text for which the tabs should be expanded
text
)

Replace all tabs in a string with the appropriate number of spaces.

public SortedSet<VariableElement>
public SortedSet<ExecutableElement>
public Utils.PreviewFlagProvider
public boolean
private boolean
public String

Returns:

String signature with qualified parameter types
signature
(ExecutableElement
the executable element
e
,
TypeElement
the contextual site
site
)

Get the signature of an executable element with qualified parameter types in the context of type element site.

public static String

Returns:

converted String
toLowerCase
(String
to convert
s
)

Returns a locale independent lower cased String.

private Collection<TypeElement>
types2Classes(List<? extends TypeMirror> types)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait