aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/uk/ac/ox/cs/rsacomb/util/DataFactory.scala
blob: 863122ea5ba5f43a21abeeedbdfad331ff1c2b1b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package uk.ac.ox.cs.rsacomb.util

import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.OWLClass
import tech.oxfordsemantic.jrdfox.logic.expression.Variable

/** Simple fresh variable/class generator */
object DataFactory {

  /** Manager instance to interface with OWLAPI */
  private val manager = OWLManager.createOWLOntologyManager()
  private val factory = manager.getOWLDataFactory()

  def apply(counter: Integer = -1): DataFactory = new DataFactory(counter)
}

class DataFactory(private var counter: Integer) {

  private def getNext(): Integer = {
    counter += 1
    counter
  }

  def getVariable(): Variable =
    Variable.create(f"I${this.getNext()}%05d")

  def getOWLClass(): OWLClass =
    DataFactory.factory.getOWLClass(RSA(s"tmp${this.getNext()}").getIRI)
}