Class TaxonomyImpl<T>

  • Type Parameters:
    T - kind of Node
    All Implemented Interfaces:
    Taxonomy<T>, openllet.shared.tools.Logging

    public class TaxonomyImpl<T>
    extends java.lang.Object
    implements Taxonomy<T>
    Since:
    2.6.0
    • Field Detail

      • _logger

        public static final java.util.logging.Logger _logger
    • Constructor Detail

      • TaxonomyImpl

        public TaxonomyImpl()
      • TaxonomyImpl

        public TaxonomyImpl​(java.util.Collection<T> elements,
                            T top,
                            T bottom)
    • Method Detail

      • getLogger

        public java.util.logging.Logger getLogger()
        Specified by:
        getLogger in interface openllet.shared.tools.Logging
      • getDepth

        public short getDepth()
        Specified by:
        getDepth in interface Taxonomy<T>
      • setDepth

        public void setDepth​(short depth)
        Specified by:
        setDepth in interface Taxonomy<T>
      • setTotalBranching

        public void setTotalBranching​(int totalBranching)
        Specified by:
        setTotalBranching in interface Taxonomy<T>
      • datumEquivalentsPair

        public java.util.Iterator<java.util.Map.Entry<java.util.Set<T>,​java.lang.Object>> datumEquivalentsPair​(TaxonomyUtils.TaxonomyKey key)
        Iterate over nodes in taxonomy (no specific order)returning pair of equivalence set and datum associated with key for each. Useful, e.g., to collect equivalence sets matching some condition on the datum (as in all classes which have a particular instances)
        Specified by:
        datumEquivalentsPair in interface Taxonomy<T>
        Parameters:
        key - key associated with datum returned
        Returns:
        iterator over equivalence set, datum pairs
      • depthFirstDatumOnly

        public java.util.Iterator<java.lang.Object> depthFirstDatumOnly​(T t,
                                                                        TaxonomyUtils.TaxonomyKey key)
        Iterate down taxonomy in a _depth first traversal, beginning with class c, returning only datum associated with _key for each. Useful, e.g., to collect datum values in a transitive closure (as in all instances of a class).
        Specified by:
        depthFirstDatumOnly in interface Taxonomy<T>
        Parameters:
        t - starting location in taxonomy
        key - _key associated with datum returned
        Returns:
        datum iterator
      • getSubs

        public java.util.Set<java.util.Set<T>> getSubs​(T t,
                                                       boolean direct)
        Returns the (named) subclasses of class c. Depending on the second parameter the resulting list will include either all subclasses or only the direct subclasses. A class d is a direct subclass of c iff
        1. d is subclass of c
        2. there is no other class x different from c and d such that x is subclass of c and d is subclass of x
        The class c itself is not included in the list but all the other classes that are sameAs c are put into the list. Also note that the returned list will always have at least one element. The list will either include one other concept from the hierarchy or the BOTTOM concept if no other class is subsumed by c. By definition BOTTOM concept is subclass of every concept.
        Specified by:
        getSubs in interface Taxonomy<T>
        Parameters:
        t - Class whose subclasses are found
        direct - If true return only direct subclasses elese return all the subclasses
        Returns:
        A set of sets, where each set in the collection represents an equivalence class. The elements of the inner class are ATermAppl objects.
      • getSupers

        public java.util.Set<java.util.Set<T>> getSupers​(T t)
        Returns all the superclasses (implicitly or explicitly defined) of class c. The class c itself is not included in the list. but all the other classes that are sameAs c are put into the list. Also note that the returned list will always have at least one element, that is TOP concept. By definition TOP concept is superclass of every concept. This function is equivalent to calling getSuperClasses(c, true).
        Specified by:
        getSupers in interface Taxonomy<T>
        Parameters:
        t - class whose superclasses are returned
        Returns:
        A set of sets, where each set in the collection represents an equivalence class. The elements of the inner class are ATermAppl objects.
      • getSupers

        public java.util.Set<java.util.Set<T>> getSupers​(T t,
                                                         boolean direct)
        Returns the (named) superclasses of class c. Depending on the second parameter the resulting list will include either all or only the direct superclasses. A class d is a direct superclass of c iff
        1. d is superclass of c
        2. there is no other class x such that x is superclass of c and d is superclass of x
        The class c itself is not included in the list but all the other classes that are sameAs c are put into the list. Also note that the returned list will always have at least one element. The list will either include one other concept from the hierarchy or the TOP concept if no other class subsumes c. By definition TOP concept is superclass of every concept.
        Specified by:
        getSupers in interface Taxonomy<T>
        Parameters:
        t - Class whose subclasses are found
        direct - If true return all the superclasses else return only direct superclasses
        Returns:
        A set of sets, where each set in the collection represents an equivalence class. The elements of the inner class are ATermAppl objects.
      • supers

        public java.util.stream.Stream<java.util.Set<T>> supers​(T t,
                                                                boolean direct)
        Specified by:
        supers in interface Taxonomy<T>
      • removeCycles

        public void removeCycles​(TaxonomyNode<T> node)
        Walk through the super _nodes of the given _node and when a cycle is detected merge all the _nodes in that path
        Specified by:
        removeCycles in interface Taxonomy<T>