Top Description Methods
javax.lang.model.element

public Interface PackageElement

extends Element, QualifiedNameable
Imports
java.util.List, javax.lang.model.type.TypeMirror

Represents a package program element. Provides access to information about the package and its members.

API Note

The represented package may have an explicit reference representation (either source code or executable output) or may be created from implicit information. The explicit and standalone source code construct for a package is typically a package-info.java file (JLS 7.4.1). A named package without a standalone package-info.java file can be declared in the package declaration of a top-level class or interface. Implicit information is used to model unnamed packages (JLS 7.4.2).

In the context of annotation processing, a package element can be:

Since
1.6
See Also
javax.lang.model.util.Elements#getPackageOf

Method Summary

Modifier and TypeMethod and Description
public TypeMirror

Returns:

a pseudo-type for this package
asType
()

Redeclares javax.lang.model.element.Element.asType.

Returns a pseudo-type for this package.

public List<? extends Element>

Returns:

the top-level classes and interfaces within this package
getEnclosedElements
()

Redeclares javax.lang.model.element.Element.getEnclosedElements.

Returns the top-level classes and interfaces within this package.

public Element

Returns:

the enclosing module if such a module exists; otherwise null
getEnclosingElement
()

Redeclares javax.lang.model.element.Element.getEnclosingElement.

Returns the enclosing module if such a module exists; otherwise null.

public Name

Returns:

the fully qualified name of this package, or an empty name if this is an unnamed package
getQualifiedName
()

Redeclares javax.lang.model.element.QualifiedNameable.getQualifiedName.

Returns the fully qualified name of this package.

public Name

Returns:

the simple name of this package or an empty name if this is an unnamed package
getSimpleName
()

Redeclares javax.lang.model.element.Element.getSimpleName.

Returns the simple name of this package.

public boolean

Returns:

true if this is an unnamed package and false otherwise
isUnnamed
()

Returns true if this is an unnamed package and false otherwise.

Inherited from javax.lang.model.element.Element:
acceptequalsgetAnnotationgetAnnotationMirrorsgetAnnotationsByTypegetKindgetModifiershashCode

Method Detail

asTypeback to summary
public TypeMirror asType()

Redeclares javax.lang.model.element.Element.asType.

Returns a pseudo-type for this package.

Returns:TypeMirror

a pseudo-type for this package

Annotations
@Override
See Also
javax.lang.model.type.NoType, javax.lang.model.type.TypeKind#PACKAGE
getEnclosedElementsback to summary
public List<? extends Element> getEnclosedElements()

Redeclares javax.lang.model.element.Element.getEnclosedElements.

Returns the top-level classes and interfaces within this package. Note that subpackages are not considered to be enclosed by a package.

Returns:List<? extends Element>

the top-level classes and interfaces within this package

Annotations
@Override
getEnclosingElementback to summary
public Element getEnclosingElement()

Redeclares javax.lang.model.element.Element.getEnclosingElement.

Returns the enclosing module if such a module exists; otherwise null. One situation where a module does not exist for a package is if the environment does not include modules, such as an annotation processing environment configured for a source version without modules.

Returns:Element

the enclosing module if such a module exists; otherwise null

Annotations
@Override
getQualifiedNameback to summary
public Name getQualifiedName()

Redeclares javax.lang.model.element.QualifiedNameable.getQualifiedName.

Returns the fully qualified name of this package. This is also known as the package's canonical name. For an unnamed package, an empty name is returned.

API Note

The fully qualified name of a named package that is not a subpackage of a named package is its simple name. The fully qualified name of a named package that is a subpackage of another named package consists of the fully qualified name of the containing package, followed by ".", followed by the simple (member) name of the subpackage.

Returns:Name

the fully qualified name of this package, or an empty name if this is an unnamed package

Java Language Specification
6.7 Fully Qualified Names and Canonical Names
getSimpleNameback to summary
public Name getSimpleName()

Redeclares javax.lang.model.element.Element.getSimpleName.

Returns the simple name of this package. For an unnamed package, an empty name is returned.

Returns:Name

the simple name of this package or an empty name if this is an unnamed package

Annotations
@Override
isUnnamedback to summary
public boolean isUnnamed()

Returns true if this is an unnamed package and false otherwise.

Returns:boolean

true if this is an unnamed package and false otherwise

Java Language Specification
7.4.2 Unnamed Packages