java.lang.Object
edu.upc.fib.inlab.imp.kse.logics.logicschema.domain.LevelHierarchy
All Implemented Interfaces:
Iterable<Level>

public class LevelHierarchy extends Object implements Iterable<Level>

This class implements the definition of hierarchical database as defined in "Basis for Deductive Database Systems" by J. W. Lloyd AND R. W. Topor.

A database is called hierarchical if its predicates can be partitioned into levels so that the definitions of level 0 predicates consist solely of base predicates and the bodies of the derived predicates of level j contain only level i predicates, where i < j.

  • Constructor Details

    • LevelHierarchy

      public LevelHierarchy(List<Level> levels)
  • Method Details

    • getNumberOfLevels

      public int getNumberOfLevels()
    • getLevel

      public Level getLevel(int index)
    • getLevelIndexOfPredicate

      public int getLevelIndexOfPredicate(Predicate predicate)
      May throw exception if predicate is not contained in the hierarchy
      Parameters:
      predicate - a non-null predicate
      Returns:
      the index of the predicate
    • getLevelOfPredicate

      public Level getLevelOfPredicate(Predicate predicate)
      May throw exception if predicate is not contained in the hierarchy
      Parameters:
      predicate - a non-null predicate
      Returns:
      the level of the predicate
    • getBasePredicatesLevel

      public Level getBasePredicatesLevel()
      Returns:
      the 0-th level of the hierarchy, which contains the base predicates
    • getDerivedLevels

      public List<Level> getDerivedLevels()
      Returns:
      a list with the levels representing derived predicates (i.e., i-th levels with i > 0)
    • iterator

      public Iterator<Level> iterator()
      Specified by:
      iterator in interface Iterable<Level>
    • forEach

      public void forEach(Consumer<? super Level> action)
      Specified by:
      forEach in interface Iterable<Level>