Tests whether the given program element is visible according to one of the
access control options (-public
, -protected
,
-package
, -private
) specified on the Javadoc
command line (or assumed by default, i.e. -protected
).
Unlike elements not included in the active set (see Doc/@isIncluded
attribute),
which may still appear in the documentation (for instance, in the inherited member lists),
the invisible elements should be treated as if they do not exists at all.
Nevertheless, their presence must be taken into account by the doclet so as to generate the consistent documentation according to that principle.
For example, let's consider we have an interface I
and
two classes: A
and B
, defined as the following:
public interface I {
void m();
}
class B implements I {
public void m() {...}
}
public class A extends class B {
...
}
A
, interface I
and the method m()
are public. However, the method m()
, which is defined in the interface
I
, is actually implemented in the class B
with
the package local visibility.
Let's suppose, we want to generate by such a code some open API documentation
with mentioning only public and protected elements.
To do this, we run Javadoc with -protected
option (default).
In that case, the class B
becomes invisible and must not be mentioned in
the documentation. That's true, because the class B
is a feature of our internal
implementation not supposed to be published in the open API. (It may change next time!)
Instead, the open API documentation must represent everything as if it was defined like the following:
public interface I {
void m();
}
public class A implements I {
public void m() {...}
}
B
does not exist.
Instead, the class A
implements the interface I
directly,
together with the method m()
, in particular.
In fact, that is how the Standard Javadoc Doclet (starting from JDK 1.5) would also represent this situation.
Since the Doclet API represents everything exactly as it is specified in the Java sources
(and that's right!), doing such a conversion is the job of a particular doclet.
Here is where the isVisible()
function is needed.
Parameter:
element
TheReturns:ProgramElementDoc
element whose visibility is requested.It may also be a
Type
element, which is automatically converted to theClassDoc
by calling the method:Type.asClassDoc()
If
element
is aPackageDoc
, the function will returntrue
(as packages are always visible).In any other cases, the function will return
false
.If this parameter is not specified, the generator context element is assumed, i.e. the same as the call:
contextElement.isVisible()
true
, if the program element is visible;false
, otherwise
See Also:
isIncluded()