Class OntModelFactory

java.lang.Object
org.apache.jena.ontapi.OntModelFactory

public class OntModelFactory extends Object
A factory to produce Ontolofy models.
  • Field Details

    • STANDARD

      public static final org.apache.jena.shared.PrefixMapping STANDARD
      A PrefixMapping that contains the "standard" for OWL2 prefixes we know about, viz rdf, rdfs, xsd, and owl.
  • Constructor Details

    • OntModelFactory

      public OntModelFactory()
  • Method Details

    • init

      public static void init()
      Initializes Jena System.
    • createDefaultGraph

      public static org.apache.jena.graph.Graph createDefaultGraph()
      Creates default (in-memory) graph implementation.
      Returns:
      Graph
    • createUnionGraph

      public static UnionGraph createUnionGraph(org.apache.jena.graph.Graph base)
      Wraps the given base graph as UnionGraph
      Parameters:
      base - Graph
      Returns:
      UnionGraph
    • createDefaultModel

      public static org.apache.jena.rdf.model.Model createDefaultModel()
      Creates default (in-memory) RDF Model implementation.
      Returns:
      Model
      See Also:
      • ModelFactory.createDefaultModel()
    • createDefaultModel

      public static org.apache.jena.rdf.model.Model createDefaultModel(org.apache.jena.graph.Graph graph)
      Creates default RDF Model implementation wrapping the given graph.
      Parameters:
      graph - Graph, not null
      Returns:
      Model
      See Also:
      • ModelFactory.createDefaultModel()
    • createModel

      public static OntModel createModel()
      Creates a fresh in-memory Ontology RDF Model with default personalities.
      Returns:
      OntModel
    • createModel

      public static OntModel createModel(org.apache.jena.graph.Graph graph)
      Creates an Ontology RDF Model wrapper around the given graph with default personalities.
      Parameters:
      graph - Graph
      Returns:
      OntModel
    • createModel

      public static OntModel createModel(org.apache.jena.graph.Graph graph, OntPersonality personality)
      Creates an Ontology RDF Model wrapper around the given graph with given personalities.
      Parameters:
      graph - Graph
      personality - OntPersonality
      Returns:
      OntModel
    • createModel

      public static OntModel createModel(OntSpecification spec)
      Creates an Ontology Model according to the specified specification.
      Parameters:
      spec - OntSpecification
      Returns:
      OntModel
    • createModel

      public static OntModel createModel(org.apache.jena.graph.Graph graph, OntSpecification spec)
      Creates an Ontology Model according to the specified specification.
      Parameters:
      graph - Graph (base graph)
      spec - OntSpecification
      Returns:
      OntModel
    • createModel

      public static OntModel createModel(org.apache.jena.graph.Graph graph, OntPersonality personality, org.apache.jena.reasoner.Reasoner reasoner)
      Creates an Ontology Model which is Inference Model. The specified graph and its subgraphs (if any) must not be InfGraph.
      Parameters:
      graph - Graph
      personality - OntPersonality
      reasoner - Reasoner
      Returns:
      OntModel
      See Also:
    • createModel

      public static OntModel createModel(String uri, GraphRepository repository)
      Creates Ontology Model associated with OntSpecification.OWL2_DL_MEM_BUILTIN_RDFS_INF spec. The repository manages all the dependencies. See createModel(Graph, OntSpecification, GraphRepository).
      Parameters:
      uri - String, subject of uri rdf:type owl:Ontology statement, can be null for anonymous ontology
      repository - GraphRepository
      Returns:
      OntModel
    • createModel

      public static OntModel createModel(OntSpecification spec, GraphRepository repository)
      Creates an anonymous Ontology Model according to the specified specification. The repository manages all the dependencies. Note that if repository is PersistentGraphRepository, encapsulated GraphMaker will be used to create graphs. See also createModel(Graph, OntSpecification, GraphRepository).
      Parameters:
      spec - OntSpecification
      repository - GraphRepository
      Returns:
      OntModel
    • createModel

      public static OntModel createModel(org.apache.jena.graph.Graph graph, OntSpecification spec, GraphRepository repository)
      Creates an Ontology Model according to the specified specification. The repository manages all the dependencies (imports closure).

      Note that for consistency it is necessary to work only through the OntModel or UnionGraph interfaces. Working directly with the UnionGraph.getBaseGraph() or repository may break the state. Imports closure control is performed via UnionGraph.Listener, any ontological graphs in the repository is wrapped as UnionGraph, InfGraph are not stored in the repository. When adding subgraph using the UnionGraph.addSubGraph(Graph) method a statement a owl:import b will be added. In turns, adding a statement a owl:import b will cause adding a subgraph. If a subgraph cannot be found in the repository, an empty ontology graph will be associated with the corresponding owl:import. The specified graph and its subgraphs (if any) must not be InfGraph. Note that the method adds ontology headers to each subgraph of the specified graph, including itself. Also note that attempt to change OntID will cause OntJenaException.IllegalArgument if the ontology is in some other ontologies' import closure.

      This method can also be used to retrieve OntModel from the repository: it returns a new instance of OntModel wrapping the existing UnionGraph if it is present in the repository.

      Parameters:
      graph - Graph or null to create anonymous Graph automatically; the instance (new or provided) will be wrapped as UnionGraph (if it is not already UnionGraph)
      spec - OntSpecification
      repository - GraphRepository; will contain UnionGraphs
      Returns:
      OntModel
      See Also:
    • getModelOrNull

      public static OntModel getModelOrNull(String uri, OntSpecification spec, GraphRepository repository)
      Finds OntModel in the repository, returning null if there is no ontology with the specified uri. The method constructs new OntModel instance, wrapping the found UnionGraph.
      Parameters:
      uri - ontology name: object from the statement <ont> owl:versionIri <name> or subject from the statement <name> rdf:type owl:Ontology; not null
      spec - OntSpecification
      repository - GraphRepository
      Returns:
      OntModel or null if there is no such ontology
    • getModelOrNull

      public static OntModel getModelOrNull(org.apache.jena.graph.Node name, OntSpecification spec, GraphRepository repository)
      Finds OntModel in the repository, returning null if there is no ontology with the specified name. The method constructs new OntModel instance, wrapping the found UnionGraph.
      Parameters:
      name - Node ontology name, URI or blank
      spec - OntSpecification
      repository - GraphRepository
      Returns:
      OntModel or null if there is no such ontology
    • createOntGraph

      public static org.apache.jena.graph.Graph createOntGraph(org.apache.jena.graph.Node name, GraphRepository repository)
      Creates ontology graph.
      Parameters:
      name - Node, not null - ontology header.
      repository - GraphRepository, not null
      Returns:
      Graph