org.netbeans.modules.java.source 0.80.1 17

org.netbeans.api.java.source
Class ElementUtilities

java.lang.Object
  extended by org.netbeans.api.java.source.ElementUtilities

public final class ElementUtilities
extends Object


Nested Class Summary
static interface ElementUtilities.ElementAcceptor
          Filter Elements
 
Method Summary
 boolean alreadyDefinedIn(CharSequence name, ExecutableType method, TypeElement enclClass)
          Returns true if a method specified by name and type is defined in a class type.
 Element elementFor(com.sun.javadoc.Doc doc)
          Find a Element corresponding to a given Doc.
 TypeElement enclosingTypeElement(Element element)
          Returns the type element within which this member or constructor is declared.
 List<? extends ExecutableElement> findUnimplementedMethods(TypeElement impl)
          Find all methods in given type and its supertypes, which are not implemented.
static String getBinaryName(TypeElement element)
          Returns a binary name of a type.
 Iterable<? extends TypeElement> getGlobalTypes(ElementUtilities.ElementAcceptor acceptor)
          Return TypeElements: which are imported which are in the same package as the current file which are in the java.lang package
 Element getImplementationOf(ExecutableElement method, TypeElement origin)
          Returns the implementation of a method in class origin; null if none exists.
 Iterable<? extends Element> getLocalMembersAndVars(Scope scope, ElementUtilities.ElementAcceptor acceptor)
          Return members declared in the given scope.
 Iterable<? extends Element> getLocalVars(Scope scope, ElementUtilities.ElementAcceptor acceptor)
          Return variables declared in the given scope.
 Iterable<? extends Element> getMembers(TypeMirror type, ElementUtilities.ElementAcceptor acceptor)
          Returns all members of a type, whether inherited or declared directly.
 ExecutableElement getOverriddenMethod(ExecutableElement method)
          Returns the parent method which the specified method overrides, or null if the method does not override a parent class method.
 boolean implementsMethod(ExecutableElement element)
          Returns true if this element represents a method which implements a method in an interface the parent class implements.
 boolean isLocal(Element element)
          Returns true if the element is declared (directly or indirectly) local to a method or variable initializer.
 boolean isMemberOf(Element e, TypeElement type)
          Returns true if a type element has the specified element as a member.
 boolean isSynthetic(Element element)
          Returns true if the given element is synthetic.
 com.sun.javadoc.Doc javaDocFor(Element element)
          Get javadoc for given element.
 TypeElement outermostTypeElement(Element element)
          The outermost TypeElement which indirectly encloses this element.
 boolean overridesMethod(ExecutableElement element)
          Returns true if this element represents a method which overrides a method in one of its superclasses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

enclosingTypeElement

public TypeElement enclosingTypeElement(Element element)
                                 throws IllegalArgumentException
Returns the type element within which this member or constructor is declared. Does not accept packages If this is the declaration of a top-level type (a non-nested class or interface), returns null.

Returns:
the type declaration within which this member or constructor is declared, or null if there is none
Throws:
IllegalArgumentException - if the provided element is a package element

outermostTypeElement

public TypeElement outermostTypeElement(Element element)
The outermost TypeElement which indirectly encloses this element.


getImplementationOf

public Element getImplementationOf(ExecutableElement method,
                                   TypeElement origin)
Returns the implementation of a method in class origin; null if none exists.


isSynthetic

public boolean isSynthetic(Element element)
Returns true if the given element is synthetic.

Parameters:
element - to check
Returns:
true if and only if the given element is synthetic, false otherwise

overridesMethod

public boolean overridesMethod(ExecutableElement element)
Returns true if this element represents a method which overrides a method in one of its superclasses.


getBinaryName

public static String getBinaryName(TypeElement element)
                            throws IllegalArgumentException
Returns a binary name of a type.

Parameters:
element - for which the binary name should be returned
Returns:
the binary name, see Java Language Specification 13.1
Throws:
IllegalArgumentException - when the element is not a javac element

javaDocFor

public com.sun.javadoc.Doc javaDocFor(Element element)
Get javadoc for given element.


elementFor

public Element elementFor(com.sun.javadoc.Doc doc)
Find a Element corresponding to a given Doc.


getMembers

public Iterable<? extends Element> getMembers(TypeMirror type,
                                              ElementUtilities.ElementAcceptor acceptor)
Returns all members of a type, whether inherited or declared directly. For a class the result also includes its constructors, but not local or anonymous classes.

Parameters:
type - the type being examined
acceptor - to filter the members
Returns:
all members in the type
See Also:
Elements.getAllMembers(javax.lang.model.element.TypeElement)

getLocalMembersAndVars

public Iterable<? extends Element> getLocalMembersAndVars(Scope scope,
                                                          ElementUtilities.ElementAcceptor acceptor)
Return members declared in the given scope.


getLocalVars

public Iterable<? extends Element> getLocalVars(Scope scope,
                                                ElementUtilities.ElementAcceptor acceptor)
Return variables declared in the given scope.


getGlobalTypes

public Iterable<? extends TypeElement> getGlobalTypes(ElementUtilities.ElementAcceptor acceptor)
Return TypeElements:


isLocal

public boolean isLocal(Element element)
Returns true if the element is declared (directly or indirectly) local to a method or variable initializer. Also true for fields of inner classes which are in turn local to a method or variable initializer.


alreadyDefinedIn

public boolean alreadyDefinedIn(CharSequence name,
                                ExecutableType method,
                                TypeElement enclClass)
Returns true if a method specified by name and type is defined in a class type.


isMemberOf

public boolean isMemberOf(Element e,
                          TypeElement type)
Returns true if a type element has the specified element as a member.


getOverriddenMethod

public ExecutableElement getOverriddenMethod(ExecutableElement method)
Returns the parent method which the specified method overrides, or null if the method does not override a parent class method.


implementsMethod

public boolean implementsMethod(ExecutableElement element)
Returns true if this element represents a method which implements a method in an interface the parent class implements.


findUnimplementedMethods

public List<? extends ExecutableElement> findUnimplementedMethods(TypeElement impl)
Find all methods in given type and its supertypes, which are not implemented.

Parameters:
type - to inspect
Returns:
list of all unimplemented methods
Since:
0.20

org.netbeans.modules.java.source 0.80.1 17

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.