Package ghidra.util.classfinder
Class ClassSearcher
- java.lang.Object
-
- ghidra.util.classfinder.ClassSearcher
-
public class ClassSearcher extends java.lang.ObjectThis class is a collection of static methods used to discover classes that implement a particular interface or extend a particular base class.Warning: Using the search feature of this class will trigger other classes to be loaded. Thus, clients should not make calls to this class inside of static initializer blocks
Note: if your application is not using a module structure for its release build, then your application must create the following file, with the required entries, in order to find extension points:
<install dir>/data/ExtensionPoint.manifest
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSEARCH_ALL_JARS_PROPERTY
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidaddChangeListener(javax.swing.event.ChangeListener l)Add a change listener that will be notified when the classpath is searched for new classes.static <T> java.util.List<java.lang.Class<? extends T>>getClasses(java.lang.Class<T> c)Getpriority-sortedclasses that implement or derive from the given classstatic <T> java.util.List<java.lang.Class<? extends T>>getClasses(java.lang.Class<T> c, java.util.function.Predicate<java.lang.Class<? extends T>> classFilter)Getpriority-sortedclasses that implement or derive from the given classstatic <T> java.util.List<T>getInstances(java.lang.Class<T> c)static <T> java.util.List<T>getInstances(java.lang.Class<T> c, ClassFilter filter)Getpriority-sortedclasses instances that implement or derive from the given classstatic voidremoveChangeListener(javax.swing.event.ChangeListener l)Remove the change listenerstatic voidsearch(boolean forceRefresh, TaskMonitor monitor)Deprecated, for removal: This API element is subject to removal in a future version.usesearch(TaskMonitor)insteadstatic voidsearch(TaskMonitor monitor)Searches the classpath and updates the list of available classes which satisfy the class filter.
-
-
-
Field Detail
-
SEARCH_ALL_JARS_PROPERTY
public static final java.lang.String SEARCH_ALL_JARS_PROPERTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getClasses
public static <T> java.util.List<java.lang.Class<? extends T>> getClasses(java.lang.Class<T> c)
Getpriority-sortedclasses that implement or derive from the given class- Parameters:
c- the filter class- Returns:
- set of classes that implement or extend T
-
getClasses
public static <T> java.util.List<java.lang.Class<? extends T>> getClasses(java.lang.Class<T> c, java.util.function.Predicate<java.lang.Class<? extends T>> classFilter)Getpriority-sortedclasses that implement or derive from the given class- Parameters:
c- the filter classclassFilter- A Predicate that tests class objects (that are already of type T) for further filtering,nullis equivalent to "return true"- Returns:
priority-sortedlist of classes that implement or extend T and pass the filtering test performed by the predicate
-
getInstances
public static <T> java.util.List<T> getInstances(java.lang.Class<T> c)
-
getInstances
public static <T> java.util.List<T> getInstances(java.lang.Class<T> c, ClassFilter filter)Getpriority-sortedclasses instances that implement or derive from the given class- Parameters:
c- the filter classfilter- A Predicate that tests class objects (that are already of type T) for further filtering,nullis equivalent to "return true"- Returns:
priority-sortedlist of classes instances that implement or extend T and pass the filtering test performed by the predicate
-
addChangeListener
public static void addChangeListener(javax.swing.event.ChangeListener l)
Add a change listener that will be notified when the classpath is searched for new classes.Note: The listener list is implemented using WeakReferences. Therefore, the caller must maintain a handle to the listener being added, or else it will be garbage collected and never called.
- Parameters:
l- the listener to add
-
removeChangeListener
public static void removeChangeListener(javax.swing.event.ChangeListener l)
Remove the change listener- Parameters:
l- the listener to remove
-
search
@Deprecated(forRemoval=true, since="10.1") public static void search(boolean forceRefresh, TaskMonitor monitor) throws CancelledExceptionDeprecated, for removal: This API element is subject to removal in a future version.usesearch(TaskMonitor)insteadThis deprecated method is now simply a pass-through forsearch(TaskMonitor).- Parameters:
forceRefresh- ignoredmonitor- the task monitor- Throws:
CancelledException- if cancelled
-
search
public static void search(TaskMonitor monitor) throws CancelledException
Searches the classpath and updates the list of available classes which satisfy the class filter. Classes which data types, and language providers. When the search completes and was not cancelled, the change listeners are notified.- Parameters:
monitor- the progress monitor for the search.- Throws:
CancelledException- if the operation is cancelled
-
-