org.eclipse.rdf4j.model

## Interface Model

- All Superinterfaces:
    Collection<Statement>, Iterable<Statement>, NamespaceAware, Serializable, Set<Statement>
  All Known Implementing Classes:
    AbstractModel, DynamicModel, EmptyModel, FilteredModel, LinkedHashModel, SailModel, TreeModel

      public interface Model
      extends Set<Statement>, Serializable, NamespaceAware

  An RDF Model, represented as a `Set` of `Statement`s with predictable iteration order.

  Additional utility functionality for working with `Model` objects is available in the `org.eclipse.rdf4j.model.util.Models` utility class.

  Author:
    James Leigh, Jeen Broekstra

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(Resource subj, IRI pred, Value obj, Resource... contexts)` Adds one or more statements to the model.
    `default boolean` | `add(Resource subj, URI pred, Value obj, Resource... contexts)` Deprecated. since 2.0. Use `add(Resource, IRI, Value, Resource...)` instead.
    `boolean` | `clear(Resource... context)` Removes statements with the specified context exist in this model.
    `boolean` | `contains(Resource subj, IRI pred, Value obj, Resource... contexts)` Determines if statements with the specified subject, predicate, object and (optionally) context exist in this model.
    `default boolean` | `contains(Resource subj, URI pred, Value obj, Resource... contexts)` Deprecated. since 2.0. Use `contains(Resource, IRI, Value, Resource...)` instead.
    `default Set<Resource>` | `contexts()` Returns a `Set` view of the contexts contained in this model.
    `Model` | `filter(Resource subj, IRI pred, Value obj, Resource... contexts)` Returns a filtered view of the statements with the specified subject, predicate, object and (optionally) context.
    `default Model` | `filter(Resource subj, URI pred, Value obj, Resource... contexts)` Deprecated.
    `default Iterable<Statement>` | `getStatements(Resource subject, IRI predicate, Value object, Resource... contexts)` Returns an `Iterable` over all `Statement`s in this Model that match the supplied criteria.
    `Set<Value>` | `objects()` Returns a `Set` view of the objects contained in this model.
    `Set<IRI>` | `predicates()` Returns a `Set` view of the predicates contained in this model.
    `boolean` | `remove(Resource subj, IRI pred, Value obj, Resource... contexts)` Removes statements with the specified subject, predicate, object and (optionally) context exist in this model.
    `default boolean` | `remove(Resource subj, URI pred, Value obj, Resource... contexts)` Deprecated. since 2.0. Use `remove(Resource, IRI, Value, Resource...)` instead.
    `Optional<Namespace>` | `removeNamespace(String prefix)` Removes a namespace declaration by removing the association between a prefix and a namespace name.
    `void` | `setNamespace(Namespace namespace)` Sets the prefix for a namespace.
    `default Namespace` | `setNamespace(String prefix, String name)` Sets the prefix for a namespace.
    `Set<Resource>` | `subjects()` Returns a `Set` view of the subjects contained in this model.
    `Model` | `unmodifiable()` Returns an unmodifiable view of this model.

    - ### Methods inherited from interface java.util.Set

      `add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, spliterator, toArray, toArray`

    - ### Methods inherited from interface java.util.Collection

      `parallelStream, removeIf, stream`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

    - ### Methods inherited from interface org.eclipse.rdf4j.model.NamespaceAware

      `getNamespace, getNamespaces`

- - ### Method Detail

    - #### unmodifiable

          Model unmodifiable()

      Returns an unmodifiable view of this model. This method provides "read-only" access to this model. Query operations on the returned model "read through" to this model, and attempts to modify the returned model, whether direct or via its iterator, result in an `UnsupportedOperationException`.

      Returns:
        an unmodifiable view of the specified set.

    - #### setNamespace

          default Namespace setNamespace(String prefix,
                                         String name)

      Sets the prefix for a namespace. This will replace any existing namespace associated to the prefix.
      Parameters:
        `prefix` - The new prefix.
        `name` - The namespace name that the prefix maps to.
      Returns:
        The `Namespace` object for the given namespace.

    - #### setNamespace

          void setNamespace(Namespace namespace)

      Sets the prefix for a namespace. This will replace any existing namespace associated to the prefix.
      Parameters:
        `namespace` - A `Namespace` object to use in this Model.

    - #### removeNamespace

          Optional<Namespace> removeNamespace(String prefix)

      Removes a namespace declaration by removing the association between a prefix and a namespace name.
      Parameters:
        `prefix` - The namespace prefix of which the assocation with a namespace name is to be removed.
      Returns:
        the previous namespace bound to the prefix or `Optional.empty()`

    - #### contains

          boolean contains(Resource subj,
                           IRI pred,
                           Value obj,
                           Resource... contexts)

      Determines if statements with the specified subject, predicate, object and (optionally) context exist in this model. The `subject`, `predicate` and `object` parameters can be `null` to indicate wildcards. The `contexts` parameter is a wildcard and accepts zero or more values. If no contexts are specified, statements will match disregarding their context. If one or more contexts are specified, statements with a context matching one of these will match. Note: to match statements without an associated context, specify the value `null` and explicitly cast it to type `Resource`.

      Examples: `model.contains(s1, null, null)` is true if any statements in this model have subject `s1`,
      `model.contains(null, null, null, c1)` is true if any statements in this model have context `c1`,
      `model.contains(null, null, null, (Resource)null)` is true if any statements in this model have no associated context,
      `model.contains(null, null, null, c1, c2, c3)` is true if any statements in this model have context `c1`, `c2` or `c3` .

      Parameters:
        `subj` - The subject of the statements to match, `null` to match statements with any subject.
        `pred` - The predicate of the statements to match, `null` to match statements with any predicate.
        `obj` - The object of the statements to match, `null` to match statements with any object.
        `contexts` - The contexts of the statements to match. If no contexts are specified, statements will match disregarding their context. If one or more contexts are specified, statements with a context matching one of these will match.
      Returns:
        `true` if statements match the specified pattern.

    - #### contains

          @Deprecated
          default boolean contains(Resource subj,
                                               URI pred,
                                               Value obj,
                                               Resource... contexts)

      Deprecated. since 2.0. Use `contains(Resource, IRI, Value, Resource...)` instead.

    - #### add

          boolean add(Resource subj,
                      IRI pred,
                      Value obj,
                      Resource... contexts)

      Adds one or more statements to the model. This method creates a statement for each specified context and adds those to the model. If no contexts are specified, a single statement with no associated context is added. If this Model is a filtered Model then null (if context empty) values are permitted and will use the corresponding filtered values.
      Parameters:
        `subj` - The statement's subject.
        `pred` - The statement's predicate.
        `obj` - The statement's object.
        `contexts` - The contexts to add statements to.
      Throws:
        `IllegalArgumentException` - If This Model cannot store the given statement, because it is filtered out of this view.
        `UnsupportedOperationException` - If this Model cannot accept any statements, because it is filtered to the empty set.

    - #### add

          @Deprecated
          default boolean add(Resource subj,
                                          URI pred,
                                          Value obj,
                                          Resource... contexts)

      Deprecated. since 2.0. Use `add(Resource, IRI, Value, Resource...)` instead.

    - #### clear

          boolean clear(Resource... context)

      Removes statements with the specified context exist in this model.
      Parameters:
        `context` - The context of the statements to remove.
      Returns:
        `true` if one or more statements have been removed.

    - #### remove

          boolean remove(Resource subj,
                         IRI pred,
                         Value obj,
                         Resource... contexts)

      Removes statements with the specified subject, predicate, object and (optionally) context exist in this model. The `subject`, `predicate` and `object` parameters can be `null` to indicate wildcards. The `contexts` parameter is a wildcard and accepts zero or more values. If no contexts are specified, statements will be removed disregarding their context. If one or more contexts are specified, statements with a context matching one of these will be removed. Note: to remove statements without an associated context, specify the value `null` and explicitly cast it to type `Resource`.

      Examples: `model.remove(s1, null, null)` removes any statements in this model have subject `s1`,
      `model.remove(null, null, null, c1)` removes any statements in this model have context `c1` ,
      `model.remove(null, null, null, (Resource)null)` removes any statements in this model have no associated context,
      `model.remove(null, null, null, c1, c2, c3)` removes any statements in this model have context `c1`, `c2` or `c3`.

      Parameters:
        `subj` - The subject of the statements to remove, `null` to remove statements with any subject.
        `pred` - The predicate of the statements to remove, `null` to remove statements with any predicate.
        `obj` - The object of the statements to remove, `null` to remove statements with any object.
        `contexts` - The contexts of the statements to remove. If no contexts are specified, statements will be removed disregarding their context. If one or more contexts are specified, statements with a context matching one of these will be removed.
      Returns:
        `true` if one or more statements have been removed.

    - #### remove

          @Deprecated
          default boolean remove(Resource subj,
                                             URI pred,
                                             Value obj,
                                             Resource... contexts)

      Deprecated. since 2.0. Use `remove(Resource, IRI, Value, Resource...)` instead.

    - #### getStatements

          default Iterable<Statement> getStatements(Resource subject,
                                                    IRI predicate,
                                                    Value object,
                                                    Resource... contexts)

      Returns an `Iterable` over all `Statement`s in this Model that match the supplied criteria.

      Examples:

      - `model.getStatements(s1, null, null)` matches all statements that have subject `s1`
      - `model.getStatements(s1, p1, null)` matches all statements that have subject `s1` and predicate `p1`
      - `model.getStatements(null, null, null, c1)` matches all statements that have context `c1`
      - `model.getStatements(null, null, null, (Resource)null)` matches all statements that have no associated context
      - `model.getStatements(null, null, null, c1, c2, c3)` matches all statements that have context `c1`, `c2` or `c3`
      Parameters:
        `subject` - The subject of the statements to match, `null` to match statements with any subject.
        `predicate` - The predicate of the statements to match, `null` to match statements with any predicate.
        `object` - The object of the statements to match, `null` to match statements with any object.
        `contexts` - The contexts of the statements to match. If no contexts are specified, statements will match disregarding their context. If one or more contexts are specified, statements with a context matching any one of these will match. To match statements without an associated context, specify the value `null` and explicitly cast it to type `Resource`.
      Returns:
        an `Iterable` over the statements in this Model that match the specified pattern.
      Since:
        3.2.0
      See Also:
        `filter(Resource, IRI, Value, Resource...)`

    - #### filter

          Model filter(Resource subj,
                       IRI pred,
                       Value obj,
                       Resource... contexts)

      Returns a filtered view of the statements with the specified subject, predicate, object and (optionally) context. The `subject`, `predicate` and `object` parameters can be `null` to indicate wildcards. The `contexts` parameter is a wildcard and accepts zero or more values. If no contexts are specified, statements will match disregarding their context. If one or more contexts are specified, statements with a context matching one of these will match. Note: to match statements without an associated context, specify the value `null` and explicitly cast it to type `Resource`.

      The returned model is backed by this Model, so changes to this Model are reflected in the returned model, and vice-versa. If this Model is modified while an iteration over the returned model is in progress (except through the iterator's own `remove` operation), the results of the iteration are undefined. The model supports element removal, which removes the corresponding statement from this Model, via the `Iterator.remove`, `Set.remove`, `removeAll`, `retainAll`, and `clear` operations. The statements passed to the `add` and `addAll` operations must match the parameter pattern.

      Examples: `model.filter(s1, null, null)` matches all statements that have subject `s1`,
      `model.filter(null, null, null, c1)` matches all statements that have context `c1`,
      `model.filter(null, null, null, (Resource)null)` matches all statements that have no associated context,
      `model.filter(null, null, null, c1, c2, c3)` matches all statements that have context `c1`, `c2` or `c3`.

      Parameters:
        `subj` - The subject of the statements to match, `null` to match statements with any subject.
        `pred` - The predicate of the statements to match, `null` to match statements with any predicate.
        `obj` - The object of the statements to match, `null` to match statements with any object.
        `contexts` - The contexts of the statements to match. If no contexts are specified, statements will match disregarding their context. If one or more contexts are specified, statements with a context matching one of these will match.
      Returns:
        The statements that match the specified pattern.
      See Also:
        `getStatements(Resource, IRI, Value, Resource...)`

    - #### filter

          @Deprecated
          default Model filter(Resource subj,
                                           URI pred,
                                           Value obj,
                                           Resource... contexts)

      Deprecated.

    - #### subjects

          Set<Resource> subjects()

      Returns a `Set` view of the subjects contained in this model. The set is backed by the model, so changes to the model are reflected in the set, and vice-versa. If the model is modified while an iteration over the set is in progress (except through the iterator's own `remove` operation), the results of the iteration are undefined. The set supports element removal, which removes all statements from the model for which that element is a subject value, via the `Iterator.remove`, `Set.remove`, `removeAll`, `retainAll`, and `clear` operations. It does not support the `add` or `addAll` operations if the parameters `pred` or `obj` are null.
      Returns:
        a set view of the subjects contained in this model

    - #### predicates

          Set<IRI> predicates()

      Returns a `Set` view of the predicates contained in this model. The set is backed by the model, so changes to the model are reflected in the set, and vice-versa. If the model is modified while an iteration over the set is in progress (except through the iterator's own `remove` operation), the results of the iteration are undefined. The set supports element removal, which removes all statements from the model for which that element is a predicate value, via the `Iterator.remove`, `Set.remove`, `removeAll`, `retainAll`, and `clear` operations. It does not support the `add` or `addAll` operations if the parameters `subj` or `obj` are null.
      Returns:
        a set view of the predicates contained in this model

    - #### objects

          Set<Value> objects()

      Returns a `Set` view of the objects contained in this model. The set is backed by the model, so changes to the model are reflected in the set, and vice-versa. If the model is modified while an iteration over the set is in progress (except through the iterator's own `remove` operation), the results of the iteration are undefined. The set supports element removal, which removes all statements from the model for which that element is an object value, via the `Iterator.remove`, `Set.remove`, `removeAll`, `retainAll`, and `clear` operations. It does not support the `add` or `addAll` operations if the parameters `subj` or `pred` are null.
      Returns:
        a set view of the objects contained in this model

    - #### contexts

          default Set<Resource> contexts()

      Returns a `Set` view of the contexts contained in this model. The set is backed by the model, so changes to the model are reflected in the set, and vice-versa. If the model is modified while an iteration over the set is in progress (except through the iterator's own `remove` operation), the results of the iteration are undefined. The set supports element removal, which removes all statements from the model for which that element is a context value, via the `Iterator.remove`, `Set.remove`, `removeAll`, `retainAll`, and `clear` operations. It does not support the `add` or `addAll` operations if the parameters `subj` , `pred` or `obj` are null.
      Returns:
        a set view of the contexts contained in this model

Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.