Interface EnhNodeFactory

All Known Implementing Classes:
BaseEnhNodeFactoryImpl, CommonEnhNodeFactoryImpl, CompositeEnhNodeFactoryImpl, WrappedEnhNodeFactory

public interface EnhNodeFactory
An EnhNode factory abstraction, that is an ONT-API analogue of the Jena Implementation Factory. Used to bind a concrete implementation (i.e. enhanced node) and an interface (OWL Object) with a Graph Node. It is a part of OntPersonality mechanism to manipulate OWL2 RDF-model objects (which happens through OntEnhGraph). Also note, explicit links between different EnhNodeFactory factories are undesirable (for more details see OntObjectPersonalityBuilder.add(Class, EnhNodeFactory) and OntEnhGraph).

TODO: consider a possibility to replace EnhGraph with OntEnhGraph.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.jena.enhanced.Implementation
    Represents the given implementation factory as Jena Implementation Factory.
    default boolean
    canCreateInGraph(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph eg)
    Answers true iff the modifying of the graph is allowed by this implementation for the encapsulated object's interface.
    boolean
    canWrap(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph eg)
    Checks that the wrapping (node, eg) would succeed.
    default org.apache.jena.enhanced.EnhNode
    createInGraph(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph eg)
    Makes interface-defined changes in the given graph and returns a new enhanced node, wrapping the given Node.
    org.apache.jena.enhanced.EnhNode
    createInstance(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph eg)
    Wraps the given pair of node and graph to a fresh EnhNode instance without any checking or throwing any exception.
    default Stream<org.apache.jena.enhanced.EnhNode>
    find(org.apache.jena.enhanced.EnhGraph eg)
    Lists all enhanced nodes from the graph, with the interface that this factory encapsulates.
    org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.enhanced.EnhNode>
    iterator(org.apache.jena.enhanced.EnhGraph eg)
    Returns an Extended Iterator over the nodes found in the EnhGraph in the form of EnhNode with the interface that this factory encapsulates.
    default org.apache.jena.enhanced.EnhNode
    wrap(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph eg)
    Creates a new EnhNode wrapping the given Node node in the context of the graph EnhGraph.
  • Method Details

    • asJenaImplementation

      static org.apache.jena.enhanced.Implementation asJenaImplementation(EnhNodeFactory f) throws OntJenaException
      Represents the given implementation factory as Jena Implementation Factory.
      Parameters:
      f - OntPersonality, not null
      Returns:
      Implementation, not null
      Throws:
      OntJenaException - in case the conversion is not possible
      See Also:
    • iterator

      org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.enhanced.EnhNode> iterator(org.apache.jena.enhanced.EnhGraph eg)
      Returns an Extended Iterator over the nodes found in the EnhGraph in the form of EnhNode with the interface that this factory encapsulates. It is assumed that the returned iterator is distinct (does not answer with duplicates). At least, it must be distinct if the EnhGraph encapsulates the distinct graph (see also Graphs.isDistinct(Graph)).
      Parameters:
      eg - EnhGraph
      Returns:
      ExtendedIterator of EnhNodes
    • canWrap

      boolean canWrap(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph eg)
      Checks that the wrapping (node, eg) would succeed.
      Parameters:
      node - node the node to test for suitability
      eg - the enhanced graph the node appears in
      Returns:
      true iff the node can represent the type in the graph
    • createInstance

      org.apache.jena.enhanced.EnhNode createInstance(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph eg)
      Wraps the given pair of node and graph to a fresh EnhNode instance without any checking or throwing any exception. Some implementations may return null if the canWrap(Node, EnhGraph) returns false. Unlike the method createInGraph(Node, EnhGraph), this method does not make any changes to the graph.
      Parameters:
      node - Node, not null
      eg - EnhGraph, not null
      Returns:
      EnhNode or null
    • wrap

      default org.apache.jena.enhanced.EnhNode wrap(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph eg)
      Creates a new EnhNode wrapping the given Node node in the context of the graph EnhGraph. Unlike the method createInGraph(Node, EnhGraph), this method does not make any changes to the graph.
      Parameters:
      node - Node, the node to be wrapped as EnhNode, not null
      eg - EnhGraph, the graph containing the node, not null
      Returns:
      EnhNode a new enhanced node presenting the interface that this factory encapsulates
      Throws:
      OntJenaException - in case wrapping is impossible
    • createInGraph

      default org.apache.jena.enhanced.EnhNode createInGraph(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph eg)
      Makes interface-defined changes in the given graph and returns a new enhanced node, wrapping the given Node.
      Parameters:
      node - Node, the node to be wrapped as EnhNode, not null
      eg - EnhGraph, the graph which would contain the result EnhNode, not null
      Returns:
      a new enhanced node
      Throws:
      OntJenaException - in case modification of graph is not allowed for the specified node
    • canCreateInGraph

      default boolean canCreateInGraph(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph eg)
      Answers true iff the modifying of the graph is allowed by this implementation for the encapsulated object's interface.
      Parameters:
      node - Node the node to test that changes are permitted.
      eg - EnhGraph the graph to be changed.
      Returns:
      true if creation is allowed.
    • find

      default Stream<org.apache.jena.enhanced.EnhNode> find(org.apache.jena.enhanced.EnhGraph eg)
      Lists all enhanced nodes from the graph, with the interface that this factory encapsulates.
      Parameters:
      eg - the graph containing the node
      Returns:
      the stream of enhanced and suitability nodes