Class AbstractAtomSet

java.lang.Object
fr.lirmm.graphik.integraal.core.atomset.AbstractAtomSet
All Implemented Interfaces:
AtomSet, CloseableIterable<Atom>
Direct Known Subclasses:
AbstractImmutableAtomSet, AbstractInMemoryAtomSet

public abstract class AbstractAtomSet extends Object implements AtomSet
Partial AtomSet implementation providing common set operations.
Author:
Clément Sipieter (INRIA) clement@6pi.fr
  • Constructor Details

    • AbstractAtomSet

      protected AbstractAtomSet()
      Creates an abstract atom set base implementation.
  • Method Details

    • contains

      public boolean contains(Atom atom) throws AtomSetException
      Description copied from interface: AtomSet
      Returns true if this atom set contains the specified atom.
      Specified by:
      contains in interface AtomSet
      Parameters:
      atom - the atom to search for
      Returns:
      true if this atom set contains the specified atom.
      Throws:
      AtomSetException - if the lookup cannot be performed
    • addAll

      public boolean addAll(CloseableIterator<? extends Atom> it) throws AtomSetException
      Description copied from interface: AtomSet
      Add the specified atom stream to this atom set.
      Specified by:
      addAll in interface AtomSet
      Parameters:
      it - the atom stream to add
      Returns:
      true if this atomset changed as a result of the call.
      Throws:
      AtomSetException - if the atoms cannot be added
    • addAll

      public boolean addAll(AtomSet atomset) throws AtomSetException
      Description copied from interface: AtomSet
      Adds all atoms from the specified atom set.
      Specified by:
      addAll in interface AtomSet
      Parameters:
      atomset - the atom set to add
      Returns:
      true if this atomset changed as a result of the call.
      Throws:
      AtomSetException - if the atoms cannot be added
    • removeAll

      public boolean removeAll(CloseableIterator<? extends Atom> it) throws AtomSetException
      Description copied from interface: AtomSet
      Remove the specified atom stream from this atom set.
      Specified by:
      removeAll in interface AtomSet
      Parameters:
      it - the atom stream to be removed
      Returns:
      true if this atomset changed as a result of the call. In many implementations, the return value is only true since it's time consuming to test the effective modification of the store (e.g. RDBMS, RDF4J...)
      Throws:
      AtomSetException - if the atoms cannot be removed
    • remove

      public boolean remove(Atom atom) throws AtomSetException
      Description copied from interface: AtomSet
      Remove the specified atom from this this atom set.
      Specified by:
      remove in interface AtomSet
      Parameters:
      atom - the atom to be removed
      Returns:
      true if this atom set contained the specified atom.
      Throws:
      AtomSetException - if the atom cannot be removed
    • removeAll

      public boolean removeAll(AtomSet atomset) throws AtomSetException
      Description copied from interface: AtomSet
      Removes all atoms contained in the specified atom set.
      Specified by:
      removeAll in interface AtomSet
      Parameters:
      atomset - the atoms to remove
      Returns:
      true if this atom set changed as a result of the call
      Throws:
      AtomSetException - if the atoms cannot be removed
    • match

      public CloseableIterator<Atom> match(Atom atom) throws AtomSetException
      Description copied from interface: AtomSet
      Returns an iterator over atoms that match predicate and constants from the specified atom.
      Specified by:
      match in interface AtomSet
      Parameters:
      atom - the atom pattern to match
      Returns:
      an iterator over atoms.
      Throws:
      AtomSetException - if the match operation fails
    • getTerms

      public Set<Term> getTerms() throws AtomSetException
      Description copied from interface: AtomSet
      Returns a Set of all terms in this atom set.
      Specified by:
      getTerms in interface AtomSet
      Returns:
      a Set of all terms.
      Throws:
      AtomSetException - if the term collection cannot be computed
    • getVariables

      public Set<Variable> getVariables() throws AtomSetException
      Description copied from interface: AtomSet
      Returns a Set of all variables in this atom set.
      Specified by:
      getVariables in interface AtomSet
      Returns:
      a Set of all variables.
      Throws:
      AtomSetException - if the variable collection cannot be computed
    • getConstants

      public Set<Constant> getConstants() throws AtomSetException
      Description copied from interface: AtomSet
      Returns a Set of all constants in this atom set.
      Specified by:
      getConstants in interface AtomSet
      Returns:
      a Set of all constants.
      Throws:
      AtomSetException - if the constant collection cannot be computed
    • getLiterals

      public Set<Literal> getLiterals() throws AtomSetException
      Description copied from interface: AtomSet
      Returns a Set of all literals in this atom set.
      Specified by:
      getLiterals in interface AtomSet
      Returns:
      a Set of all literals.
      Throws:
      AtomSetException - if the literal collection cannot be computed
    • variablesIterator

      public CloseableIterator<Variable> variablesIterator() throws AtomSetException
      Description copied from interface: AtomSet
      Returns an iterator over all variables in this atom set. Each term is iterated only once time.
      Specified by:
      variablesIterator in interface AtomSet
      Returns:
      an iterator over all variables.
      Throws:
      AtomSetException - if the iterator cannot be produced
    • constantsIterator

      public CloseableIterator<Constant> constantsIterator() throws AtomSetException
      Description copied from interface: AtomSet
      Returns an iterator over all constants in this atom set. Each term is iterated only once time.
      Specified by:
      constantsIterator in interface AtomSet
      Returns:
      an iterator over all constants.
      Throws:
      AtomSetException - if the iterator cannot be produced
    • literalsIterator

      public CloseableIterator<Literal> literalsIterator() throws AtomSetException
      Description copied from interface: AtomSet
      Returns an iterator over all literals in this atom set. Each term is iterated only once time.
      Specified by:
      literalsIterator in interface AtomSet
      Returns:
      an iterator over all literals.
      Throws:
      AtomSetException - if the iterator cannot be produced
    • getTerms

      @Deprecated public Set<Term> getTerms(Term.Type type) throws AtomSetException
      Deprecated.
      Description copied from interface: AtomSet
      This method is deprecated since 1.3, use AtomSet.getVariables(), AtomSet.getConstants() or AtomSet.getLiterals() instead.

      Returns a Set of all terms of the specified type in this atom set.
      Specified by:
      getTerms in interface AtomSet
      Parameters:
      type - the term type to filter on
      Returns:
      a collection of all terms of the specified type in this atom set.
      Throws:
      AtomSetException - if the term collection cannot be computed
    • getPredicates

      public Set<Predicate> getPredicates() throws AtomSetException
      Description copied from interface: AtomSet
      Returns a Set of all predicates in this atom set.
      Specified by:
      getPredicates in interface AtomSet
      Returns:
      a Set of all predicates.
      Throws:
      AtomSetException - if the predicate collection cannot be computed
    • isSubSetOf

      @Deprecated public boolean isSubSetOf(AtomSet atomset) throws AtomSetException
      Deprecated.
      Description copied from interface: AtomSet
      Use AtomSets.contains instead. Check if all atoms of this AtomSet are also contained in the specified AtomSet.
      Specified by:
      isSubSetOf in interface AtomSet
      Parameters:
      atomset - the candidate superset
      Returns:
      true if all atoms of this AtomSet are also contained in the specified atomset, false otherwise.
      Throws:
      AtomSetException - if the subset test cannot be performed
    • size

      public int size() throws AtomSetException
      This default implementation should be overriden, it is convenient for in memory set, but will be inefficient in some case.
      Specified by:
      size in interface AtomSet
      Returns:
      the number of atoms in the set
      Throws:
      AtomSetException - if the size cannot be computed
      See Also:
    • isEmpty

      public boolean isEmpty() throws AtomSetException
      Description copied from interface: AtomSet
      Returns whether this atom set contains no atom.
      Specified by:
      isEmpty in interface AtomSet
      Returns:
      true if this atom set is empty, false otherwise.
      Throws:
      AtomSetException - if the emptiness check cannot be performed
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(AtomSet other)
      Compares this atom set with another one by checking mutual containment.
      Parameters:
      other - the other atom set to compare with
      Returns:
      true if both atom sets contain the same atoms
    • toString

      public String toString()
      Overrides:
      toString in class Object