Class DefaultOntology

java.lang.Object
fr.lirmm.graphik.integraal.core.ruleset.DefaultOntology
All Implemented Interfaces:
ImmutableRuleSet, Ontology, RuleSet, Iterable<Rule>

public class DefaultOntology extends Object implements Ontology
Default ontology implementation backed by maps keyed by rule labels.
Author:
Clément Sipieter (INRIA) <clement@6pi.fr>
  • Constructor Details

    • DefaultOntology

      public DefaultOntology()
      Creates an empty ontology.
    • DefaultOntology

      public DefaultOntology(RuleSet rules)
      Creates an ontology initialized with the rules from the provided rule set.
      Parameters:
      rules - the rules to import
    • DefaultOntology

      public DefaultOntology(CloseableIterator<Object> parser) throws RuleSetException
      Creates an ontology from parser output filtered down to rules.
      Parameters:
      parser - the parser iterator
      Throws:
      RuleSetException - if the parser output cannot be consumed as rules
  • Method Details

    • getRuleNames

      public Set<String> getRuleNames()
      Description copied from interface: Ontology
      Returns the names of the rules stored in this ontology.
      Specified by:
      getRuleNames in interface Ontology
      Returns:
      the rule names
    • getRule

      public Rule getRule(String name)
      Description copied from interface: Ontology
      Retrieves a rule by its name.
      Specified by:
      getRule in interface Ontology
      Parameters:
      name - the rule name
      Returns:
      the matching rule, or null if none exists
    • getNegativeConstraintNames

      public Set<String> getNegativeConstraintNames()
      Description copied from interface: Ontology
      Returns the names of the negative constraints stored in this ontology.
      Specified by:
      getNegativeConstraintNames in interface Ontology
      Returns:
      the negative constraint names
    • getNegativeConstraint

      public NegativeConstraint getNegativeConstraint(String name)
      Description copied from interface: Ontology
      Retrieves a negative constraint by its name.
      Specified by:
      getNegativeConstraint in interface Ontology
      Parameters:
      name - the negative constraint name
      Returns:
      the matching negative constraint, or null if none exists
    • add

      public boolean add(Rule rule)
      Description copied from interface: RuleSet
      Adds a rule to this set.
      Specified by:
      add in interface Ontology
      Specified by:
      add in interface RuleSet
      Parameters:
      rule - the rule to add
      Returns:
      true if this set changed as a result of the call
    • addAll

      public boolean addAll(Iterator<Rule> ruleIterator)
      Description copied from interface: RuleSet
      Adds all rules provided by the specified iterator.
      Specified by:
      addAll in interface Ontology
      Specified by:
      addAll in interface RuleSet
      Parameters:
      ruleIterator - the rules to add
      Returns:
      true if this set changed as a result of the call
    • addAll

      public boolean addAll(CloseableIterator<Rule> ruleIterator) throws RuleSetException
      Description copied from interface: RuleSet
      Adds all rules provided by the specified closeable iterator.
      Specified by:
      addAll in interface Ontology
      Specified by:
      addAll in interface RuleSet
      Parameters:
      ruleIterator - the rules to add
      Returns:
      true if this set changed as a result of the call
      Throws:
      RuleSetException - if the iteration fails
    • remove

      public boolean remove(Rule rule)
      Description copied from interface: RuleSet
      Removes a rule from this set.
      Specified by:
      remove in interface Ontology
      Specified by:
      remove in interface RuleSet
      Parameters:
      rule - the rule to remove
      Returns:
      true if this set changed as a result of the call
    • removeAll

      public boolean removeAll(Iterator<Rule> ruleIterator)
      Description copied from interface: RuleSet
      Removes all rules provided by the specified iterator.
      Specified by:
      removeAll in interface Ontology
      Specified by:
      removeAll in interface RuleSet
      Parameters:
      ruleIterator - the rules to remove
      Returns:
      true if this set changed as a result of the call
    • removeAll

      public boolean removeAll(CloseableIterator<Rule> ruleIterator) throws RuleSetException
      Description copied from interface: RuleSet
      Removes all rules provided by the specified closeable iterator.
      Specified by:
      removeAll in interface Ontology
      Specified by:
      removeAll in interface RuleSet
      Parameters:
      ruleIterator - the rules to remove
      Returns:
      true if this set changed as a result of the call
      Throws:
      RuleSetException - if the iteration fails
    • contains

      public boolean contains(Rule rule)
      Description copied from interface: ImmutableRuleSet
      Returns whether the specified rule is present in this set.
      Specified by:
      contains in interface ImmutableRuleSet
      Specified by:
      contains in interface Ontology
      Specified by:
      contains in interface RuleSet
      Parameters:
      rule - the rule to search for
      Returns:
      true if the rule is present
    • size

      public int size()
      Description copied from interface: ImmutableRuleSet
      Returns the number of rules contained in this set.
      Specified by:
      size in interface ImmutableRuleSet
      Specified by:
      size in interface Ontology
      Specified by:
      size in interface RuleSet
      Returns:
      the number of rules contained in this set.
    • iterator

      public Iterator<Rule> iterator()
      Specified by:
      iterator in interface ImmutableRuleSet
      Specified by:
      iterator in interface Iterable<Rule>
      Specified by:
      iterator in interface Ontology
      Specified by:
      iterator in interface RuleSet
    • getVocabulary

      public Set<Predicate> getVocabulary()
      Description copied from interface: Ontology
      Returns the vocabulary used by this ontology.
      Specified by:
      getVocabulary in interface Ontology
      Returns:
      a set of all predicates related to this ontology
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: ImmutableRuleSet
      Returns whether this set contains no rule.
      Specified by:
      isEmpty in interface ImmutableRuleSet
      Specified by:
      isEmpty in interface RuleSet
      Returns:
      true if this set is empty