Save This Page
Home » Open-JDK-6.b17-src » javax.lang » model » util » [javadoc | source]
javax.lang.model.util
public interface: Elements [javadoc | source] Utility methods for operating on program elements.

Compatibility Note: Methods may be added to this interface in future releases of the platform.

Method from javax.lang.model.util.Elements Summary:
getAllAnnotationMirrors,   getAllMembers,   getBinaryName,   getConstantExpression,   getDocComment,   getElementValuesWithDefaults,   getName,   getPackageElement,   getPackageOf,   getTypeElement,   hides,   isDeprecated,   overrides,   printElements
Method from javax.lang.model.util.Elements Detail:
 public List<AnnotationMirror> getAllAnnotationMirrors(Element e)
    Returns all annotations of an element, whether inherited or directly present.
 public List<Element> getAllMembers(TypeElement type)
    Returns all members of a type element, whether inherited or declared directly. For a class the result also includes its constructors, but not local or anonymous classes.

    Note that elements of certain kinds can be isolated using methods in ElementFilter .

 public Name getBinaryName(TypeElement type)
    Returns the binary name of a type element.
 public String getConstantExpression(Object value)
    Returns the text of a constant expression representing a primitive value or a string. The text returned is in a form suitable for representing the value in source code.
 public String getDocComment(Element e)
    Returns the text of the documentation ("Javadoc") comment of an element.
 public Map<ExecutableElement, AnnotationValue> getElementValuesWithDefaults(AnnotationMirror a)
    Returns the values of an annotation's elements, including defaults.
 public Name getName(CharSequence cs)
    Return a name with the same sequence of characters as the argument.
 public PackageElement getPackageElement(CharSequence name)
    Returns a package given its fully qualified name.
 public PackageElement getPackageOf(Element type)
    Returns the package of an element. The package of a package is itself.
 public TypeElement getTypeElement(CharSequence name)
    Returns a type element given its canonical name.
 public boolean hides(Element hider,
    Element hidden)
    Tests whether one type, method, or field hides another.
 public boolean isDeprecated(Element e)
    Returns {@code true} if the element is deprecated, {@code false} otherwise.
 public boolean overrides(ExecutableElement overrider,
    ExecutableElement overridden,
    TypeElement type)
    Tests whether one method, as a member of a given type, overrides another method. When a non-abstract method overrides an abstract one, the former is also said to implement the latter.

    In the simplest and most typical usage, the value of the {@code type} parameter will simply be the class or interface directly enclosing {@code overrider} (the possibly-overriding method). For example, suppose {@code m1} represents the method {@code String.hashCode} and {@code m2} represents {@code Object.hashCode}. We can then ask whether {@code m1} overrides {@code m2} within the class {@code String} (it does):

    {@code assert elements.overrides(m1, m2, elements.getTypeElement("java.lang.String")); }
    A more interesting case can be illustrated by the following example in which a method in type {@code A} does not override a like-named method in type {@code B}:
    {@code class A { public void m() {} } }
    {@code interface B { void m(); } }
    ...
    {@code m1 = ...; // A.m }
    {@code m2 = ...; // B.m }
    {@code assert ! elements.overrides(m1, m2, elements.getTypeElement("A")); }
    When viewed as a member of a third type {@code C}, however, the method in {@code A} does override the one in {@code B}:
    {@code class C extends A implements B {} }
    ...
    {@code assert elements.overrides(m1, m2, elements.getTypeElement("C")); }
 public  void printElements(Writer w,
    Element elements)
    Prints a representation of the elements to the given writer in the specified order. The main purpose of this method is for diagnostics. The exact format of the output is not specified and is subject to change.