Interface OntEnhGraph

All Known Implementing Classes:
OntGraphModelImpl

public interface OntEnhGraph
An abstraction to work with OntPersonality and an interface-analogue of the Jena Enhanced Graph, and also a facility to provide implicit links between different EnhNodeFactory factories within a model. A .orElse(null) is assumed to be OntEnhGraph.

Explicit links between object factories are undesirable, since replacing one of the factories will affect others. But using this interface, it is possible to build safe implicit links and replacing one factory with a custom implementation will not break the whole model. More about this see in the description for the method OntObjectPersonalityBuilder.add(Class, EnhNodeFactory).

  • Method Summary

    Modifier and Type
    Method
    Description
    asPersonalityModel(org.apache.jena.enhanced.EnhGraph graph)
    Represents the given EnhGraph as a OntEnhGraph.
    Represents the given Ont[Graph]Model as a OntEnhGraph.
    static boolean
    canAs(Class<? extends org.apache.jena.rdf.model.RDFNode> view, org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph graph)
    Checks if the given node can be viewed as the given type.
    default boolean
    canNodeAs(Class<? extends org.apache.jena.rdf.model.RDFNode> view, org.apache.jena.graph.Node node)
    Equivalent to safeFindNodeAs(node, view) != null.
    default <X extends OntObject>
    void
    checkType(Class<X> type)
     
    static OntConfig
    config(org.apache.jena.enhanced.EnhGraph graph)
    Extracts OntConfig from the given enhanced graph.
    <N extends org.apache.jena.rdf.model.RDFNode>
    N
    findNodeAs(org.apache.jena.graph.Node node, Class<N> type)
    Answers an enhanced node that wraps the given node and conforms to the given interface type.
    <N extends org.apache.jena.rdf.model.RDFNode>
    N
    getNodeAs(org.apache.jena.graph.Node node, Class<N> view)
    Answers an enhanced node that wraps the given node and conforms to the given interface type.
    Returns the model personality, that is unmodifiable model's configuration storage.
    <N extends org.apache.jena.rdf.model.RDFNode>
    N
    safeFindNodeAs(org.apache.jena.graph.Node node, Class<N> view)
    Answers an enhanced node that wraps the given node and conforms to the given interface type, taking into account possible graph recursions.
  • Method Details

    • asPersonalityModel

      static OntEnhGraph asPersonalityModel(org.apache.jena.enhanced.EnhGraph graph) throws OntJenaException
      Represents the given EnhGraph as a OntEnhGraph.
      Parameters:
      graph - enhanced graph, that is also assumed to be OntModel, not null
      Returns:
      OntEnhGraph
      Throws:
      OntJenaException - in case the conversion is not possible
      See Also:
    • asPersonalityModel

      static OntEnhGraph asPersonalityModel(OntModel graph) throws OntJenaException
      Represents the given Ont[Graph]Model as a OntEnhGraph.
      Parameters:
      graph - OWL graph model, that is also assumed to be EnhGraph, not null
      Returns:
      OntEnhGraph
      Throws:
      OntJenaException - in case the conversion is not possible
      See Also:
    • config

      static OntConfig config(org.apache.jena.enhanced.EnhGraph graph)
      Extracts OntConfig from the given enhanced graph.
      Parameters:
      graph - OWL graph model, that is also assumed to be EnhGraph, not null
      Returns:
      OntConfig
    • canAs

      static boolean canAs(Class<? extends org.apache.jena.rdf.model.RDFNode> view, org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph graph)
      Checks if the given node can be viewed as the given type. Opposite to the method findNodeAs(Node, Class), this method handles possible graph recursions.
      Parameters:
      view - Class-type
      node - Node
      graph - EnhGraph, assumed to be OntGraphModelImpl
      Returns:
      true if the node can be safely cast to the specified type
    • getOntPersonality

      OntPersonality getOntPersonality()
      Returns the model personality, that is unmodifiable model's configuration storage.
      Returns:
      OntPersonality
    • getNodeAs

      <N extends org.apache.jena.rdf.model.RDFNode> N getNodeAs(org.apache.jena.graph.Node node, Class<N> view)
      Answers an enhanced node that wraps the given node and conforms to the given interface type.
      Type Parameters:
      N - a subtype of RDFNode
      Parameters:
      node - a node, that is assumed to be in this graph
      view - a type denoting the enhanced facet desired
      Returns:
      an enhanced node, not null
      Throws:
      OntJenaException - in case no RDFNode match found
      See Also:
    • findNodeAs

      <N extends org.apache.jena.rdf.model.RDFNode> N findNodeAs(org.apache.jena.graph.Node node, Class<N> type)
      Answers an enhanced node that wraps the given node and conforms to the given interface type. It works silently: no exception is thrown, instead returns null.
      Type Parameters:
      N - any subtype of RDFNode
      Parameters:
      node - Node
      type - Class-type
      Returns:
      RDFNode or null
      See Also:
    • safeFindNodeAs

      <N extends org.apache.jena.rdf.model.RDFNode> N safeFindNodeAs(org.apache.jena.graph.Node node, Class<N> view)
      Answers an enhanced node that wraps the given node and conforms to the given interface type, taking into account possible graph recursions.
      Type Parameters:
      N - a subtype of RDFNode
      Parameters:
      node - a node, that is assumed to be in this graph
      view - a type denoting the enhanced facet desired
      Returns:
      an enhanced node or null if no match found
      Throws:
      OntJenaException.Recursion - if a graph recursion is indicated
      See Also:
    • canNodeAs

      default boolean canNodeAs(Class<? extends org.apache.jena.rdf.model.RDFNode> view, org.apache.jena.graph.Node node)
      Equivalent to safeFindNodeAs(node, view) != null.
      Parameters:
      view - RDFNode type
      node - Node
      Returns:
      boolean
    • checkType

      default <X extends OntObject> void checkType(Class<X> type)
      Type Parameters:
      X - any OntObject type
      Parameters:
      type - X
      Throws:
      OntJenaException.Unsupported - if the type is not supported by the configuration