spoon.reflect.visitor
Class Query

Package class diagram package Query
java.lang.Object
  extended by spoon.reflect.visitor.CtScanner
      extended by spoon.reflect.visitor.Query
All Implemented Interfaces:
CtVisitor

public abstract class Query
extends CtScanner

This class provides some useful methods to retrieve program elements and reference through a CtScanner-based deep search. It uses the Filter and ReferenceFilter facitily to select the right elements or references.


Method Summary
static
<E extends CtElement>
java.util.List<E>
getElements(CtElement rootElement, Filter<E> filter)
          Returns all the program elements that match the filter.
static
<E extends CtElement>
java.util.List<E>
getElements(Factory factory, Filter<E> filter)
          Within a given factory, returns all the program elements that match the filter.
static
<T extends CtReference>
java.util.List<T>
getReferences(CtElement rootElement, ReferenceFilter<T> filter)
          Returns all the program element references that match the filter.
static
<R extends CtReference>
java.util.List<R>
getReferences(Factory factory, ReferenceFilter<R> filter)
          Within a given factory, returns all the program element references that match the filter.
 
Methods inherited from class spoon.reflect.visitor.CtScanner
enter, enterReference, exit, exitReference, scan, scan, scan, scan, scanReferences, visitCtAnnotation, visitCtAnnotationType, visitCtAnonymousExecutable, visitCtArrayAccess, visitCtArrayTypeReference, visitCtAssert, visitCtAssignment, visitCtBinaryOperator, visitCtBlock, visitCtBreak, visitCtCase, visitCtCatch, visitCtClass, visitCtCodeSnippetExpression, visitCtCodeSnippetStatement, visitCtConditional, visitCtConstructor, visitCtContinue, visitCtDo, visitCtEnum, visitCtExecutableReference, visitCtField, visitCtFieldAccess, visitCtFieldReference, visitCtFor, visitCtForEach, visitCtIf, visitCtInterface, visitCtInvocation, visitCtLiteral, visitCtLocalVariable, visitCtLocalVariableReference, visitCtMethod, visitCtNewArray, visitCtNewClass, visitCtOperatorAssignement, visitCtPackage, visitCtPackageReference, visitCtParameter, visitCtParameterReference, visitCtReturn, visitCtStatementList, visitCtSwitch, visitCtSynchronized, visitCtThrow, visitCtTry, visitCtTypeParameter, visitCtTypeParameterReference, visitCtTypeReference, visitCtUnaryOperator, visitCtVariableAccess, visitCtWhile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getElements

public static <E extends CtElement> java.util.List<E> getElements(Factory factory,
                                                                  Filter<E> filter)
Within a given factory, returns all the program elements that match the filter.

Type Parameters:
E - the type of the seeked program elements
Parameters:
factory - the factory that contains the elements where to recursive search on
filter - the filter which defines the matching criteria

getElements

public static <E extends CtElement> java.util.List<E> getElements(CtElement rootElement,
                                                                  Filter<E> filter)
Returns all the program elements that match the filter.

Type Parameters:
E - the type of the seeked program elements
Parameters:
rootElement - the element to start the recursive search on
filter - the filter which defines the matching criteria

getReferences

public static <T extends CtReference> java.util.List<T> getReferences(CtElement rootElement,
                                                                      ReferenceFilter<T> filter)
Returns all the program element references that match the filter.

Type Parameters:
T - the type of the seeked program element references
Parameters:
rootElement - the element to start the recursive search on
filter - the filter which defines the matching criteria

getReferences

public static <R extends CtReference> java.util.List<R> getReferences(Factory factory,
                                                                      ReferenceFilter<R> filter)
Within a given factory, returns all the program element references that match the filter.

Type Parameters:
R - the type of the seeked program element references
Parameters:
factory - the factory that contains the references where to recursive search on
filter - the filter which defines the matching criteria