Class UnionModel

  • All Implemented Interfaces:
    org.apache.jena.rdf.model.Model, org.apache.jena.rdf.model.ModelCon, org.apache.jena.rdf.model.ModelGraphInterface, org.apache.jena.rdf.model.RDFReaderF, org.apache.jena.rdf.model.RDFWriterF, org.apache.jena.shared.Lock, org.apache.jena.shared.PrefixMapping
    Direct Known Subclasses:
    OntGraphModelImpl

    public class UnionModel
    extends org.apache.jena.rdf.model.impl.ModelCom
    A model implementation which encapsulates union graph.

    Created by @szuev on 12.04.2018.

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.apache.jena.shared.PrefixMapping

        org.apache.jena.shared.PrefixMapping.Factory, org.apache.jena.shared.PrefixMapping.IllegalPrefixException, org.apache.jena.shared.PrefixMapping.JenaLockedException
    • Field Summary

      • Fields inherited from class org.apache.jena.rdf.model.impl.ModelCom

        modelReifier
      • Fields inherited from class org.apache.jena.enhanced.EnhGraph

        enhNodes, graph
      • Fields inherited from interface org.apache.jena.shared.Lock

        READ, WRITE
      • Fields inherited from interface org.apache.jena.shared.PrefixMapping

        Extended, Standard
    • Constructor Summary

      Constructors 
      Constructor Description
      UnionModel​(org.apache.jena.graph.Graph base, org.apache.jena.enhanced.Personality<org.apache.jena.rdf.model.RDFNode> personality)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static UnionGraph asUnionGraph​(org.apache.jena.graph.Graph graph)
      Creates an UnionGraph instance if it is needed.
      <N extends org.apache.jena.rdf.model.RDFNode>
      N
      fetchNodeAs​(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, taking into account possible graph recursions.
      <N extends org.apache.jena.rdf.model.RDFNode>
      N
      findNodeAs​(org.apache.jena.graph.Node node, Class<N> type)
      Returns a RDFNode for the given type and, if the result is present, caches it node at the model level.
      org.apache.jena.graph.Graph getBaseGraph()  
      org.apache.jena.rdf.model.Model getBaseModel()  
      UnionGraph getGraph()  
      <N extends org.apache.jena.rdf.model.RDFNode>
      N
      getNodeAs​(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.
      protected <N extends org.apache.jena.rdf.model.RDFNode>
      N
      getNodeAsInternal​(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.
      protected org.apache.jena.atlas.lib.Cache<org.apache.jena.graph.Node,​org.apache.jena.rdf.model.RDFNode> getNodeCache()
      Returns nodes cache.
      boolean isLocal​(org.apache.jena.rdf.model.Resource s, org.apache.jena.rdf.model.Property p, org.apache.jena.rdf.model.RDFNode o)
      Answers true if the given SPO belongs to the base graph.
      boolean isLocal​(org.apache.jena.rdf.model.Statement s)
      Answers true if the given statement belongs to the base graph.
      String toString()  
      UnionModel write​(OutputStream out)  
      UnionModel write​(OutputStream out, String lang)  
      UnionModel write​(OutputStream out, String lang, String base)  
      UnionModel write​(Writer writer)  
      UnionModel write​(Writer writer, String lang)  
      UnionModel write​(Writer writer, String lang, String base)  
      • Methods inherited from class org.apache.jena.rdf.model.impl.ModelCom

        abort, adapt, add, add, add, add, add, add, add, add, add, add, add, addCommon, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addNamespaces, asModel, asNode, asRDFNode, asStatement, asStatements, asStatements, asStatements, begin, calculateInTxn, clearNsPrefixMap, close, commit, contains, contains, contains, contains, contains, containsAll, containsAll, containsAllThenClose, containsAny, containsAny, containsAnyThenClose, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsResource, createAlt, createAlt, createBag, createBag, createList, createList, createList, createLiteral, createLiteral, createLiteral, createLiteral, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createProperty, createProperty, createReifiedStatement, createReifiedStatement, createResource, createResource, createResource, createResource, createResource, createResource, createResource, createResource, createSeq, createSeq, createStatement, createStatement, createStatement, createStatement, createStatement, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createWorkModel, difference, enterCriticalSection, executeInTxn, expandPrefix, findTriplesFrom, getAlt, getAlt, getAnyReifiedStatement, getBag, getBag, getList, getList, getLock, getModelLock, getNsPrefixMap, getNsPrefixURI, getNsURIPrefix, getProperty, getProperty, getProperty, getProperty, getRDFNode, getReader, getReader, getRequiredProperty, getRequiredProperty, getResource, getResource, getSeq, getSeq, getWriter, getWriter, hasNoMappings, independent, intersect, intersection, isClosed, isEmpty, isIsomorphicWith, isReified, leaveCriticalSection, listBySubject, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listNameSpaces, listObjects, listObjectsOfProperty, listObjectsOfProperty, listReifiedStatements, listReifiedStatements, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listStatements, listStatements, listStatements, listStatements, listStatements, listStatements, listSubjects, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, lock, notifyEvent, numPrefixes, qnameFor, query, read, read, read, read, read, read, read, register, reifiedToString, remove, remove, remove, remove, remove, remove, removeAll, removeAll, removeAllReifications, removeNsPrefix, removeReification, samePrefixMappingAs, setNsPrefix, setNsPrefixes, setNsPrefixes, shortForm, size, statementsToString, supportsSetOperations, supportsTransactions, union, unregister, withDefaultMappings, wrapAsResource
      • Methods inherited from class org.apache.jena.enhanced.EnhGraph

        asGraph, equals, getPersonality, hashCode, isIsomorphicWith, setNodeCache
      • Methods inherited from interface org.apache.jena.rdf.model.Model

        equals
    • Constructor Detail

      • UnionModel

        public UnionModel​(org.apache.jena.graph.Graph base,
                          org.apache.jena.enhanced.Personality<org.apache.jena.rdf.model.RDFNode> personality)
    • Method Detail

      • asUnionGraph

        public static UnionGraph asUnionGraph​(org.apache.jena.graph.Graph graph)
        Creates an UnionGraph instance if it is needed.
        Parameters:
        graph - Graph to wrap or return as is
        Returns:
        UnionGraph (fresh or given)
      • getGraph

        public UnionGraph getGraph()
        Specified by:
        getGraph in interface org.apache.jena.rdf.model.ModelGraphInterface
        Overrides:
        getGraph in class org.apache.jena.rdf.model.impl.ModelCom
      • getBaseGraph

        public org.apache.jena.graph.Graph getBaseGraph()
      • getBaseModel

        public org.apache.jena.rdf.model.Model getBaseModel()
      • write

        public UnionModel write​(Writer writer)
        Specified by:
        write in interface org.apache.jena.rdf.model.Model
        Overrides:
        write in class org.apache.jena.rdf.model.impl.ModelCom
      • write

        public UnionModel write​(Writer writer,
                                String lang)
        Specified by:
        write in interface org.apache.jena.rdf.model.Model
        Overrides:
        write in class org.apache.jena.rdf.model.impl.ModelCom
      • write

        public UnionModel write​(Writer writer,
                                String lang,
                                String base)
        Specified by:
        write in interface org.apache.jena.rdf.model.Model
        Overrides:
        write in class org.apache.jena.rdf.model.impl.ModelCom
      • write

        public UnionModel write​(OutputStream out)
        Specified by:
        write in interface org.apache.jena.rdf.model.Model
        Overrides:
        write in class org.apache.jena.rdf.model.impl.ModelCom
      • write

        public UnionModel write​(OutputStream out,
                                String lang)
        Specified by:
        write in interface org.apache.jena.rdf.model.Model
        Overrides:
        write in class org.apache.jena.rdf.model.impl.ModelCom
      • write

        public UnionModel write​(OutputStream out,
                                String lang,
                                String base)
        Specified by:
        write in interface org.apache.jena.rdf.model.Model
        Overrides:
        write in class org.apache.jena.rdf.model.impl.ModelCom
      • getNodeCache

        protected org.apache.jena.atlas.lib.Cache<org.apache.jena.graph.Node,​org.apache.jena.rdf.model.RDFNode> getNodeCache()
        Returns nodes cache.
        Returns:
        Cache with Node as key and RDFNode as value
      • isLocal

        public boolean isLocal​(org.apache.jena.rdf.model.Statement s)
        Answers true if the given statement belongs to the base graph.
        Parameters:
        s - Statement, not null
        Returns:
        boolean
      • isLocal

        public boolean isLocal​(org.apache.jena.rdf.model.Resource s,
                               org.apache.jena.rdf.model.Property p,
                               org.apache.jena.rdf.model.RDFNode o)
        Answers true if the given SPO belongs to the base graph.
        Parameters:
        s - Resource, not null
        p - Property, not null
        o - RDFNode, not null
        Returns:
        boolean
      • findNodeAs

        public <N extends org.apache.jena.rdf.model.RDFNode> N findNodeAs​(org.apache.jena.graph.Node node,
                                                                          Class<N> type)
        Returns a RDFNode for the given type and, if the result is present, caches it node at the model level. The method works silently: normally no exception is expected.
        Type Parameters:
        N - any subtype of RDFNode
        Parameters:
        node - Node
        type - Class-type
        Returns:
        RDFNode or null
        Throws:
        RuntimeException - unexpected misconfiguration (RDF recursion, wrong input, personality mismatch, etc)
        See Also:
        getNodeAs(Node, Class)
      • getNodeAs

        public <N extends org.apache.jena.rdf.model.RDFNode> N getNodeAs​(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. The returned RDF node is cached at the model-level.
        Overrides:
        getNodeAs in class org.apache.jena.enhanced.EnhGraph
        Type Parameters:
        N - a subtype of RDFNode
        Parameters:
        node - a node (assumed to be in this graph)
        type - a type denoting the enhanced facet desired
        Returns:
        an enhanced node, cannot be null
        Throws:
        OntJenaException - unable to construct new RDF view for whatever reasons
        RuntimeException - unexpected misconfiguration (wrong inputs, personality mismatch)
      • fetchNodeAs

        public <N extends org.apache.jena.rdf.model.RDFNode> N fetchNodeAs​(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, taking into account possible graph recursions. For internal usage only.
        Type Parameters:
        N - a subtype of RDFNode
        Parameters:
        node - a node (assumed to be in this graph)
        type - 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
        RuntimeException - unexpected misconfiguration
        See Also:
        getNodeAs(Node, Class)
      • getNodeAsInternal

        protected <N extends org.apache.jena.rdf.model.RDFNode> N getNodeAsInternal​(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. The returned RDF node is cached at the model-level.
        Type Parameters:
        N - a subtype of RDFNode
        Parameters:
        node - a node (assumed to be in this graph)
        type - a type denoting the enhanced facet desired
        Returns:
        an enhanced node
        Throws:
        org.apache.jena.enhanced.PersonalityConfigException - if personality is misconfigured or the given type is absent in it; normally this should not happen
        NullPointerException - if any input is null
        org.apache.jena.shared.JenaException - unable to construct a new RDF view
      • toString

        public String toString()
        Overrides:
        toString in class org.apache.jena.rdf.model.impl.ModelCom