cz.cuni.pogamut.posh.explorer
Class ClassCrawler

Package class diagram package ClassCrawler
java.lang.Object
  extended by cz.cuni.pogamut.posh.explorer.Crawler<T>
      extended by cz.cuni.pogamut.posh.explorer.ClassCrawler

public abstract class ClassCrawler
extends Crawler<T>

Crawl through all class and find the ones that fit the filter. This crawler doesn't invoke any extra threads, all crawling is done in the crawl() method. The crawler looks for all classes that are subtypes/implement class/interface with specified fully qualified name.

Author:
Honza

Field Summary
protected  String fqn
           
protected  Set<org.netbeans.api.project.Project> projects
          Project we will crawl over, source of classpath.
 
Fields inherited from class cz.cuni.pogamut.posh.explorer.Crawler
cache, cacheUm, listeners, listenersUm
 
Constructor Summary
protected ClassCrawler(org.netbeans.api.project.Project project, String fqn)
          Create new crawler that will go through project and find all classes that are either subclass or implement class/interface with fqn.
protected ClassCrawler(Set<org.netbeans.api.project.Project> projects, String fqn)
          Create new crawler that will go through all projects and find all classes that are either subclass or implement class/interface with fqn.
 
Method Summary
 void crawl()
          Start crawling for the primitives.
 void die()
          Terminate the crawler, once this is called, crawler should die and liseners shouldn't recieve any further messages.
protected  Set<org.netbeans.api.java.source.ElementHandle<TypeElement>> getAllSubtypes(org.netbeans.api.java.source.ClassIndex ci, org.netbeans.api.java.source.ElementHandle<TypeElement> ancestorTE)
          Get all subtypes (either implemetors or subtypes) of certain TypeElement in the ClassIndex.
protected  org.netbeans.api.java.source.ClasspathInfo getClasspathInfo(org.netbeans.api.project.Project project)
          Get ClasspathInfo for project.
protected  Set<org.netbeans.api.java.source.ElementHandle<TypeElement>> getDirectSubtypes(org.netbeans.api.java.source.ClassIndex ci, org.netbeans.api.java.source.ElementHandle<TypeElement> ancestor)
          Find all types that directly (=not transitively) implement ancestor type (extends/implemet).
protected  String getSimpleNameFromFQN(String fqn)
          Get simple name from fqn of class
protected  org.netbeans.api.java.source.ElementHandle<TypeElement> getTypeOfClass(org.netbeans.api.java.source.ClassIndex ci, String classfqn)
          Find the ElementHandle of TypeElement of clazz in the passed ClassIndex.
 
Methods inherited from class cz.cuni.pogamut.posh.explorer.Crawler
addListener, getDescription, getName, notifyCrawledData, notifyFinished, notifyStarted, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

projects

protected final Set<org.netbeans.api.project.Project> projects
Project we will crawl over, source of classpath.


fqn

protected final String fqn
Constructor Detail

ClassCrawler

protected ClassCrawler(org.netbeans.api.project.Project project,
                       String fqn)
Create new crawler that will go through project and find all classes that are either subclass or implement class/interface with fqn.

Parameters:
project - project in which (sources and dependencies) we will crawl
fqn - Fully qualified name of class/interface that is ancestor for all seeked classes.

ClassCrawler

protected ClassCrawler(Set<org.netbeans.api.project.Project> projects,
                       String fqn)
Create new crawler that will go through all projects and find all classes that are either subclass or implement class/interface with fqn.

Parameters:
projects - All projects in which (sources and dependencies) we will crawl
fqn - Fully qualified name of class/interface that is ancestor for all seeked classes.
Method Detail

crawl

public final void crawl()
Description copied from class: Crawler
Start crawling for the primitives. All you need to do is to call this method, it will notify listeners about progress and in due time it terminates itself (no need for programmer to take care about that).
DO NOT CALL TWICE, create new crawler in you need to.
Once crawling starts, it will notify listeners about progress(using CrawlerListener).
If you have to stop the crawling prematurely, use {@link Crawler#die() }.

Specified by:
crawl in class Crawler<cz.cuni.amis.pogamut.sposh.executor.PrimitiveData>
See Also:
CrawlerListener

die

public void die()
Description copied from class: Crawler
Terminate the crawler, once this is called, crawler should die and liseners shouldn't recieve any further messages. This will notify all listeners with CrawlerListener#finished(boolean) .

Specified by:
die in class Crawler<cz.cuni.amis.pogamut.sposh.executor.PrimitiveData>

getClasspathInfo

protected final org.netbeans.api.java.source.ClasspathInfo getClasspathInfo(org.netbeans.api.project.Project project)
Get ClasspathInfo for project. In most cases, you are interested in ClassIndex you can retrieve using ClasspathInfo.getClassIndex(). If you need to owner project of some file, use FileOwnerQuery.

Parameters:
project - What project should I use to determine classpath?
Returns:
classpath for project that contains ClassPath.BOOT, ClassPath.COMPILE, and ClassPath.SOURCE

getSimpleNameFromFQN

protected final String getSimpleNameFromFQN(String fqn)
Get simple name from fqn of class

Parameters:
fqn - fully qualified name of some class, like (like java.lang.String)
Returns:
simple name, like String

getTypeOfClass

protected final org.netbeans.api.java.source.ElementHandle<TypeElement> getTypeOfClass(org.netbeans.api.java.source.ClassIndex ci,
                                                                                       String classfqn)
Find the ElementHandle of TypeElement of clazz in the passed ClassIndex. Look in boot, compile and sources.

Parameters:
ci - ClassIndex in which we are looking.
clazz - class for which TypeElement we are looking
Returns:
null if no such EH found in ci otherwise first found class with same fqn.

getDirectSubtypes

protected final Set<org.netbeans.api.java.source.ElementHandle<TypeElement>> getDirectSubtypes(org.netbeans.api.java.source.ClassIndex ci,
                                                                                               org.netbeans.api.java.source.ElementHandle<TypeElement> ancestor)
Find all types that directly (=not transitively) implement ancestor type (extends/implemet). Search in boot, compile and sources.

Parameters:
ci - classindedx in which we are looking
ancestor - ancestor type
Returns:
set of implementors

getAllSubtypes

protected final Set<org.netbeans.api.java.source.ElementHandle<TypeElement>> getAllSubtypes(org.netbeans.api.java.source.ClassIndex ci,
                                                                                            org.netbeans.api.java.source.ElementHandle<TypeElement> ancestorTE)
Get all subtypes (either implemetors or subtypes) of certain TypeElement in the ClassIndex. I.e. find all types that either (transitively) extend or implement the ancestor.

Parameters:
ci - ClassIndex in which we are loooking
ancestorTE - type element that is the ancestor.
Returns:
set of all types that extend / implement ancestor


Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.