Package org.revapi.base
Class BaseEagerLoadingArchiveAnalyzer<F extends BaseElementForest<E>,E extends BaseElement<E>>
- java.lang.Object
-
- org.revapi.base.BaseArchiveAnalyzer<F,E>
-
- org.revapi.base.BaseEagerLoadingArchiveAnalyzer<F,E>
-
- Type Parameters:
E
- the parent type of all elements produced by the API analyzer
- All Implemented Interfaces:
ArchiveAnalyzer<E>
- Direct Known Subclasses:
ZipArchiveAnalyzer
public abstract class BaseEagerLoadingArchiveAnalyzer<F extends BaseElementForest<E>,E extends BaseElement<E>> extends BaseArchiveAnalyzer<F,E>
A base class for archive analyzers that need to load all the elements in an archive eagerly.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
BaseEagerLoadingArchiveAnalyzer.FullForestContext
This context object is used to "remember" all the elements that were created during parsing of an archive.
-
Constructor Summary
Constructors Constructor Description BaseEagerLoadingArchiveAnalyzer(ApiAnalyzer<E> apiAnalyzer, API api, boolean processSupplementaryArchives)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Set<E>
createElements(Archive archive)
Scans the archive and returns the elements within.protected Stream<E>
discoverElements(Object context, E parent)
Discovers new elements under the given parent element.protected Stream<E>
discoverRoots(Object context)
Discovers all the root elements in the relevant archives of the API.protected BaseEagerLoadingArchiveAnalyzer.FullForestContext
preAnalyze()
Called as the first thing inBaseArchiveAnalyzer.analyze(TreeFilter)
.-
Methods inherited from class org.revapi.base.BaseArchiveAnalyzer
addTo, analyze, getApi, getApiAnalyzer, newElementForest, postAnalyze, prune
-
-
-
-
Constructor Detail
-
BaseEagerLoadingArchiveAnalyzer
public BaseEagerLoadingArchiveAnalyzer(ApiAnalyzer<E> apiAnalyzer, API api, boolean processSupplementaryArchives)
-
-
Method Detail
-
preAnalyze
protected BaseEagerLoadingArchiveAnalyzer.FullForestContext preAnalyze()
Called as the first thing inBaseArchiveAnalyzer.analyze(TreeFilter)
. Can be used by the subclasses to initialize themselves for the analysis. This implementation eagerly analyzes all the archives and remembers the results so that the final tree can be computed.- Overrides:
preAnalyze
in classBaseArchiveAnalyzer<F extends BaseElementForest<E>,E extends BaseElement<E>>
- Returns:
- a context object with the results of the analysis
- See Also:
BaseArchiveAnalyzer.postAnalyze(Object)
-
discoverRoots
protected Stream<E> discoverRoots(Object context)
Discovers all the root elements in the relevant archives of the API. What is a relevant archive is determined by the implementor. This is called afterBaseArchiveAnalyzer.preAnalyze()
and before allBaseArchiveAnalyzer.discoverElements(Object, Element)
calls.This method assumes the context is a
BaseEagerLoadingArchiveAnalyzer.FullForestContext
and uses it to return the recorded roots.- Specified by:
discoverRoots
in classBaseArchiveAnalyzer<F extends BaseElementForest<E>,E extends BaseElement<E>>
- Parameters:
context
- the full forest context- Returns:
- the recorded roots
-
discoverElements
protected Stream<E> discoverElements(Object context, E parent)
Discovers new elements under the given parent element.This method assumes the context is a
BaseEagerLoadingArchiveAnalyzer.FullForestContext
and uses it to return the recorded children of the provided element.- Specified by:
discoverElements
in classBaseArchiveAnalyzer<F extends BaseElementForest<E>,E extends BaseElement<E>>
- Parameters:
context
- the full forest contextparent
- the parent to discover children of- Returns:
- the recorded children of the element
-
createElements
protected abstract Set<E> createElements(Archive archive)
Scans the archive and returns the elements within. Each of the returned elements is supposed to have a fully realized hierarchy of children.- Parameters:
archive
- the archive to analyze- Returns:
- a set of root elements found in the archive (with children initialized, too)
-
-