Class BaseArchiveAnalyzer<F extends BaseElementForest<E>,​E extends Element<E>>

    • Constructor Detail

      • BaseArchiveAnalyzer

        public BaseArchiveAnalyzer​(ApiAnalyzer<E> apiAnalyzer,
                                   API api)
    • Method Detail

      • analyze

        public F analyze​(TreeFilter<E> filter)
        Description copied from interface: ArchiveAnalyzer
        Analyzes the API archives and filters the forest using the provided filter.

        This produces a preliminary forest which can be too "wide" because of Ternary.UNDECIDED elements or non-local relationships between elements. Once this method returns the preliminary forest, the callers should also call the ArchiveAnalyzer.prune(ElementForest) method to obtain a forest that is truly minimal.

        Specified by:
        analyze in interface ArchiveAnalyzer<F extends BaseElementForest<E>>
        Parameters:
        filter - the filter to use to filter out unwanted elements from the forest
        Returns:
        the preliminary element forest that should be pruned before analysis
      • prune

        public void prune​(ElementForest<E> forest)
        Description copied from interface: ArchiveAnalyzer
        Once all the filtering on the element forest is done, the analyzer is allowed one final "pass" through the forest to remove any elements that should not be there any longer.
        Specified by:
        prune in interface ArchiveAnalyzer<F extends BaseElementForest<E>>
        Parameters:
        forest - the forest to prune
      • newElementForest

        protected abstract F newElementForest()
        Creates a new empty element forest of given type.
      • preAnalyze

        @Nullable
        protected Object preAnalyze()
        Called as the first thing in analyze(TreeFilter). Can be used by the subclasses to initialize themselves for the analysis.
        Returns:
        a context object that can be used by the other methods or null if no such thing is needed.
        See Also:
        postAnalyze(Object)
      • discoverRoots

        protected abstract Stream<E> discoverRoots​(@Nullable
                                                   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 after preAnalyze() and before all discoverElements(Object, Element) calls.
        Parameters:
        context - the optional context obtained from the preAnalyze() method
        Returns:
        a stream of elements
      • discoverElements

        protected abstract Stream<E> discoverElements​(@Nullable
                                                      Object context,
                                                      E parent)
        Discovers new elements under the given parent element.
        Parameters:
        parent - the parent to discover children of
        Returns:
        a stream of elements
      • addTo

        protected final void addTo​(@Nullable
                                   Object context,
                                   TreeFilter<E> filter,
                                   SortedSet<E> siblings,
                                   E element)
        Adds an element to the set of its potential siblings. This assumes the siblings are part of a BaseElementForest and therefore automatically update the parent-child relationships.

        This method can be used to establish the right hierarchy of elements in the element forest.

        Parameters:
        filter - the filter that the element needs to match to be added to the siblings
        siblings - the set of siblings
        element - the element to potentially add to siblings