Class WrapperResource

  • All Implemented Interfaces:
    org.apache.jena.graph.FrontsNode, org.apache.jena.rdf.model.RDFNode, org.apache.jena.rdf.model.Resource

    public abstract class WrapperResource
    extends org.apache.jena.rdf.model.impl.ResourceImpl
    A wrapper for resources which contains methods that aid authoring wrapping classes.

    All methods require a predicate and a value mapping function.

    This table details the behavior of singular getter helper methods depending on the number of matching statements in the underlying graph:

     ┌───────────────┬───────┬────────┬────────┐
     │               │   0   │   1    │   >1   │
     ├───────────────┼───────┼────────┼────────┤
     │ anyOrNull     │ null  │ single │ random │
     │ anyOrThrow    │ throw │ single │ random │
     │ singleOrNull  │ null  │ single │ throw  │
     │ singleOrThrow │ throw │ single │ throw  │
     └───────────────┴───────┴────────┴────────┘
     

    This table details the behavior of plural getter helper methods in terms of reflecting changes to the underlying graph after calling them:

     ┌──────────┬─────────┐
     │ iterator │ static  │
     │ snapshot │ static  │
     │ live     │ dynamic │
     └──────────┴─────────┘
     

    This table details the behavior of setter helper methods in terms of effect on existing statements in the underlying graph and given values:

     ┌───────────────────┬──────────┬────────────┐
     │                   │ existing │ null value │
     ├───────────────────┼──────────┼────────────┤
     │ overwrite         │ remove   │ throw      │
     │ overwriteNullable │ remove   │ ignore     │
     │ add               │ leave    │ throw      │
     └───────────────────┴──────────┴────────────┘
     
    Author:
    Samu Lang
    • Field Summary

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

        factory, rdfNodeFactory
      • Fields inherited from class org.apache.jena.enhanced.EnhNode

        enhGraph, node
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected WrapperResource​(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph model)
      Create a new subject resource with a backing EnhGraph structure.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected <T> void add​(org.apache.jena.rdf.model.Property p, Iterable<T> v, NodeMapping<T> m)
      An additive converting singular setter helper for expected cardinality 0..*.
      protected <T> void add​(org.apache.jena.rdf.model.Property p, T v, NodeMapping<T> m)
      An additive converting singular setter helper for expected cardinality 0..*.
      protected <T> T anyOrNull​(org.apache.jena.rdf.model.Property p, ValueMapping<T> m)
      A converting singular getter helper for expected cardinality 0..1 that ignores overflow.
      protected <T> T anyOrThrow​(org.apache.jena.rdf.model.Property p, ValueMapping<T> m)
      A converting singular getter helper for expected cardinality 1..1 that ignores overflow.
      protected <T> Iterator<T> objectIterator​(org.apache.jena.rdf.model.Property p, ValueMapping<T> m)
      A static converting plural getter helper for expected cardinality 0..*.
      protected <T> Set<T> objects​(org.apache.jena.rdf.model.Property p, NodeMapping<T> nm, ValueMapping<T> vm)
      A dynamic converting plural getter helper for expected cardinality 0..*.
      protected <T> Set<T> objectsReadOnly​(org.apache.jena.rdf.model.Property p, ValueMapping<T> m)
      A static converting plural getter helper for expected cardinality 0..*.
      protected <T> Stream<T> objectStream​(org.apache.jena.rdf.model.Property p, ValueMapping<T> m)
      A static converting plural getter helper for expected cardinality 0..*.
      protected <T> void overwrite​(org.apache.jena.rdf.model.Property p, Iterable<T> v, NodeMapping<T> m)
      A destructive converting plural setter helper for expected cardinality 1..*.
      protected <T> void overwrite​(org.apache.jena.rdf.model.Property p, T v, NodeMapping<T> m)
      A destructive converting singular setter helper for expected cardinality 1..1.
      protected <T> void overwriteNullable​(org.apache.jena.rdf.model.Property p, Iterable<T> v, NodeMapping<T> m)
      A destructive converting plural setter helper for expected cardinality 0..*.
      protected <T> void overwriteNullable​(org.apache.jena.rdf.model.Property p, T v, NodeMapping<T> m)
      A destructive converting singular setter helper for expected cardinality 0..1.
      protected <T> T singleOrNull​(org.apache.jena.rdf.model.Property p, ValueMapping<T> m)
      A converting singular getter helper for expected cardinality 0..1 that forbids overflow.
      protected <T> T singleOrThrow​(org.apache.jena.rdf.model.Property p, ValueMapping<T> m)
      A converting singular getter helper for expected cardinality 1..1 that forbids overflow.
      • Methods inherited from class org.apache.jena.rdf.model.impl.ResourceImpl

        abort, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, asLiteral, asResource, begin, commit, getId, getLocalName, getModel, getModelCom, getNameSpace, getProperty, getProperty, getPropertyResourceValue, getRequiredProperty, getRequiredProperty, getStmtTerm, getURI, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasProperty, hasProperty, hasProperty, hasProperty, hasURI, inModel, listProperties, listProperties, listProperties, mustHaveModel, removeAll, removeProperties, toString, visitWith
      • Methods inherited from class org.apache.jena.enhanced.EnhNode

        as, asNode, canAs, canSupport, convertTo, equals, getGraph, getPersonality, hashCode, isAnon, isLiteral, isResource, isStmtResource, isURIResource, isValid, viewAs
      • Methods inherited from class org.apache.jena.enhanced.Polymorphic

        addView, alreadyHasView, asInternal, supports
      • Methods inherited from interface org.apache.jena.graph.FrontsNode

        asNode
      • Methods inherited from interface org.apache.jena.rdf.model.RDFNode

        as, canAs, isAnon, isLiteral, isResource, isStmtResource, isURIResource
      • Methods inherited from interface org.apache.jena.rdf.model.Resource

        equals
    • Constructor Detail

      • WrapperResource

        protected WrapperResource​(org.apache.jena.graph.Node node,
                                  org.apache.jena.enhanced.EnhGraph model)
        Create a new subject resource with a backing EnhGraph structure.
        Parameters:
        node - the subject node
        model - the rdf model
    • Method Detail

      • anyOrNull

        protected <T> T anyOrNull​(org.apache.jena.rdf.model.Property p,
                                  ValueMapping<T> m)
        A converting singular getter helper for expected cardinality 0..1 that ignores overflow.
        Type Parameters:
        T - the type of values returned the type of values returned
        Parameters:
        p - the predicate to query
        m - the mapping applied to result nodes
        Returns:
        the converted object of an arbitrary statement with this subject and the given predicate or null if there are no such statements
      • anyOrThrow

        protected <T> T anyOrThrow​(org.apache.jena.rdf.model.Property p,
                                   ValueMapping<T> m)
        A converting singular getter helper for expected cardinality 1..1 that ignores overflow.
        Type Parameters:
        T - the type of values returned
        Parameters:
        p - the predicate to query
        m - the mapping applied to result nodes
        Returns:
        the converted object of an arbitrary statement with this subject and the given predicate
        Throws:
        org.apache.jena.shared.PropertyNotFoundException - if there are no such statements
      • singleOrNull

        protected <T> T singleOrNull​(org.apache.jena.rdf.model.Property p,
                                     ValueMapping<T> m)
        A converting singular getter helper for expected cardinality 0..1 that forbids overflow.
        Type Parameters:
        T - the type of values returned
        Parameters:
        p - the predicate to query
        m - the mapping applied to result nodes
        Returns:
        the converted object of the only statement with this subject and the given predicate, or null if there is no such statement
        Throws:
        IllegalStateException - if there are multiple such statements
      • singleOrThrow

        protected <T> T singleOrThrow​(org.apache.jena.rdf.model.Property p,
                                      ValueMapping<T> m)
        A converting singular getter helper for expected cardinality 1..1 that forbids overflow.
        Type Parameters:
        T - the type of values returned
        Parameters:
        p - the predicate to query
        m - the mapping applied to result nodes
        Returns:
        the converted object of the only statement with this subject and the given predicate
        Throws:
        org.apache.jena.shared.PropertyNotFoundException - if there are no such statements
        IllegalStateException - if there are multiple such statements
      • objectIterator

        protected <T> Iterator<T> objectIterator​(org.apache.jena.rdf.model.Property p,
                                                 ValueMapping<T> m)
        A static converting plural getter helper for expected cardinality 0..*.
        Type Parameters:
        T - the type of values returned
        Parameters:
        p - the predicate to query
        m - the mapping applied to result nodes
        Returns:
        the converted objects of statements with this subject and the given predicate
      • objectsReadOnly

        protected <T> Set<T> objectsReadOnly​(org.apache.jena.rdf.model.Property p,
                                             ValueMapping<T> m)
        A static converting plural getter helper for expected cardinality 0..*.
        Type Parameters:
        T - the type of values returned
        Parameters:
        p - the predicate to query
        m - the mapping applied to result nodes
        Returns:
        a static set view over converted objects of statements with this subject and the given predicate
      • objects

        protected <T> Set<T> objects​(org.apache.jena.rdf.model.Property p,
                                     NodeMapping<T> nm,
                                     ValueMapping<T> vm)
        A dynamic converting plural getter helper for expected cardinality 0..*.
        Type Parameters:
        T - the type of values returned
        Parameters:
        p - the predicate to query
        nm - the input mapping to apply to values
        vm - the output mapping to apply to nodes
        Returns:
        a dynamic set view over converted objects of statements with this subject and the given predicate
      • objectStream

        protected <T> Stream<T> objectStream​(org.apache.jena.rdf.model.Property p,
                                             ValueMapping<T> m)
        A static converting plural getter helper for expected cardinality 0..*.
        Type Parameters:
        T - the type of values returned
        Parameters:
        p - the predicate to query
        m - the mapping applied to result terms
        Returns:
        a static stream of converted objects of statements with this subject and the given predicate
      • overwrite

        protected <T> void overwrite​(org.apache.jena.rdf.model.Property p,
                                     T v,
                                     NodeMapping<T> m)
        A destructive converting singular setter helper for expected cardinality 1..1.
        Type Parameters:
        T - the type of values returned
        Parameters:
        p - the predicate to query
        v - the value to assert as object in the graph
        m - the mapping applied to result nodes
        Throws:
        NullPointerException - if the given value is null
      • overwrite

        protected <T> void overwrite​(org.apache.jena.rdf.model.Property p,
                                     Iterable<T> v,
                                     NodeMapping<T> m)
        A destructive converting plural setter helper for expected cardinality 1..*.
        Type Parameters:
        T - the type of values returned
        Parameters:
        p - the predicate to query
        v - the value to assert as object in the graph
        m - the mapping applied to result nodes
        Throws:
        NullPointerException - if the given value is null
        NullPointerException - if the given value contains null elements
      • overwriteNullable

        protected <T> void overwriteNullable​(org.apache.jena.rdf.model.Property p,
                                             Iterable<T> v,
                                             NodeMapping<T> m)
        A destructive converting plural setter helper for expected cardinality 0..*.
        Type Parameters:
        T - the type of values returned
        Parameters:
        p - the predicate to query
        v - the value to assert as object in the graph
        m - the mapping applied to result nodes
        Throws:
        NullPointerException - if the given value is not null and contains null elements
      • overwriteNullable

        protected <T> void overwriteNullable​(org.apache.jena.rdf.model.Property p,
                                             T v,
                                             NodeMapping<T> m)
        A destructive converting singular setter helper for expected cardinality 0..1.
        Type Parameters:
        T - the type of values returned
        Parameters:
        p - the predicate to query
        v - the value to assert as object in the graph
        m - the mapping applied to result nodes
      • add

        protected <T> void add​(org.apache.jena.rdf.model.Property p,
                               T v,
                               NodeMapping<T> m)
        An additive converting singular setter helper for expected cardinality 0..*.
        Type Parameters:
        T - the type of values returned
        Parameters:
        p - the predicate to query
        v - the value to assert as object in the graph
        m - the mapping applied to result nodes
        Throws:
        NullPointerException - if the given value is null
      • add

        protected <T> void add​(org.apache.jena.rdf.model.Property p,
                               Iterable<T> v,
                               NodeMapping<T> m)
        An additive converting singular setter helper for expected cardinality 0..*.
        Type Parameters:
        T - the type of values returned
        Parameters:
        p - the predicate to query
        v - the value to assert as object in the graph
        m - the mapping applied to result nodes
        Throws:
        NullPointerException - if the given value is null
        NullPointerException - if the given value contains null elements