java.lang.Object
org.apache.jena.ontapi.utils.Graphs

public class Graphs extends Object
Helper to work with Jena Graph (generally with our UnionGraph) and with its related objects: Triple and Node.
See Also:
  • GraphUtil
  • GraphUtils
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.jena.shared.PrefixMapping
    collectPrefixes(Iterable<org.apache.jena.graph.Graph> graphs)
    Collects a prefixes' library from the collection of the graphs.
    static org.apache.jena.graph.Node
    Makes a fresh node instance according to the given iri.
    static org.apache.jena.graph.Node
    createOntologyHeaderNode(org.apache.jena.graph.Graph graph, String uriOrNull)
    Creates a new ontology header (uriOrBlank rdf:type owl:Ontology) if it is not present in the graph.
    static Stream<org.apache.jena.graph.Graph>
    dataGraphs(org.apache.jena.graph.Graph graph)
    Lists all indivisible graphs extracted from the composite or wrapper graph including the base as flat stream of non-composite (primitive) graphs.
    static boolean
    dependsOn(org.apache.jena.graph.Graph left, org.apache.jena.graph.Graph right)
    Answers true if the left graph depends on the right one.
    static Stream<org.apache.jena.graph.Graph>
    directSubGraphs(org.apache.jena.graph.Graph graph)
    Extracts and lists all top-level sub-graphs from the given composite graph-container, that is allowed to be either UnionGraph or Polyadic or Dyadic.
    static Optional<org.apache.jena.graph.Node>
    findOntologyNameNode(org.apache.jena.graph.Graph graph)
    Returns OWL Ontology ID (either object in any owl:versionIRI <uri> statement or subject in <uri> rdf:type owl:Ontology statement).
    static Optional<org.apache.jena.graph.Node>
    findOntologyNameNode(org.apache.jena.graph.Graph graph, boolean allowMultipleOntologyHeaders)
    Returns OWL Ontology ID (either object in any owl:versionIRI <uri> statement or subject in <uri> rdf:type owl:Ontology statement).
    static Optional<org.apache.jena.graph.Node>
    findVersionIRI(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node header)
     
    Lists all graphs in the tree that is specified as UnionGraph.
    static Stream<org.apache.jena.graph.Graph>
    flatTree(org.apache.jena.graph.Graph graph, Function<org.apache.jena.graph.Graph,org.apache.jena.graph.Graph> getBase, Function<org.apache.jena.graph.Graph,Stream<org.apache.jena.graph.Graph>> listSubGraphs)
    Lists all indivisible data graphs extracted from the composite or wrapper graph;
    static Set<String>
    getImports(org.apache.jena.graph.Graph graph)
    Returns all uri-objects from the _:x owl:imports _:uri statements.
    static Set<String>
    getImports(org.apache.jena.graph.Graph graph, boolean allowMultipleOntologyHeaders)
    Returns all uri-objects from the _:x owl:imports _:uri statements.
    static org.apache.jena.graph.Graph
    getPrimary(org.apache.jena.graph.Graph graph)
    Gets the base (primary) base graph from a composite or wrapper graph if it is possible otherwise returns the same graph.
    static int
    getSpliteratorCharacteristics(org.apache.jena.graph.Graph graph)
    Returns a Spliterator characteristics based on graph analysis.
    static boolean
    hasImports(org.apache.jena.graph.Graph graph, String uri)
    Answers true if the given uri is present in the import closure.
    static boolean
    hasOneOfType(org.apache.jena.graph.Node node, org.apache.jena.graph.Graph graph, Set<org.apache.jena.graph.Node> types)
    Answers true, if there is a declaration node rdf:type $type, where $type is one of the specified types.
    static org.apache.jena.graph.Triple
    invertTriple(org.apache.jena.graph.Triple triple)
    Inverts the given triple so that the new triple has the same subject as the given object, and the same object as the given subject.
    static boolean
    isDistinct(org.apache.jena.graph.Graph graph)
    Answers true iff the given graph is distinct.
    static boolean
    isGraphInf(org.apache.jena.graph.Graph graph)
    Answers true if the graph specified is InfGraph.
    static boolean
    isGraphMem(org.apache.jena.graph.Graph graph)
    Answers true if the graph specified is GraphMem.
    static boolean
    isNamedTriple(org.apache.jena.graph.Triple triple)
    Answers true if all parts of the given RDF triple are URIs (i.e., not blank nodes or literals).
    static boolean
    isOntGraph(org.apache.jena.graph.Graph graph)
    Checks whether the specified graph is ontological, that is, has an OWL header.
    static boolean
    isOntUnionGraph(UnionGraph graph, boolean allowMultipleOntologyHeaders)
    Checks whether the specified graph is ontological, that is, has a hierarchy synchronized with the owl:imports & owl:Ontology relationships.
    static boolean
    isSameBase(org.apache.jena.graph.Graph left, org.apache.jena.graph.Graph right)
    Answers true iff the two input graphs are based on the same primitive graph.
    static boolean
    isSized(org.apache.jena.graph.Graph graph)
    Answers true iff the given graph has known size and therefore the operation graph.size() does not take significant efforts.
    static boolean
    isWrapper(org.apache.jena.graph.Graph g)
    Answers true if the given graph can be unwrapped.
    static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Node>
    listAllNodes(org.apache.jena.graph.Graph graph)
    Lists all unique nodes in the given graph.
    static org.apache.jena.util.iterator.ExtendedIterator<String>
    listImports(org.apache.jena.graph.Graph graph, boolean allowMultipleOntologyHeaders)
    Returns an ExtendedIterator over all URIs from the _:x owl:imports _:uri statements.
    static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Triple>
    listOntHeaderTriples(org.apache.jena.graph.Graph graph)
    Lists all triples which related to ontology header somehow.
    static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Node>
    listOntologyNodes(org.apache.jena.graph.Graph graph)
    Lists all subjects from uriOrBlankNode rdf:type owl:Ontology statements.
    static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Node>
    listSubjects(org.apache.jena.graph.Graph graph)
    Lists all unique subject nodes in the given graph.
    static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Node>
    listSubjectsAndObjects(org.apache.jena.graph.Graph graph)
    Lists all unique nodes in the given graph, which are used in a subject or an object positions.
    static org.apache.jena.graph.Node
    makeOntologyHeaderNode(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node newOntology)
    Creates (if absents) a new ontology header (node rdf:type owl:Ontology) for the specified node, removing existing ontology headers (if any) and moving their contents to the new header.
    static UnionGraph
    makeOntUnion(org.apache.jena.graph.Graph graph, Collection<org.apache.jena.graph.Graph> repository, Function<org.apache.jena.graph.Graph,UnionGraph> wrapAsUnion)
    Assembles the hierarchical ontology Union Graph from the specified components in accordance with their owl:imports and owl:Ontology declarations.
    static UnionGraph
    makeOntUnionFrom(org.apache.jena.graph.Graph graph, Function<org.apache.jena.graph.Graph,UnionGraph> wrapAsUnion)
    Creates an ontology UnionGraph from the specified graph of arbitrary nature.
    static Optional<org.apache.jena.graph.Node>
    ontologyNode(org.apache.jena.graph.Graph graph)
    Returns the primary Ontology Node (the subject in the _:x rdf:type owl:Ontology statement) within the given graph if it can be uniquely determined.
    static Optional<org.apache.jena.graph.Node>
    ontologyNode(org.apache.jena.graph.Graph graph, boolean allowMultipleOntologyHeaders)
    Returns the primary Ontology Node (the subject in the _:x rdf:type owl:Ontology statement) within the given graph if it can be uniquely determined.
    static Comparator<org.apache.jena.graph.Node>
    rootNodeComparator(org.apache.jena.graph.Graph graph)
    Returns a comparator for root nodes.
    static long
    size(org.apache.jena.graph.Graph graph)
    Returns the number of triples in the graph as long.
    static boolean
    testTypes(org.apache.jena.graph.Node node, org.apache.jena.graph.Graph graph, Set<org.apache.jena.graph.Node> whiteTypes, Set<org.apache.jena.graph.Node> blackTypes)
    Answers true, if there is a declaration node rdf:type $type, where $type is from the white types list, but not from the black types list.
    static boolean
    testTypesUsingContains(org.apache.jena.graph.Node node, org.apache.jena.graph.Graph g, Set<org.apache.jena.graph.Node> whiteTypes, Set<org.apache.jena.graph.Node> blackTypes)
     
    static org.apache.jena.graph.Graph
    unwrap(org.apache.jena.graph.Graph graph)
    Unwraps the base (primary) base graph from a composite or wrapper graph if it is possible otherwise returns the same graph.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Graphs

      public Graphs()
  • Method Details

    • directSubGraphs

      public static Stream<org.apache.jena.graph.Graph> directSubGraphs(org.apache.jena.graph.Graph graph)
      Extracts and lists all top-level sub-graphs from the given composite graph-container, that is allowed to be either UnionGraph or Polyadic or Dyadic. If the graph is not of the list above, an empty stream is expected. The base graph is not included in the resulting stream. In case of Dyadic, the left graph is considered as a base and the right is a sub-graph.
      Parameters:
      graph - Graph
      Returns:
      Stream of Graphs
      See Also:
    • getPrimary

      public static org.apache.jena.graph.Graph getPrimary(org.apache.jena.graph.Graph graph)
      Gets the base (primary) base graph from a composite or wrapper graph if it is possible otherwise returns the same graph. If the specified graph is Dyadic, the left part is considered as base graph.
      Parameters:
      graph - Graph
      Returns:
      Graph
      See Also:
    • unwrap

      public static org.apache.jena.graph.Graph unwrap(org.apache.jena.graph.Graph graph)
      Unwraps the base (primary) base graph from a composite or wrapper graph if it is possible otherwise returns the same graph. If the specified graph is Dyadic, the left part is considered as base graph.
      Parameters:
      graph - Graph
      Returns:
      Graph
      See Also:
    • isWrapper

      public static boolean isWrapper(org.apache.jena.graph.Graph g)
      Answers true if the given graph can be unwrapped.
      Parameters:
      g - Graph
      Returns:
      boolean
      See Also:
    • isGraphMem

      public static boolean isGraphMem(org.apache.jena.graph.Graph graph)
      Answers true if the graph specified is GraphMem.
      Parameters:
      graph - Graph
      Returns:
      boolean
    • isGraphInf

      public static boolean isGraphInf(org.apache.jena.graph.Graph graph)
      Answers true if the graph specified is InfGraph.
      Parameters:
      graph - Graph
      Returns:
      boolean
    • dataGraphs

      public static Stream<org.apache.jena.graph.Graph> dataGraphs(org.apache.jena.graph.Graph graph)
      Lists all indivisible graphs extracted from the composite or wrapper graph including the base as flat stream of non-composite (primitive) graphs.
      Parameters:
      graph - Graph
      Returns:
      Stream of Graphs
    • flatTree

      public static Stream<org.apache.jena.graph.Graph> flatTree(org.apache.jena.graph.Graph graph, Function<org.apache.jena.graph.Graph,org.apache.jena.graph.Graph> getBase, Function<org.apache.jena.graph.Graph,Stream<org.apache.jena.graph.Graph>> listSubGraphs)
      Lists all indivisible data graphs extracted from the composite or wrapper graph;
      Parameters:
      graph - Graph
      getBase - a Function to extract primary graph
      listSubGraphs - a Function to extract subgraphs
      Returns:
      Stream of Graphs
    • isSameBase

      public static boolean isSameBase(org.apache.jena.graph.Graph left, org.apache.jena.graph.Graph right)
      Answers true iff the two input graphs are based on the same primitive graph.
      Parameters:
      left - Graph
      right - Graph
      Returns:
      boolean
    • isDistinct

      public static boolean isDistinct(org.apache.jena.graph.Graph graph)
      Answers true iff the given graph is distinct. A distinct Graph behaves like a Set: for each pair of encountered triples t1, t2 from any iterator, !t1.equals(t2).
      Parameters:
      graph - Graph to test
      Returns:
      boolean if graph is distinct
      See Also:
    • isSized

      public static boolean isSized(org.apache.jena.graph.Graph graph)
      Answers true iff the given graph has known size and therefore the operation graph.size() does not take significant efforts. Composite graphs are considered as sized only if they relay on a single base graph, since their sizes are not always a sum of part size.
      Parameters:
      graph - Graph to test
      Returns:
      boolean if graph is sized
      See Also:
    • size

      public static long size(org.apache.jena.graph.Graph graph)
      Returns the number of triples in the graph as long.
      Parameters:
      graph - Graph, not null
      Returns:
      long
      See Also:
    • makeOntUnionFrom

      public static UnionGraph makeOntUnionFrom(org.apache.jena.graph.Graph graph, Function<org.apache.jena.graph.Graph,UnionGraph> wrapAsUnion)
      Creates an ontology UnionGraph from the specified graph of arbitrary nature. The method can be used, for example, to transform the legacy MultiUnion Graph to UnionGraph.
      Parameters:
      graph - Graph
      wrapAsUnion - Function to produce new instance UnionGraph from Graph
      Returns:
      UnionGraph
    • makeOntUnion

      public static UnionGraph makeOntUnion(org.apache.jena.graph.Graph graph, Collection<org.apache.jena.graph.Graph> repository, Function<org.apache.jena.graph.Graph,UnionGraph> wrapAsUnion)
      Assembles the hierarchical ontology Union Graph from the specified components in accordance with their owl:imports and owl:Ontology declarations. Irrelevant graphs are ignored.
      Parameters:
      graph - Graph
      repository - a Collection of graphs to search in for missed dependencies
      wrapAsUnion - Function to produce new instance UnionGraph from Graph
      Returns:
      UnionGraph
    • flatHierarchy

      public static Stream<UnionGraph> flatHierarchy(UnionGraph graph)
      Lists all graphs in the tree that is specified as UnionGraph.
      Parameters:
      graph - UnionGraph
      Returns:
      Stream of UnionGraphs
      See Also:
    • isOntGraph

      public static boolean isOntGraph(org.apache.jena.graph.Graph graph)
      Checks whether the specified graph is ontological, that is, has an OWL header. This method does not check the graph for validity; it may still be misconfigured (if there are several headers).
      Parameters:
      graph - Graph
      Returns:
      boolean
    • isOntUnionGraph

      public static boolean isOntUnionGraph(UnionGraph graph, boolean allowMultipleOntologyHeaders)
      Checks whether the specified graph is ontological, that is, has a hierarchy synchronized with the owl:imports & owl:Ontology relationships.
      Parameters:
      graph - UnionGraph
      allowMultipleOntologyHeaders - boolean, see ontologyNode(Graph, boolean) for explanation
      Returns:
      boolean
    • createOntologyHeaderNode

      public static org.apache.jena.graph.Node createOntologyHeaderNode(org.apache.jena.graph.Graph graph, String uriOrNull)
      Creates a new ontology header (uriOrBlank rdf:type owl:Ontology) if it is not present in the graph. According to the OWL specification, each non-composite ontology graph must contain one and only one ontology header. If a well-formed header already exists, the method returns it unchanged. If there are multiple other headers, any extra headers will be removed, and the content will be moved to a new generated anonymous header.
      Parameters:
      graph - Graph
      uriOrNull - ontology header IRI, if null then the method returns either existing anonymous header or generates new anonymous (blank) header
      Returns:
      existing or new header
    • makeOntologyHeaderNode

      public static org.apache.jena.graph.Node makeOntologyHeaderNode(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node newOntology)
      Creates (if absents) a new ontology header (node rdf:type owl:Ontology) for the specified node, removing existing ontology headers (if any) and moving their contents to the new header. Note that a valid ontology must have a single header, but there could be multiple headers in imports closure.
      Parameters:
      graph - Graph
      newOntology - Node the new ontology header (iri or blank)
      Returns:
      newOntology
    • findOntologyNameNode

      public static Optional<org.apache.jena.graph.Node> findOntologyNameNode(org.apache.jena.graph.Graph graph)
      Returns OWL Ontology ID (either object in any owl:versionIRI <uri> statement or subject in <uri> rdf:type owl:Ontology statement).
      Parameters:
      graph - Graph
      Returns:
      Optional with Node blank or URI, or Optional#empty if the ontology Node cannot be uniquely defined or absent in the graph
      See Also:
    • findOntologyNameNode

      public static Optional<org.apache.jena.graph.Node> findOntologyNameNode(org.apache.jena.graph.Graph graph, boolean allowMultipleOntologyHeaders)
      Returns OWL Ontology ID (either object in any owl:versionIRI <uri> statement or subject in <uri> rdf:type owl:Ontology statement).
      Parameters:
      graph - Graph
      allowMultipleOntologyHeaders - boolean, see ontologyNode(Graph, boolean) for explanation
      Returns:
      Optional with Node blank or URI, or Optional#empty if the ontology Node cannot be uniquely defined or absent in the graph
      See Also:
    • findVersionIRI

      public static Optional<org.apache.jena.graph.Node> findVersionIRI(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node header)
      Parameters:
      graph - Graph
      header - Node subject from header rdf:type owl:Ontology statement
      Returns:
      Optional with URI Node
    • ontologyNode

      public static Optional<org.apache.jena.graph.Node> ontologyNode(org.apache.jena.graph.Graph graph, boolean allowMultipleOntologyHeaders)
      Returns the primary Ontology Node (the subject in the _:x rdf:type owl:Ontology statement) within the given graph if it can be uniquely determined. Note: it works with any graph, not necessarily with the base. A valid composite ontology graph a lot of ontological nodes are expected. If allowMultipleOntologyHeaders = true, the most suitable ontology header will be chosen: if there are both uri and blank ontological nodes together in the graph, then the method prefers uri; if there are several ontological nodes of the same kind, it chooses the most cumbersome one.
      Parameters:
      graph - Graph
      allowMultipleOntologyHeaders - boolean
      Returns:
      Optional around the Node which could be uri or blank
    • ontologyNode

      public static Optional<org.apache.jena.graph.Node> ontologyNode(org.apache.jena.graph.Graph graph)
      Returns the primary Ontology Node (the subject in the _:x rdf:type owl:Ontology statement) within the given graph if it can be uniquely determined. Note: it works with any graph, not necessarily with the base. A valid composite ontology graph a lot of ontological nodes are expected.
      Parameters:
      graph - Graph
      Returns:
      Optional around the Node which could be uri or blank
    • rootNodeComparator

      public static Comparator<org.apache.jena.graph.Node> rootNodeComparator(org.apache.jena.graph.Graph graph)
      Returns a comparator for root nodes. Tricky logic: first compares roots as standalone nodes and any uri-node is considered less than any blank-node, then compares roots as part of the graph using the rule 'the fewer children -> the greater weight'.
      Parameters:
      graph - Graph
      Returns:
      Comparator
    • listOntologyNodes

      public static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Node> listOntologyNodes(org.apache.jena.graph.Graph graph)
      Lists all subjects from uriOrBlankNode rdf:type owl:Ontology statements.
      Parameters:
      graph - Graph
      Returns:
      ExtendedIterator of Node
    • getImports

      public static Set<String> getImports(org.apache.jena.graph.Graph graph)
      Returns all uri-objects from the _:x owl:imports _:uri statements. In the case of composite graph, imports are listed transitively.
      Parameters:
      graph - Graph, not null
      Returns:
      unordered Set of uris from the whole graph (it may be composite)
    • getImports

      public static Set<String> getImports(org.apache.jena.graph.Graph graph, boolean allowMultipleOntologyHeaders)
      Returns all uri-objects from the _:x owl:imports _:uri statements. In the case of composite graph, imports are listed transitively.
      Parameters:
      graph - Graph, not null
      allowMultipleOntologyHeaders - boolean, see ontologyNode(Graph, boolean) for explanation
      Returns:
      unordered Set of uris from the whole graph (it may be composite)
    • hasImports

      public static boolean hasImports(org.apache.jena.graph.Graph graph, String uri)
      Answers true if the given uri is present in the import closure.
      Parameters:
      graph - Graph, not null
      uri - to test
      Returns:
      boolean
    • listImports

      public static org.apache.jena.util.iterator.ExtendedIterator<String> listImports(org.apache.jena.graph.Graph graph, boolean allowMultipleOntologyHeaders)
      Returns an ExtendedIterator over all URIs from the _:x owl:imports _:uri statements. In the case of composite graph, imports are listed transitively.
      Parameters:
      graph - Graph, not null
      allowMultipleOntologyHeaders - boolean, see ontologyNode(Graph, boolean) for explanation
      Returns:
      ExtendedIterator of String-URIs
    • listOntHeaderTriples

      public static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Triple> listOntHeaderTriples(org.apache.jena.graph.Graph graph)
      Lists all triples which related to ontology header somehow.
      Parameters:
      graph - Graph
      Returns:
      ExtendedIterator of Triples
    • collectPrefixes

      public static org.apache.jena.shared.PrefixMapping collectPrefixes(Iterable<org.apache.jena.graph.Graph> graphs)
      Collects a prefixes' library from the collection of the graphs.
      Parameters:
      graphs - Iterable a collection of graphs
      Returns:
      unmodifiable (locked) prefix mapping
    • dependsOn

      public static boolean dependsOn(org.apache.jena.graph.Graph left, org.apache.jena.graph.Graph right)
      Answers true if the left graph depends on the right one.
      Parameters:
      left - Graph
      right - Graph
      Returns:
      true if the left argument graph is dependent on the right
    • listSubjects

      public static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Node> listSubjects(org.apache.jena.graph.Graph graph)
      Lists all unique subject nodes in the given graph. Warning: the result is temporary stored in-memory!
      Parameters:
      graph - Graph, not null
      Returns:
      an ExtendedIterator (distinct) of all subjects in the graph
      Throws:
      OutOfMemoryError - may occur while iterating, e.g.when the graph is huge so that all its subjects can be placed in memory as a Set
      See Also:
      • GraphUtil.listSubjects(Graph, Node, Node)
    • listSubjectsAndObjects

      public static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Node> listSubjectsAndObjects(org.apache.jena.graph.Graph graph)
      Lists all unique nodes in the given graph, which are used in a subject or an object positions. Warning: the result is temporary stored in-memory!
      Parameters:
      graph - Graph, not null
      Returns:
      an ExtendedIterator (distinct) of all subjects or objects in the graph
      Throws:
      OutOfMemoryError - while iterating in case the graph is too large so that all its subjects and objects can be placed in memory as a Set
      See Also:
      • GraphUtils.allNodes(Graph)
    • listAllNodes

      public static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Node> listAllNodes(org.apache.jena.graph.Graph graph)
      Lists all unique nodes in the given graph. Warning: the result is temporary stored in-memory!
      Parameters:
      graph - Graph, not null
      Returns:
      an ExtendedIterator (distinct) of all nodes in the graph
      Throws:
      OutOfMemoryError - while iterating in case the graph is too large to be placed in memory as a Set
    • createNode

      public static org.apache.jena.graph.Node createNode(String iri)
      Makes a fresh node instance according to the given iri.
      Parameters:
      iri - String, an IRI to create URI-Node or null to create Blank-Node
      Returns:
      Node, not null
    • isNamedTriple

      public static boolean isNamedTriple(org.apache.jena.graph.Triple triple)
      Answers true if all parts of the given RDF triple are URIs (i.e., not blank nodes or literals).
      Parameters:
      triple - a regular graph Triple, not null
      Returns:
      boolean
    • invertTriple

      public static org.apache.jena.graph.Triple invertTriple(org.apache.jena.graph.Triple triple)
      Inverts the given triple so that the new triple has the same subject as the given object, and the same object as the given subject.
      Parameters:
      triple - SPO the Triple, not null
      Returns:
      Triple, OPS
    • getSpliteratorCharacteristics

      public static int getSpliteratorCharacteristics(org.apache.jena.graph.Graph graph)
      Returns a Spliterator characteristics based on graph analysis.
      Parameters:
      graph - Graph
      Returns:
      int
    • hasOneOfType

      public static boolean hasOneOfType(org.apache.jena.graph.Node node, org.apache.jena.graph.Graph graph, Set<org.apache.jena.graph.Node> types)
      Answers true, if there is a declaration node rdf:type $type, where $type is one of the specified types.

      Impl note: depending on the type of the underlying graph, it may or may not be advantageous to get all types at once, or ask many separate queries. Heuristically, we assume that fine-grain queries to an inference graph are preferable, and all-at-once for other types, including persistent stores.

      Parameters:
      node - Node to test
      graph - Graph
      types - Set of Node-types
      Returns:
      boolean
    • testTypes

      public static boolean testTypes(org.apache.jena.graph.Node node, org.apache.jena.graph.Graph graph, Set<org.apache.jena.graph.Node> whiteTypes, Set<org.apache.jena.graph.Node> blackTypes)
      Answers true, if there is a declaration node rdf:type $type, where $type is from the white types list, but not from the black types list.

      Impl note: depending on the type of the underlying graph, it may or may not be advantageous to get all types at once, or ask many separate queries. Heuristically, we assume that fine-grain queries to an inference graph are preferable, and all-at-once for other types, including persistent stores.

      Parameters:
      node - Node to test
      graph - Graph
      whiteTypes - Set of Node-types
      blackTypes - Set of Node-types
      Returns:
      boolean
    • testTypesUsingContains

      public static boolean testTypesUsingContains(org.apache.jena.graph.Node node, org.apache.jena.graph.Graph g, Set<org.apache.jena.graph.Node> whiteTypes, Set<org.apache.jena.graph.Node> blackTypes)