org.netbeans.api.java.source
public final class ClassIndex extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ClassIndex.NameKind
Encodes a type of the name kind used by
getDeclaredTypes(java.lang.String, org.netbeans.api.java.source.ClassIndex.NameKind, java.util.Set method. |
static class |
ClassIndex.SearchKind
Encodes a reference type,
used by
getElements(org.netbeans.api.java.source.ElementHandle and getResources(org.netbeans.api.java.source.ElementHandle
to restrict the search. |
static class |
ClassIndex.SearchScope
Scope used by
ClassIndex to search in |
Modifier and Type | Method and Description |
---|---|
void |
addClassIndexListener(ClassIndexListener listener)
Adds an
ClassIndexListener . |
Set<ElementHandle<TypeElement>> |
getDeclaredTypes(String name,
ClassIndex.NameKind kind,
Set<ClassIndex.SearchScope> scope)
Returns
ElementHandle s for all declared types in given classpath corresponding to the name. |
Set<ElementHandle<TypeElement>> |
getElements(ElementHandle<TypeElement> element,
Set<ClassIndex.SearchKind> searchKind,
Set<ClassIndex.SearchScope> scope)
Returns a set of
ElementHandle s containing reference(s) to given element. |
Set<String> |
getPackageNames(String prefix,
boolean directOnly,
Set<ClassIndex.SearchScope> scope)
Returns names af all packages in given classpath starting with prefix.
|
Set<FileObject> |
getResources(ElementHandle<TypeElement> element,
Set<ClassIndex.SearchKind> searchKind,
Set<ClassIndex.SearchScope> scope)
Returns a set of source files containing reference(s) to given element.
|
void |
removeClassIndexListener(ClassIndexListener listener)
Removes an
ClassIndexListener . |
public void addClassIndexListener(@NonNull ClassIndexListener listener)
ClassIndexListener
. The listener is notified about the
changes of declared types in this ClassIndex
listener
- to be addedpublic void removeClassIndexListener(@NonNull ClassIndexListener listener)
ClassIndexListener
. The listener is notified about the
changes of declared types in this ClassIndex
listener
- to be removed@NullUnknown public Set<ElementHandle<TypeElement>> getElements(@NonNull ElementHandle<TypeElement> element, @NonNull Set<ClassIndex.SearchKind> searchKind, @NonNull Set<ClassIndex.SearchScope> scope)
ElementHandle
s containing reference(s) to given element.element
- for which usages should be foundsearchKind
- type of reference, ClassIndex.SearchKind
scope
- to search in ClassIndex.SearchScope
ElementHandle
s containing the reference(s)
It may return null when the caller is a CancellableTask<CompilationInfo> and is cancelled
inside call of this method.@NullUnknown public Set<FileObject> getResources(@NonNull ElementHandle<TypeElement> element, @NonNull Set<ClassIndex.SearchKind> searchKind, @NonNull Set<ClassIndex.SearchScope> scope)
element
- for which usages should be foundsearchKind
- type of reference, ClassIndex.SearchKind
scope
- to search in ClassIndex.SearchScope
FileObject
s containing the reference(s)
It may return null when the caller is a CancellableTask<CompilationInfo> and is cancelled
inside call of this method.@NullUnknown public Set<ElementHandle<TypeElement>> getDeclaredTypes(@NonNull String name, @NonNull ClassIndex.NameKind kind, @NonNull Set<ClassIndex.SearchScope> scope)
ElementHandle
s for all declared types in given classpath corresponding to the name.name
- case sensitive prefix, case insensitive prefix, exact simple name,
camel case or regular expression depending on the kind parameter.kind
- of the name ClassIndex.NameKind
scope
- to search in ClassIndex.SearchScope
@NullUnknown public Set<String> getPackageNames(@NonNull String prefix, boolean directOnly, @NonNull Set<ClassIndex.SearchScope> scope)
prefix
- of the package namedirectOnly
- if true treats the packages as folders and returns only
the nearest component of the package.scope
- to search in ClassIndex.SearchScope
Built on March 18 2014. | Portions Copyright 1997-2014 Sun Microsystems, Inc. All rights reserved.