Class ModelCom

java.lang.Object
org.apache.jena.enhanced.EnhGraph
org.apache.jena.rdf.model.impl.ModelCom
All Implemented Interfaces:
Model, ModelCon, ModelGraphInterface, RDFReaderF, RDFWriterF, Lock, PrefixMapping
Direct Known Subclasses:
InfModelImpl, MonitorModel, OntModelImpl

public class ModelCom extends EnhGraph implements Model, PrefixMapping, Lock
Common methods for model implementations.

This class implements common methods, mainly convenience methods, for model implementations. It is intended use is as a base class from which model implementations can be derived.

  • Constructor Details

    • ModelCom

      public ModelCom(Graph base)
      make a model based on the specified graph
    • ModelCom

      public ModelCom(Graph base, Personality<RDFNode> personality)
  • Method Details

    • getGraph

      public Graph getGraph()
      Description copied from interface: ModelGraphInterface
      Answer the Graph which this Model is presenting.
      Specified by:
      getGraph in interface ModelGraphInterface
    • asRDFNode

      public RDFNode asRDFNode(Node n)
      Description copied from interface: ModelGraphInterface
      Answer an RDF node wrapping n suitably; URI nodes become Resources with the same URI, blank nodes become Resources with URI null but the same AnonId, and literal nodes become Literals with n as their value carrier.
      Specified by:
      asRDFNode in interface ModelGraphInterface
    • wrapAsResource

      public Resource wrapAsResource(Node n)
      Specified by:
      wrapAsResource in interface ModelGraphInterface
    • getResource

      @Deprecated public Resource getResource(String uri, ResourceF f)
      Deprecated.
      Description copied from interface: ModelCon
      Return a Resource instance in this model.

      Subsequent operations on the returned object may modify this model.

      The resource is assumed to already exist in the model. If it does not, createResource should be used instead.

      Specified by:
      getResource in interface ModelCon
      Parameters:
      uri - the URI of the resource
      f - the factory object
      Returns:
      a resource instance created by the factory provided
    • addLiteral

      public Model addLiteral(Resource s, Property p, boolean o)
      Description copied from interface: ModelCon
      Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.
      Specified by:
      addLiteral in interface ModelCon
    • addLiteral

      public Model addLiteral(Resource s, Property p, long o)
      Description copied from interface: ModelCon
      Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.
      Specified by:
      addLiteral in interface ModelCon
    • addLiteral

      public Model addLiteral(Resource s, Property p, int o)
      Description copied from interface: ModelCon
      Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.
      Specified by:
      addLiteral in interface ModelCon
    • addLiteral

      public Model addLiteral(Resource s, Property p, char o)
      Description copied from interface: ModelCon
      Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.
      Specified by:
      addLiteral in interface ModelCon
    • addLiteral

      public Model addLiteral(Resource s, Property p, float o)
      Description copied from interface: ModelCon
      Add the statement (s, p, o') to the model, where o' is the typed literal corresponding to o. Answer this model.
      Specified by:
      addLiteral in interface ModelCon
    • addLiteral

      public Model addLiteral(Resource s, Property p, double o)
      Description copied from interface: ModelCon
      Add the statement (s, p, o') to the model, where o' is the typed literal corresponding to o. Answer this model.
      Specified by:
      addLiteral in interface ModelCon
    • add

      public Model add(Resource s, Property p, String o)
      Description copied from interface: ModelCon
      add a statement to this model.
      Specified by:
      add in interface ModelCon
      Parameters:
      s - the subject of the statement to add
      p - the predicate of the statement to add
      o - the object of the statement to add
      Returns:
      this model
    • add

      public Model add(Resource s, Property p, String o, boolean wellFormed)
      Description copied from interface: ModelCon
      add a statement to this model.
      Specified by:
      add in interface ModelCon
      Parameters:
      s - the subject of the statement to add
      p - the predicate of the statement to add
      o - the object of the statement to add
      wellFormed - true if o is well formed XML
      Returns:
      this model
    • add

      public Model add(Resource s, Property p, String o, String lang, boolean wellFormed)
    • add

      public Model add(Resource s, Property p, String lex, RDFDatatype datatype)
      Description copied from interface: ModelCon
      add a statement to this model.
      Specified by:
      add in interface ModelCon
      Parameters:
      s - the subject of the statement to add
      p - the predicate of the statement to add
      lex - the lexcial form of the literal
      datatype - the datatype of the literal
      Returns:
      this model
    • add

      public Model add(Resource s, Property p, String o, String l)
      Description copied from interface: ModelCon
      add a statement to this model.
      Specified by:
      add in interface ModelCon
      Parameters:
      s - the subject of the statement to add
      p - the predicate of the statement to add
      o - the object of the statement to add
      l - the language associated with the object
      Returns:
      this model
    • addLiteral

      @Deprecated public Model addLiteral(Resource s, Property p, Object o)
      Deprecated.
      Description copied from interface: ModelCon
      add a statement to this model. Applications should use typed literals whereever possible.
      Specified by:
      addLiteral in interface ModelCon
      Parameters:
      s - the subject of the statement to add
      p - the predicate of the statement to add
      o - the object of the statement to add
      Returns:
      this model
    • addLiteral

      public Model addLiteral(Resource s, Property p, Literal o)
      Description copied from interface: ModelCon
      add a statement to this model.
      Specified by:
      addLiteral in interface ModelCon
      Parameters:
      s - the subject of the statement to add
      p - the predicate of the statement to add
      o - the object of the statement to add
      Returns:
      this model
    • add

      public Model add(StmtIterator iter)
      Description copied from interface: Model
      Add all the statements returned by an iterator to this model.
      Specified by:
      add in interface Model
      Parameters:
      iter - An iterator which returns the statements to be added.
      Returns:
      this model
    • add

      public Model add(Model m)
      Description copied from interface: Model
      Add all the statements in another model to this model, including the reified statements.
      Specified by:
      add in interface Model
      Parameters:
      m - The model whose statements are to be added.
      Returns:
      this model
    • getReader

      public RDFReaderI getReader()
      Description copied from interface: RDFReaderF
      return an RDFReader instance for the default serialization language.
      Specified by:
      getReader in interface Model
      Specified by:
      getReader in interface RDFReaderF
      Returns:
      an RDFReader instance for the default serialization language.
    • getReader

      public RDFReaderI getReader(String lang)
      Description copied from interface: RDFReaderF
      return an RDFReader instance for the specified serialization language.
      Specified by:
      getReader in interface Model
      Specified by:
      getReader in interface RDFReaderF
      Parameters:
      lang - the serialization language - null selects the default
      Returns:
      the RDFWriter instance
    • read

      public Model read(String url)
      Description copied from interface: Model
      Add the RDF statements from a document. Uses content negotiation to request appropriate mime types. If the content type is not found, it may guess from the URL.

      See Model for a description of how to traverse a firewall.

      See "Reading and Writing RDF in Apache Jena" for more information about determining the syntax.

      Specified by:
      read in interface Model
      Parameters:
      url - of the document containing the RDF statements.
      Returns:
      this model
    • read

      public Model read(Reader reader, String base)
      Description copied from interface: Model
      Using this method is often a mistake. Add statements from an RDF/XML serialization. It is generally better to use an InputStream if possible, otherwise there is a danger of a mismatch between the character encoding of say the FileReader and the character encoding of the data in the file. It is better to explicitly set the serialization format. See Model.read(InputStream, String, String) for explicitily setting the serialization language.

      See "Reading and Writing RDF in Apache Jena" for more information about concrete syntaxes.

      Specified by:
      read in interface Model
      base - the base uri to be used when converting relative URI's to absolute URI's and to guess the RDF serialization syntax.
      Returns:
      the current model
    • read

      public Model read(InputStream reader, String base)
      Description copied from interface: Model
      Add statements from a document. This method assumes the concrete syntax is RDF/XML. See Model.read(InputStream, String, String) for explicitly setting the language.

      See "Reading and Writing RDF in Apache Jena" for more information about concrete syntaxes.

      Specified by:
      read in interface Model
      Parameters:
      reader - the input stream
      base - the base uri to be used when converting relative URI's to absolute URI's. (Resolving relative URIs and fragment IDs is done by prepending the base URI to the relative URI/fragment.) If there are no relative URIs in the source, this argument may safely be null. If the base is the empty string, then relative URIs will be retained in the model. This is typically unwise and will usually generate errors when writing the model back out.
      Returns:
      the current model
    • read

      public Model read(String url, String lang)
      Description copied from interface: Model
      Add statements from a serializion in language lang to the model.
      Predefined values for lang are "RDF/XML", "N-TRIPLE", "TURTLE" (or "TTL") and "N3". null represents the default language, "RDF/XML". "RDF/XML-ABBREV" is a synonym for "RDF/XML".

      See Model for a description of how to traverse a firewall.

      See "Reading and Writing RDF in Apache Jena" for more information about concrete syntaxes.

      Specified by:
      read in interface Model
      Parameters:
      url - a string representation of the url to read from
      lang - the language of the serialization
      Returns:
      this model
    • read

      public Model read(String url, String base, String lang)
      Description copied from interface: Model
      Read into this model the RDF at url, using baseURI as the base URI if it is non-null. The RDF is assumed to be RDF/XML unless lang is non-null, in which case it names the language to be used. Answer this model.
      Specified by:
      read in interface Model
    • read

      public Model read(Reader reader, String base, String lang)
      Description copied from interface: Model
      Using this method is often a mistake. Add RDF statements represented in language lang to the model.
      Predefined values for lang are "RDF/XML", "N-TRIPLE", "TURTLE" (or "TTL") and "N3". null represents the default language, "RDF/XML". "RDF/XML-ABBREV" is a synonym for "RDF/XML".
      It is generally better to use an InputStream if possible. Model.read(InputStream,String), otherwise there is a danger of a mismatch between the character encoding of say the FileReader and the character encoding of the data in the file.
      Specified by:
      read in interface Model
      Parameters:
      reader - the source of the input serialization
      base - the base uri to be used when converting relative URI's to absolute URI's. (Resolving relative URIs and fragment IDs is done by prepending the base URI to the relative URI/fragment.) If there are no relative URIs in the source, this argument may safely be null. If the base is the empty string, then relative URIs will be retained in the model. This is typically unwise and will usually generate errors when writing the model back out.
      lang - the language of the serialization null selects the default
      Returns:
      this model
    • read

      public Model read(InputStream reader, String base, String lang)
      Description copied from interface: Model
      Add RDF statements represented in language lang to the model.
      Predefined values for lang are "RDF/XML", "N-TRIPLE", "TURTLE" (or "TTL") and "N3". null represents the default language, "RDF/XML". "RDF/XML-ABBREV" is a synonym for "RDF/XML".
      Specified by:
      read in interface Model
      Parameters:
      reader - the source of the input serialization
      base - the base uri to be used when converting relative URI's to absolute URI's. (Resolving relative URIs and fragment IDs is done by prepending the base URI to the relative URI/fragment.) If there are no relative URIs in the source, this argument may safely be null. If the base is the empty string, then relative URIs will be retained in the model. This is typically unwise and will usually generate errors when writing the model back out.

      See "Reading and Writing RDF in Apache Jena" for more information about concrete syntaxes.

      lang - the language of the serialization null selects the default
      Returns:
      this model
    • getWriter

      public RDFWriterI getWriter()
      Get the model's writer after priming it with the model's namespace prefixes.
      Specified by:
      getWriter in interface Model
      Specified by:
      getWriter in interface RDFWriterF
      Returns:
      an RDFWriter instance for the default serialization language.
    • getWriter

      public RDFWriterI getWriter(String lang)
      Get the model's writer after priming it with the model's namespace prefixes.
      Specified by:
      getWriter in interface Model
      Specified by:
      getWriter in interface RDFWriterF
      Parameters:
      lang - the serialization language - null selects the default
      Returns:
      the RDFWriter instance
    • write

      public Model write(Writer writer)
      Description copied from interface: Model

      Write the model as an XML document. It is often better to use an OutputStream rather than a Writer, since this will avoid character encoding errors.

      Specified by:
      write in interface Model
      Parameters:
      writer - A writer to which the XML will be written
      Returns:
      this model
    • write

      public Model write(Writer writer, String lang)
      Description copied from interface: Model

      Write a serialized representation of a model in a specified language. It is often better to use an OutputStream rather than a Writer, since this will avoid character encoding errors.

      The language in which to write the model is specified by the lang argument. Predefined values are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value, represented by null is "RDF/XML".

      Specified by:
      write in interface Model
      Parameters:
      writer - The output writer
      lang - The output language
      Returns:
      this model
    • write

      public Model write(Writer writer, String lang, String base)
      Description copied from interface: Model

      Write a serialized representation of a model in a specified language. It is often better to use an OutputStream rather than a Writer, since this will avoid character encoding errors.

      The language in which to write the model is specified by the lang argument. Predefined values are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value, represented by null, is "RDF/XML".

      Specified by:
      write in interface Model
      Parameters:
      writer - The output writer
      lang - The language in which the RDF should be written
      base - The base uri for relative URI calculations. null means use only absolute URI's.
      Returns:
      this model
    • write

      public Model write(OutputStream writer)
      Description copied from interface: Model

      Write a serialization of this model as an XML document.

      The language in which to write the model is specified by the lang argument. Predefined values are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value is represented by null is "RDF/XML".

      Specified by:
      write in interface Model
      Parameters:
      writer - The output stream to which the XML will be written
      Returns:
      This model
    • write

      public Model write(OutputStream writer, String lang)
      Description copied from interface: Model

      Write a serialized representation of this model in a specified language.

      The language in which to write the model is specified by the lang argument. Predefined values are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value, represented by null, is "RDF/XML".

      Specified by:
      write in interface Model
      Parameters:
      writer - The output stream to which the RDF is written
      lang - The output language
      Returns:
      This model
    • write

      public Model write(OutputStream writer, String lang, String base)
      Description copied from interface: Model

      Write a serialized representation of a model in a specified language.

      The language in which to write the model is specified by the lang argument. Predefined values are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value, represented by null, is "RDF/XML".

      Specified by:
      write in interface Model
      Parameters:
      writer - The output stream to which the RDF is written
      lang - The language in which the RDF should be written
      base - The base uri to use when writing relative URI's. null means use only absolute URI's. This is used for relative URIs that would be resolved against the document retrieval URL. For some values of lang, this value may be included in the output.
      Returns:
      This model
    • remove

      public Model remove(Statement s)
      Description copied from interface: Model
      Removes a statement.

      The statement with the same subject, predicate and object as that supplied will be removed from the model.

      Specified by:
      remove in interface Model
      Parameters:
      s - The statement to be removed.
      Returns:
      this model
    • remove

      public Model remove(Resource s, Property p, RDFNode o)
      Description copied from interface: ModelCon
      remove the statement (s, p, o) from this model and answer this model. None of s, p, o are permitted to be null: for wildcard removal, see removeAll.
      Specified by:
      remove in interface ModelCon
    • remove

      public Model remove(StmtIterator iter)
      Description copied from interface: ModelCon
      Remove all the Statements returned by an iterator.
      Specified by:
      remove in interface ModelCon
      Parameters:
      iter - the iterator which returns the statements to be removed.
      Returns:
      this model
    • remove

      public Model remove(Model m)
      Description copied from interface: ModelCon
      Remove all the Statements in a given model, including reified statements
      Specified by:
      remove in interface ModelCon
      Parameters:
      m - the model containing the statements to be removed.
      Returns:
      this model
    • removeAll

      public Model removeAll()
      Description copied from interface: Model
      Remove all the statements from this model.
      Specified by:
      removeAll in interface Model
    • removeAll

      public Model removeAll(Resource s, Property p, RDFNode o)
      Description copied from interface: Model
      Remove all the statements matching (s, p, o) from this model.
      Specified by:
      removeAll in interface Model
    • containsLiteral

      public boolean containsLiteral(Resource s, Property p, boolean o)
      Description copied from interface: ModelCon
      Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.
      Specified by:
      containsLiteral in interface ModelCon
    • containsLiteral

      public boolean containsLiteral(Resource s, Property p, long o)
      Description copied from interface: ModelCon
      Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.
      Specified by:
      containsLiteral in interface ModelCon
    • containsLiteral

      public boolean containsLiteral(Resource s, Property p, int o)
      Description copied from interface: ModelCon
      Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.
      Specified by:
      containsLiteral in interface ModelCon
    • containsLiteral

      public boolean containsLiteral(Resource s, Property p, char o)
      Description copied from interface: ModelCon
      Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.
      Specified by:
      containsLiteral in interface ModelCon
    • containsLiteral

      public boolean containsLiteral(Resource s, Property p, float o)
      Description copied from interface: ModelCon
      Answer true iff this model contains (s, p, o') where o' is the typed literal corresponding to o.
      Specified by:
      containsLiteral in interface ModelCon
    • containsLiteral

      public boolean containsLiteral(Resource s, Property p, double o)
      Description copied from interface: ModelCon
      Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.
      Specified by:
      containsLiteral in interface ModelCon
    • contains

      public boolean contains(Resource s, Property p, String o)
      Description copied from interface: ModelCon
      Determine if a statement is present in this model.
      Specified by:
      contains in interface ModelCon
      Parameters:
      s - The subject of the statment tested.
      p - The predicate of the statement tested.
      o - The object of the statement tested.
      Returns:
      true if the statement with subject s, property p and object o is in the model, false otherwise
    • contains

      public boolean contains(Resource s, Property p, String o, String l)
      Description copied from interface: ModelCon
      Determine if a statement is present in this model.
      Specified by:
      contains in interface ModelCon
      Parameters:
      s - The subject of the statment tested.
      p - The predicate of the statement tested.
      o - The object of the statement tested.
      l - the language associated with the object
      Returns:
      true if the statement with subject s, property p and object o is in the model, false otherwise
    • containsLiteral

      public boolean containsLiteral(Resource s, Property p, Object o)
      Description copied from interface: ModelCon
      Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.
      Specified by:
      containsLiteral in interface ModelCon
    • containsAny

      public boolean containsAny(Model model)
      Description copied from interface: Model
      Determine if any of the statements in a model are also contained in this model.
      Specified by:
      containsAny in interface Model
      Parameters:
      model - the model containing the statements to be tested
      Returns:
      true if any of the statements in model are also contained in this model and false otherwise.
    • containsAll

      public boolean containsAll(Model model)
      Description copied from interface: Model
      Determine if all of the statements in a model are also contained in this model.
      Specified by:
      containsAll in interface Model
      Parameters:
      model - the model containing the statements to be tested
      Returns:
      true if all of the statements in model are also contained in this model and false otherwise.
    • containsAny

      public boolean containsAny(StmtIterator iter)
      Description copied from interface: Model
      Determine if any of the statements returned by an iterator are contained in this model.
      Specified by:
      containsAny in interface Model
      Parameters:
      iter - an iterator of the statements to be tested
      Returns:
      true if any of the statements returns by iter are contained in this model and false otherwise.
    • containsAll

      public boolean containsAll(StmtIterator iter)
      Description copied from interface: Model
      Determine if all of the statements returned by an iterator are contained in this model.
      Specified by:
      containsAll in interface Model
      Parameters:
      iter - an iterator of the statements to be tested
      Returns:
      true if any of the statements returns by iter are contained in this model and false otherwise.
    • listStatements

      public StmtIterator listStatements(Resource S, Property P, RDFNode O)
      Description copied from interface: Model
      Find all the statements matching a pattern.

      Return an iterator over all the statements in a model that match a pattern. The statements selected are those whose subject matches the subject argument, whose predicate matches the predicate argument and whose object matches the object argument. If an argument is null it matches anything.

      Specified by:
      listStatements in interface Model
      Parameters:
      S - The subject sought
      P - The predicate sought
      O - The value sought
      Returns:
      an iterator over the subjects
    • listStatements

      public StmtIterator listStatements(Resource S, Property P, String O)
      Description copied from interface: ModelCon
      Find all the statements matching a pattern.

      Return an iterator over all the statements in a model that match a pattern. The statements selected are those whose subject matches the subject argument, whose predicate matches the predicate argument and whose object matchesthe object argument.

      Specified by:
      listStatements in interface ModelCon
      Parameters:
      S - The subject sought
      P - The predicate sought
      O - The value sought
      Returns:
      an iterator over the subjects
    • listStatements

      public StmtIterator listStatements(Resource S, Property P, String O, String L)
      Description copied from interface: ModelCon
      Find all the statements matching a pattern.

      Return an iterator over all the statements in a model that match a pattern. The statements selected are those whose subject matches the subject argument, whose predicate matches the predicate argument and whose object matchesthe object argument. If an argument is null it matches anything.

      Specified by:
      listStatements in interface ModelCon
      Parameters:
      S - The subject sought
      P - The predicate sought
      O - The value sought
      L - The lang code ofthe string.
      Returns:
      an iterator over the subjects
    • listLiteralStatements

      public StmtIterator listLiteralStatements(Resource S, Property P, boolean O)
      Description copied from interface: ModelCon
      Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matches subject, P matches predicate, and O matches the typed literal corresponding to object.
      Specified by:
      listLiteralStatements in interface ModelCon
    • listLiteralStatements

      public StmtIterator listLiteralStatements(Resource S, Property P, long O)
      Description copied from interface: ModelCon
      Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matches subject, P matches predicate, and O matches the typed literal corresponding to object.
      Specified by:
      listLiteralStatements in interface ModelCon
    • listLiteralStatements

      public StmtIterator listLiteralStatements(Resource S, Property P, int O)
      Description copied from interface: ModelCon
      Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matches subject, P matches predicate, and O matches the typed literal corresponding to object.
      Specified by:
      listLiteralStatements in interface ModelCon
    • listLiteralStatements

      public StmtIterator listLiteralStatements(Resource S, Property P, char O)
      Description copied from interface: ModelCon
      Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matches subject, P matches predicate, and O matches the typed literal corresponding to object.
      Specified by:
      listLiteralStatements in interface ModelCon
    • listLiteralStatements

      public StmtIterator listLiteralStatements(Resource S, Property P, float O)
      Description copied from interface: ModelCon
      Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matches subject, P matches predicate, and O matches the typed literal corresponding to object.
      Specified by:
      listLiteralStatements in interface ModelCon
    • listLiteralStatements

      public StmtIterator listLiteralStatements(Resource S, Property P, double O)
      Description copied from interface: ModelCon
      Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matches subject, P matches predicate, and O matches the typed literal corresponding to object.
      Specified by:
      listLiteralStatements in interface ModelCon
    • listResourcesWithProperty

      public ResIterator listResourcesWithProperty(Property p, boolean o)
      Description copied from interface: ModelCon
      Answer an iterator [without duplicates] over all the resources in this model which have value o' for property p, where o' is the typed literal corresponding to o.
      Specified by:
      listResourcesWithProperty in interface ModelCon
    • listResourcesWithProperty

      public ResIterator listResourcesWithProperty(Property p, char o)
      Description copied from interface: ModelCon
      Answer an iterator [without duplicates] over all the resources in this model which have value o' for property p, where o' is the typed literal corresponding to o.
      Specified by:
      listResourcesWithProperty in interface ModelCon
    • listResourcesWithProperty

      public ResIterator listResourcesWithProperty(Property p, long o)
      Description copied from interface: ModelCon
      Answer an iterator [without duplicates] over all the resources in this model which have value o' for property p, where o' is the typed literal corresponding to o.
      Specified by:
      listResourcesWithProperty in interface ModelCon
    • listResourcesWithProperty

      public ResIterator listResourcesWithProperty(Property p, float o)
      Description copied from interface: ModelCon
      Answer an iterator [without duplicates] over all the resources in this model which have value o' for property p, where o' is the typed literal corresponding to o.
      Specified by:
      listResourcesWithProperty in interface ModelCon
    • listResourcesWithProperty

      public ResIterator listResourcesWithProperty(Property p, double o)
      Description copied from interface: ModelCon
      Answer an iterator [without duplicates] over all the resources in this model which have value o' for property p, where o' is the typed literal corresponding to o.
      Specified by:
      listResourcesWithProperty in interface ModelCon
    • listResourcesWithProperty

      public ResIterator listResourcesWithProperty(Property p, Object o)
      Description copied from interface: ModelCon
      Answer an iterator [without duplicates] over all the resources in this model which have value o' for property p, where o' is the typed literal corresponding to o.
      Specified by:
      listResourcesWithProperty in interface ModelCon
    • listSubjectsWithProperty

      public ResIterator listSubjectsWithProperty(Property p, RDFNode o)
      Description copied from interface: Model
      An alias for listResourcesWithProperty, retained for backward compatibility. It may be deprecated in later releases.
      Specified by:
      listSubjectsWithProperty in interface Model
    • listSubjectsWithProperty

      public ResIterator listSubjectsWithProperty(Property p, String o)
      Description copied from interface: ModelCon
      lists all subjects with a given property and property value.
      Specified by:
      listSubjectsWithProperty in interface ModelCon
      Parameters:
      p - The predicate sought.
      o - The property value sought.
      Returns:
      an iterator over the set of subjects
    • listSubjectsWithProperty

      public ResIterator listSubjectsWithProperty(Property p, String o, String l)
      Description copied from interface: ModelCon
      lists all subjects with a given property and property value.
      Specified by:
      listSubjectsWithProperty in interface ModelCon
      Parameters:
      p - The predicate sought.
      o - The property value sought.
      l - the language associated with the object
      Returns:
      an iterator over the set of subjects
    • createResource

      public Resource createResource(Resource type)
      Description copied from interface: ModelCon
      Create a new anonymous resource with a given type.

      Subsequent operations on the returned resource may modify this model.

      The resource is created and an rdf:type property added to the model to specify its type.

      Specified by:
      createResource in interface ModelCon
      Parameters:
      type - the type of the resource to be created.
      Returns:
      a new anonymous resource linked to this model.
    • createResource

      public Resource createResource(String uri, Resource type)
      Description copied from interface: ModelCon
      Create a new resource with a given type.

      Subsequent operations on the returned resource may modify this model.

      The resource is created and an rdf:type property added to the model to specify its type.

      Specified by:
      createResource in interface ModelCon
      Parameters:
      uri - The URI of the new resource.
      type - the type of the resource to be created.
      Returns:
      a new resource linked to this model.
    • createResource

      @Deprecated public Resource createResource(ResourceF f)
      Deprecated.
      Description copied from interface: ModelCon
      Create a new anonymous resource using the supplied factory.

      Subsequent operations on the returned resource may modify this model.

      Specified by:
      createResource in interface ModelCon
      Parameters:
      f - A factory object to create the returned object. .
      Returns:
      a new anonymous resource linked to this model.
    • createResource

      public Resource createResource(AnonId id)
      Description copied from interface: Model
      Create a blank node resource with a specified identifier. The resulting bnode will be equal to any other bnode with the same AnonId (even if they are in separate models - be warned). The intended use for this method is to allow bnode round-tripping between Jena models and other representations.

      This method may return an existing bnode with the correct AnonId and model, or it may construct a fresh one, as it sees fit.

      Operations on the result may modify this model

      Specified by:
      createResource in interface Model
      Parameters:
      id - the identifier to use for this blank node
      Returns:
      a blank node with that identifier
    • createResource

      public Resource createResource(Statement statement)
      Description copied from interface: Model
      Create a resource that represents a statement. This is in support of RDF-star.
      Specified by:
      createResource in interface Model
      Returns:
      a new resource linked to this model.
    • createResource

      @Deprecated public Resource createResource(String uri, ResourceF f)
      Deprecated.
      Description copied from interface: ModelCon
      Create a new resource using the supplied factory.

      Subsequent operations on the returned resource may modify this model.

      Specified by:
      createResource in interface ModelCon
      Parameters:
      uri - the URI of the resource
      f - A factory to create the returned object. .
      Returns:
      a new resource linked to this model.
    • createTypedLiteral

      public Literal createTypedLiteral(boolean v)
      create a type literal from a boolean value.

      The value is converted to a string using its toString method.

      Specified by:
      createTypedLiteral in interface ModelCon
      Parameters:
      v - the value of the literal
      Returns:
      a new literal representing the value v
    • createTypedLiteral

      public Literal createTypedLiteral(int v)
      create a typed literal from an integer value.
      Specified by:
      createTypedLiteral in interface ModelCon
      Parameters:
      v - the value of the literal
      Returns:
      a new literal representing the value v
    • createTypedLiteral

      public Literal createTypedLiteral(long v)
      create a typed literal from a long integer value.
      Specified by:
      createTypedLiteral in interface ModelCon
      Parameters:
      v - the value of the literal
      Returns:
      a new literal representing the value v
    • createTypedLiteral

      public Literal createTypedLiteral(char v)
      create a typed literal from a char value.
      Specified by:
      createTypedLiteral in interface ModelCon
      Parameters:
      v - the value of the literal
      Returns:
      a new literal representing the value v
    • createTypedLiteral

      public Literal createTypedLiteral(float v)
      create a typed literal from a float value.
      Specified by:
      createTypedLiteral in interface ModelCon
      Parameters:
      v - the value of the literal
      Returns:
      a new literal representing the value v
    • createTypedLiteral

      public Literal createTypedLiteral(double v)
      create a typed literal from a double value.
      Specified by:
      createTypedLiteral in interface ModelCon
      Parameters:
      v - the value of the literal
      Returns:
      a new literal representing the value v
    • createTypedLiteral

      public Literal createTypedLiteral(String v)
      create a typed literal from a String value.
      Specified by:
      createTypedLiteral in interface ModelCon
      Parameters:
      v - the value of the literal
      Returns:
      a new literal representing the value v
    • createTypedLiteral

      public Literal createTypedLiteral(Calendar cal)
      Create a typed literal xsd:dateTime from a Calendar object.
      Specified by:
      createTypedLiteral in interface ModelCon
    • createTypedLiteral

      public Literal createTypedLiteral(String lex, RDFDatatype dtype) throws DatatypeFormatException
      Build a typed literal from its lexical form. The lexical form will be parsed now and the value stored. If the form is not legal this will throw an exception.
      Specified by:
      createTypedLiteral in interface Model
      Parameters:
      lex - the lexical form of the literal
      dtype - the type of the literal, null for old style "plain" literals
      Throws:
      DatatypeFormatException - if lex is not a legal form of dtype
    • createTypedLiteral

      public Literal createTypedLiteral(Object value, RDFDatatype dtype)
      Build a typed literal from its value form.
      Specified by:
      createTypedLiteral in interface Model
      Parameters:
      value - the value of the literal
      dtype - the type of the literal, null for old style "plain" literals
    • createTypedLiteral

      public Literal createTypedLiteral(String lex, String typeURI)
      Build a typed literal from its lexical form. The lexical form will be parsed now and the value stored. If the form is not legal this will throw an exception.
      Specified by:
      createTypedLiteral in interface ModelCon
      Parameters:
      lex - the lexical form of the literal
      typeURI - the uri of the type of the literal, null for old style "plain" literals
      Throws:
      DatatypeFormatException - if lex is not a legal form of dtype
    • createTypedLiteral

      public Literal createTypedLiteral(Object value, String typeURI)
      Build a typed literal from its value form.
      Specified by:
      createTypedLiteral in interface ModelCon
      Parameters:
      value - the value of the literal
      typeURI - the URI of the type of the literal, null for old style "plain" literals
    • createTypedLiteral

      public Literal createTypedLiteral(Object value)
      Build a typed literal label from its value form using whatever datatype is currently registered as the the default representation for this java class. No language tag is supplied.
      Specified by:
      createTypedLiteral in interface Model
      Specified by:
      createTypedLiteral in interface ModelCon
      Parameters:
      value - the literal value to encapsulate
      Returns:
      a new literal representing the value v
    • createLiteral

      public Literal createLiteral(String v)
      Description copied from interface: ModelCon
      create a literal from a String value.
      Specified by:
      createLiteral in interface ModelCon
      Parameters:
      v - the value of the literal
      Returns:
      a new literal representing the value v
    • createLiteral

      public Literal createLiteral(String v, String l)
      Description copied from interface: Model
      Create an untyped literal from a String value with a specified language.
      Specified by:
      createLiteral in interface Model
      Parameters:
      v - the lexical form of the literal
      l - the language associated with the literal
      Returns:
      a new literal representing the value v with the given language
    • createLiteral

      public Literal createLiteral(String v, boolean wellFormed)
      Description copied from interface: Model
      Create a literal from a String value. An existing literal of the right value may be returned, or a fresh one created. The use of the wellFormed flag is to create typed literals of type rdf:XMLLiteral, without error checking. This should only be use when the lexical form is known to already be in exclusive canonical XML.
      Specified by:
      createLiteral in interface Model
      Parameters:
      v - the lexical form of the literal
      wellFormed - true if the Literal is well formed XML, in the lexical space of rdf:XMLLiteral
      Returns:
      a new literal
    • createLiteral

      public Literal createLiteral(String v, String l, boolean wellFormed)
    • createLiteralStatement

      public Statement createLiteralStatement(Resource r, Property p, boolean o)
      Description copied from interface: ModelCon
      Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.
      Specified by:
      createLiteralStatement in interface ModelCon
    • createLiteralStatement

      public Statement createLiteralStatement(Resource r, Property p, long o)
      Description copied from interface: ModelCon
      Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.
      Specified by:
      createLiteralStatement in interface ModelCon
    • createLiteralStatement

      public Statement createLiteralStatement(Resource r, Property p, int o)
      Description copied from interface: ModelCon
      Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.
      Specified by:
      createLiteralStatement in interface ModelCon
    • createLiteralStatement

      public Statement createLiteralStatement(Resource r, Property p, char o)
      Description copied from interface: ModelCon
      Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.
      Specified by:
      createLiteralStatement in interface ModelCon
    • createLiteralStatement

      public Statement createLiteralStatement(Resource r, Property p, float o)
      Description copied from interface: ModelCon
      Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.
      Specified by:
      createLiteralStatement in interface ModelCon
    • createLiteralStatement

      public Statement createLiteralStatement(Resource r, Property p, double o)
      Description copied from interface: ModelCon
      Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.
      Specified by:
      createLiteralStatement in interface ModelCon
    • createStatement

      public Statement createStatement(Resource r, Property p, String o)
      Description copied from interface: ModelCon
      Create a Statement instance.

      Subsequent operations on the statement or any of its parts may modify this model.

      Creating a statement does not add it to the set of statements in the model.

      The Object o will be converted to a Literal.

      Specified by:
      createStatement in interface ModelCon
      Parameters:
      r - the subject of the statement
      p - the predicate of the statement
      o - is the value to be the object of the statement
      Returns:
      the new statement
    • createLiteralStatement

      public Statement createLiteralStatement(Resource r, Property p, Object o)
      Description copied from interface: ModelCon
      Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.
      Specified by:
      createLiteralStatement in interface ModelCon
    • createStatement

      public Statement createStatement(Resource r, Property p, String o, boolean wellFormed)
      Description copied from interface: ModelCon
      Create a Statement instance.

      Subsequent operations on the statement or any of its parts may modify this model.

      Creating a statement does not add it to the set of statements in the model.

      The Object o will be converted to a Literal.

      Specified by:
      createStatement in interface ModelCon
      Parameters:
      r - the subject of the statement
      p - the predicate of the statement
      o - is the value to be the object of the statement
      wellFormed - true if the string is well formed XML
      Returns:
      the new statement
    • createStatement

      public Statement createStatement(Resource r, Property p, String o, String l)
      Description copied from interface: ModelCon
      Create a Statement instance.

      Subsequent operations on the statement or any of its parts may modify this model.

      Creating a statement does not add it to the set of statements in the model.

      The Object o will be converted to a Literal.

      Specified by:
      createStatement in interface ModelCon
      Parameters:
      r - the subject of the statement
      p - the predicate of the statement
      o - is the value to be the object of the statement
      l - the language associated with the object
      Returns:
      the new statement
    • createStatement

      public Statement createStatement(Resource r, Property p, String o, String l, boolean wellFormed)
      Description copied from interface: ModelCon
      Create a Statement instance.

      Subsequent operations on the statement or any of its parts may modify this model.

      Creating a statement does not add it to the set of statements in the model.

      The Object o will be converted to a Literal.

      Specified by:
      createStatement in interface ModelCon
      Parameters:
      r - the subject of the statement
      p - the predicate of the statement
      o - is the value to be the object of the statement
      l - the language associated with the object
      wellFormed - true of the string is well formed XML
      Returns:
      the new statement
    • createBag

      public Bag createBag()
      Description copied from interface: ModelCon
      Create a new anonymous bag.

      Subsequent operations on the bag or any of its parts may modify this model.

      A statement defining the type of the new bag is added to this model.

      Specified by:
      createBag in interface ModelCon
      Returns:
      a new anonymous bag.
    • createAlt

      public Alt createAlt()
      Description copied from interface: ModelCon
      Create a new anonymous alt.

      Subsequent operations on the alt or any of its parts may modify this model.

      A statement defining the type of the new alt is added to this model.

      Specified by:
      createAlt in interface ModelCon
      Returns:
      a new anonymous alt.
    • createSeq

      public Seq createSeq()
      Description copied from interface: ModelCon
      Create a new anonymous seq.

      Subsequent operations on the seq or any of its parts may modify this model.

      A statement defining the type of the new seq is added to this model.

      Specified by:
      createSeq in interface ModelCon
      Returns:
      a new anonymous seq.
    • createList

      public RDFList createList()
      Answer a (the) new empty list Until this is made the object or subject in the model, it will not appear in a written form.
      Specified by:
      createList in interface Model
      Returns:
      An RDF-encoded list of no elements (ie nil)
    • createList

      public RDFList createList(Iterator<? extends RDFNode> members)

      Answer a new list containing the resources from the given iterator, in order.

      Specified by:
      createList in interface Model
      Parameters:
      members - An iterator, each value of which is expected to be an RDFNode.
      Returns:
      An RDF-encoded list of the elements of the iterator
    • createList

      public RDFList createList(RDFNode... members)

      Answer a new list containing the RDF nodes from the given array, in order

      Specified by:
      createList in interface Model
      Parameters:
      members - An array of RDFNodes that will be the members of the list
      Returns:
      An RDF-encoded list
    • getRDFNode

      public RDFNode getRDFNode(Node n)
      Description copied from interface: ModelCon
      Create or find an RDFNode (a Resource or a Literal) from a graph Node. This is provided for users and developers operating at the API/SPI interface, where Resources are constructed from Nodes. Providing this method allows each Model the opportunity to cache node-to-resource maps if it requires.
      Specified by:
      getRDFNode in interface ModelCon
      Parameters:
      n - the graph.Node on which to base the Model.RDFNode
      Returns:
      a suitable RDFNode
    • getResource

      public Resource getResource(String uri)
      Description copied from interface: Model
      Return a Resource instance with the given URI in this model. This method behaves identically to createResource(String) and exists as legacy: createResource is now capable of, and allowed to, reuse existing objects.

      Subsequent operations on the returned object may modify this model.

      Specified by:
      getResource in interface Model
      Parameters:
      uri - the URI of the resource
      Returns:
      a resource instance
    • getProperty

      public Property getProperty(String uri)
      Description copied from interface: ModelCon
      Return a Property instance in this model.

      Subsequent operations on the returned property may modify this model.

      The property is assumed to already exist in the model. If it does not, createProperty should be used instead.

      Specified by:
      getProperty in interface ModelCon
      Parameters:
      uri - the URI of the property
      Returns:
      a property object
    • getProperty

      public Property getProperty(String nameSpace, String localName)
      Description copied from interface: Model
      Return a Property instance with the given URI in this model. This method behaves identically to createProperty(String,String) and exists as legacy: createProperty is now capable of, and allowed to, reuse existing objects.

      Subsequent operations on the returned property may modify this model.

      Specified by:
      getProperty in interface Model
      Parameters:
      nameSpace - the RDF namespace of the property
      localName - the localName of the property in its namespace
      Returns:
      a property linked to this model
    • getSeq

      public Seq getSeq(String uri)
      Description copied from interface: ModelCon
      Return a Seq instance in this model.

      Subsequent operations on the returned sequence may modify this model.

      The seq is assumed to already exist in the model. If it does not, createSeq should be used instead.

      Specified by:
      getSeq in interface ModelCon
      Parameters:
      uri - the URI of the seq
      Returns:
      a seq instance
    • getSeq

      public Seq getSeq(Resource r)
      Description copied from interface: ModelCon
      Return a Seq instance based on a given resource.

      This method enables an application to treat any resource as a Seq. It is in effect an unsafe downcast.

      Subsequent operations on the returned Seq may modify this model.

      The Seq is assumed to already exist in the model. If it does not, createSeq should be used instead.

      Specified by:
      getSeq in interface ModelCon
      Parameters:
      r - an untyped Resource instance
      Returns:
      an Seq instance
    • getBag

      public Bag getBag(String uri)
      Description copied from interface: ModelCon
      Return a Bag instance in this model.

      Subsequent operations on the returned bag may modify this model.

      The bag is assumed to already exist in the model. If it does not, createBag should be used instead.

      Specified by:
      getBag in interface ModelCon
      Parameters:
      uri - the URI of the bag.
      Returns:
      a bag instance
    • getBag

      public Bag getBag(Resource r)
      Description copied from interface: ModelCon
      Return a bag instance based on a given resource.

      This method enables an application to treat any resource as a bag. It is in effect an unsafe downcast.

      Subsequent operations on the returned bag may modify this model.

      The bag is assumed to already exist in the model. If it does not, createBag should be used instead.

      Specified by:
      getBag in interface ModelCon
      Parameters:
      r - an untyped Resource instance
      Returns:
      a bag instance
    • getList

      public RDFList getList(String uri)
      Description copied from interface: ModelCon
      Return a RDF List instance in this model.

      Subsequent operations on the returned list may modify this model.

      The list is assumed to already exist in the model. If it does not, createList should be used instead.

      Specified by:
      getList in interface ModelCon
      Parameters:
      uri - the URI of the list
      Returns:
      a list instance
    • getList

      public RDFList getList(Resource r)
      Description copied from interface: ModelCon
      Return a RDF List based on a given resource.

      This method enables an application to treat any resource as a list. It is in effect an unsafe downcast.

      Subsequent operations on the returned list may modify this model.

      The list is assumed to already exist in the model. If it does not, createList should be used instead.

      Specified by:
      getList in interface ModelCon
      Parameters:
      r - the resource of the list
      Returns:
      a list instance
    • getAlt

      public Alt getAlt(String uri)
      Description copied from interface: ModelCon
      Return an Alt instance in this model.

      Subsequent operations on the returned object may modify this model.

      The alt is assumed to already exist in the model. If it does not, createAlt should be used instead.

      Specified by:
      getAlt in interface ModelCon
      Parameters:
      uri - the URI of the alt
      Returns:
      an alt instance
    • getAlt

      public Alt getAlt(Resource r)
      Description copied from interface: ModelCon
      Return an Alt instance based on a given resource.

      This method enables an application to treat any resource as an Alt. It is in effect an unsafe downcast.

      Subsequent operations on the returned Alt may modify this model.

      The Alt is assumed to already exist in the model. If it does not, createAlt should be used instead.

      Specified by:
      getAlt in interface ModelCon
      Parameters:
      r - an untyped Resource instance
      Returns:
      an Alt instance
    • size

      public long size()
      Description copied from interface: Model
      size will return the number of statements in a concrete model, for a virtualized model such as one created by an inference engine, it will return an estimated lower bound for the number of statements in the model but it is possible for a subsequent listStatements on such a model to discover more statements than size() indicated.
      Specified by:
      size in interface Model
      Returns:
      the number of statements in a concrete model or an estimated lower bound on the number of statements in an virtualized model
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Model
      Answer true iff the model contains no explicit statements (ie it's size is zero, listStatements() would deliver the empty iterator).
      Specified by:
      isEmpty in interface Model
      Returns:
      true iff the model contains no explicit statements.
    • listNameSpaces

      public NsIterator listNameSpaces()
      Description copied from interface: Model
      (You probably don't want this method; more likely you want the PrefixMapping methods that Model supports.) List the namespaces used by predicates and types in the model. This method is really intended for use by the RDF/XML writer, which needs to know these namespaces to generate correct and vaguely pretty XML.

      The namespaces returned are those of (a) every URI used as a property in the model and (b) those of every URI that appears as the object of an rdf:type statement.

      Note that the notion of "namespace" used here is not that of an XML prefix-namespace, but just of the minimal legal left part of a URI (see Util.splitNamespace for details). If you want the RDF/XML (or N3) namespaces, treat the Model as a PrefixMapping.

      Specified by:
      listNameSpaces in interface Model
      Returns:
      an iterator over every predicate and type namespace
      See Also:
    • samePrefixMappingAs

      public boolean samePrefixMappingAs(PrefixMapping other)
      Description copied from interface: PrefixMapping
      Answer true iff this prefix-mappings are equal, that is, map the same prefixes to the same URIs; same as
      this.getNsPrefixMap().equals( other.getNsPrefixMap() )
      except that it may avoid unnecessary Map creations.
      Specified by:
      samePrefixMappingAs in interface PrefixMapping
    • lock

      public PrefixMapping lock()
      Description copied from interface: PrefixMapping
      Lock the PrefixMapping so that changes can no longer be made to it. Primarily intended to lock Standard against mutation.
      Specified by:
      lock in interface PrefixMapping
      Returns:
      this mapping, locked against changes
    • setNsPrefix

      public Model setNsPrefix(String prefix, String uri)
      Description copied from interface: PrefixMapping
      Specify the prefix name for a URI prefix string. Any existing use of that prefix name is overwritten. The result is this same prefixMapping. (The earlier restriction that adding second prefix for the same URI caused the earlier binding to be deleted has been withdrawn.)

      A prefix name must be a valid NCName, or the empty string. The empty string is reserved to mean "the default namespace".

      Need not check the RFC2396 validity of the URI. Bad URIs are either silently ignored or behave as if they were good. The earlier restriction that the URI should end with a non-NCName character has been removed.

      Note, in particular, that the prefix mapping can only be used if it includes the URI up to any '#' character because '#' is not legal in the local part of an NCName.

      Specified by:
      setNsPrefix in interface Model
      Specified by:
      setNsPrefix in interface PrefixMapping
      Parameters:
      prefix - the string to be used for the prefix.
      uri - the URI prefix to be named
      Returns:
      this PrefixMapping
    • removeNsPrefix

      public Model removeNsPrefix(String prefix)
      Description copied from interface: PrefixMapping
      Remove any existing maplet with the given prefix name and answer this mapping. If the prefix is the empty string, then this removes the default namespace. If the prefix is not a legal prefix string, or is not present in the mapping, nothing happens.

      The reverse URI-to-prefix mapping is updated, but if there are multiple prefixes for the removed URI it is unspecified which of them will be chosen.

      Specified by:
      removeNsPrefix in interface Model
      Specified by:
      removeNsPrefix in interface PrefixMapping
      Parameters:
      prefix - the prefix string to remove
      Returns:
      this PrefixMapping
    • clearNsPrefixMap

      public Model clearNsPrefixMap()
      Description copied from interface: PrefixMapping
      Clear this prefix mapping of all mappings
      Specified by:
      clearNsPrefixMap in interface Model
      Specified by:
      clearNsPrefixMap in interface PrefixMapping
    • setNsPrefixes

      public Model setNsPrefixes(PrefixMapping pm)
      Description copied from interface: PrefixMapping
      Copies the prefixes from other into this. Any existing binding of the same prefix is lost. The result is this same prefixMapping.
      Specified by:
      setNsPrefixes in interface Model
      Specified by:
      setNsPrefixes in interface PrefixMapping
      Parameters:
      pm - the PrefixMapping to add
      Returns:
      this PrefixMapping
    • setNsPrefixes

      public Model setNsPrefixes(Map<String,String> map)
      Description copied from interface: PrefixMapping
      Copies the prefix mapping from other into this. Illegal prefix mappings are detected. Existing binds of the same prefix are lost. The result is this same prefixMapping.
      Specified by:
      setNsPrefixes in interface Model
      Specified by:
      setNsPrefixes in interface PrefixMapping
      Parameters:
      map - the Map whose maplets are to be added
      Returns:
      this PrefixMapping
    • withDefaultMappings

      public Model withDefaultMappings(PrefixMapping other)
      Description copied from interface: PrefixMapping
      Update this PrefixMapping with the bindings in map, only adding those (p, u) pairs for which neither p nor u appears in this mapping. Answer this PrefixMapping.
      Specified by:
      withDefaultMappings in interface Model
      Specified by:
      withDefaultMappings in interface PrefixMapping
    • getNsPrefixURI

      public String getNsPrefixURI(String prefix)
      Description copied from interface: PrefixMapping
      Get the URI bound to a specific prefix, null if there isn't one.
      Specified by:
      getNsPrefixURI in interface PrefixMapping
      Parameters:
      prefix - the prefix name to be looked up
      Returns:
      the most recent URI bound to that prefix name, null if none
    • getNsURIPrefix

      public String getNsURIPrefix(String uri)
      Description copied from interface: PrefixMapping
      Answer the prefix for the given URI, or null if there isn't one. If there is more than one, one of them will be picked. If possible, it will be the most recently added prefix. (The cases where it's not possible is when a binding has been removed.)
      Specified by:
      getNsURIPrefix in interface PrefixMapping
      Parameters:
      uri - the uri whose prefix is to be found
      Returns:
      the prefix mapped to that uri, or null if there isn't one
    • getNsPrefixMap

      public Map<String,String> getNsPrefixMap()
      Description copied from interface: PrefixMapping
      Return a copy of the internal mapping from names to URI strings. Updating this copy will have no effect on the PrefixMap.
      Specified by:
      getNsPrefixMap in interface PrefixMapping
      Returns:
      a copy of the internal String -> String mapping
    • expandPrefix

      public String expandPrefix(String prefixed)
      Description copied from interface: PrefixMapping
      Expand the uri using the prefix mappings if possible. If prefixed has the form Foo:Bar, and Foo is a prefix bound to FooURI, return FooURI+Bar. Otherwise return prefixed unchanged.
      Specified by:
      expandPrefix in interface PrefixMapping
      Parameters:
      prefixed - a QName or URI
      Returns:
      the expanded string if possible, otherwise the original string
    • qnameFor

      public String qnameFor(String uri)
      Description copied from interface: PrefixMapping
      Answer a qname with the expansion of the given uri, or null if no such qname can be constructed using the mapping's prefixes.
      Specified by:
      qnameFor in interface PrefixMapping
    • shortForm

      public String shortForm(String uri)
      Description copied from interface: PrefixMapping
      Compress the URI using the prefix mappings if possible. If there is a prefix mapping Name -> URIStart, and uri is URIStart+Tail, return Name:Tail; otherwise return uri unchanged. If there are multiple applicable mappings available, the "most recent" is chosen if that is possible, otherwise one is picked "at random".

      The result is primarily intended for human convenience: it is not necessarily a legal QName, as Tail need not be a legal NCName; and there's no way to tell a shortened name from a URI with an unusual scheme.

      Specified by:
      shortForm in interface PrefixMapping
      Parameters:
      uri - the URI string to try and prefix-compress
      Returns:
      the shortened form if possible, otherwise the unchanged argument
    • hasNoMappings

      public boolean hasNoMappings()
      Description copied from interface: PrefixMapping
      Return whether the prefix mapping has any defined prefixes.
      Specified by:
      hasNoMappings in interface PrefixMapping
    • numPrefixes

      public int numPrefixes()
      Description copied from interface: PrefixMapping
      Return the number of defined prefixes.
      Specified by:
      numPrefixes in interface PrefixMapping
    • addNamespaces

      public static void addNamespaces(Model m, Map<String,Set<String>> ns)
      Service method to update the namespaces of a Model given the mappings from prefix names to sets of URIs. If the prefix maps to multiple URIs, then we discard it completely.
      Parameters:
      m - Model who's namespace is to be updated
      ns - the namespace map to add to the Model
    • listStatements

      public StmtIterator listStatements()
      Description copied from interface: Model
      List all statements.

      Subsequent operations on those statements may modify this model.

      Specified by:
      listStatements in interface Model
      Returns:
      an iterator over all statements in the model.
    • add

      public Model add(Statement s)
      add a Statement to this Model by adding its SPO components.
      Specified by:
      add in interface Model
      Parameters:
      s - The statement to be added.
      Returns:
      This model.
    • add

      public Model add(Statement[] statements)
      Add all the statements to the model by converting them to an array of corresponding triples and removing those from the underlying graph.
      Specified by:
      add in interface Model
      Parameters:
      statements - the array of statements to add
      Returns:
      this model, to allow cascading
    • add

      public Model add(List<Statement> statements)
      Add all the statements to the model by converting the list to an array of Statement and removing that.
      Specified by:
      add in interface Model
      Parameters:
      statements - a List of Statements
      Returns:
      this model, to allow cascading
    • remove

      public Model remove(Statement[] statements)
      remove all the Statements from the model by converting them to triples and removing those triples from the underlying graph.
      Specified by:
      remove in interface Model
      Parameters:
      statements - the array of statements to be added
      Returns:
      this model, to allow cascading
    • remove

      public Model remove(List<Statement> statements)
      Remove all the Statements from the model by converting the List to a List(Statement) and removing that.
      Specified by:
      remove in interface Model
      Parameters:
      statements - a List of Statements to remove
      Returns:
      this model, to allow cascading
    • add

      public Model add(Resource s, Property p, RDFNode o)
      Description copied from interface: ModelCon
      add a statement to this model.
      Specified by:
      add in interface ModelCon
      Parameters:
      s - the subject of the statement to add
      p - the predicate of the statement to add
      o - the object of the statement to add
      Returns:
      this model
    • listReifiedStatements

      public RSIterator listReifiedStatements()
      Description copied from interface: Model
      answer an iterator delivering all the reified statements "in" this model
      Specified by:
      listReifiedStatements in interface Model
      Returns:
      an iterator which delivers all the ReifiedStatements in this model
    • listReifiedStatements

      public RSIterator listReifiedStatements(Statement st)
      Description copied from interface: Model
      answer an iterator delivering all the reified statements "in" this model that match the statement _st_.
      Specified by:
      listReifiedStatements in interface Model
      Returns:
      an iterator each of whose elements is a ReifiedStatement in this model such that it's getStatement().equals( st )
    • isReified

      public boolean isReified(Statement s)
      Description copied from interface: Model
      Determine if this Statement has been reified in this Model.
      Specified by:
      isReified in interface Model
      Parameters:
      s - The statement tested.
      Returns:
      true iff this model has a reification of _s_ in some Statement
    • getAnyReifiedStatement

      public Resource getAnyReifiedStatement(Statement s)
      get any reification of the given statement in this model; make one if necessary.
      Specified by:
      getAnyReifiedStatement in interface Model
      Parameters:
      s - for which a reification is sought
      Returns:
      a ReifiedStatement that reifies _s_
    • removeAllReifications

      public void removeAllReifications(Statement s)
      remove any ReifiedStatements reifying the given statement
      Specified by:
      removeAllReifications in interface Model
      Parameters:
      s - the statement who's reifications are to be discarded
    • removeReification

      public void removeReification(ReifiedStatement rs)
      Description copied from interface: Model
      Remove a particular reificiation.
      Specified by:
      removeReification in interface Model
    • createReifiedStatement

      public ReifiedStatement createReifiedStatement(Statement s)
      create a ReifiedStatement that encodes _s_ and belongs to this Model.
      Specified by:
      createReifiedStatement in interface Model
    • createReifiedStatement

      public ReifiedStatement createReifiedStatement(String uri, Statement s)
      Description copied from interface: Model
      answer a ReifiedStatement that encodes _s_, belongs to this Model, and is a Resource with that _uri_.
      Specified by:
      createReifiedStatement in interface Model
    • contains

      public boolean contains(Statement s)
      Description copied from interface: Model
      Determine if a statement is present in this model.
      Specified by:
      contains in interface Model
      Parameters:
      s - The statement tested.
      Returns:
      true if the statement s is in this model, false otherwise
    • containsResource

      public boolean containsResource(RDFNode r)
      Description copied from interface: Model
      determine if the RDFNode r appears in any statement of this model. (containsRDFNode is a horrible name, and in any case, even literals will be resources one day)
      Specified by:
      containsResource in interface Model
      Parameters:
      r - the RDFNode to be searched for
      Returns:
      true iff r appears as some subject, predicate, or object
    • contains

      public boolean contains(Resource s, Property p)
      Description copied from interface: Model
      Determine whether this model contains any statements with a given subject and property.
      Specified by:
      contains in interface Model
      Parameters:
      s - The subject sought (null for any).
      p - The predicate sought (null for any).
      Returns:
      true if there exists within this model a statement with subject s and property p, false otherwise
    • contains

      public boolean contains(Resource s, Property p, RDFNode o)
      Description copied from interface: Model
      Determine if an (S, P, O) pattern is present in this model, with null allowed to represent a wildcard match.
      Specified by:
      contains in interface Model
      Parameters:
      s - The subject of the statement tested (null as wildcard).
      p - The predicate of the statement tested (null as wildcard).
      o - The object of the statement tested (null as wildcard).
      Returns:
      true if the statement with subject s, property p and object o is in the model, false otherwise
    • getRequiredProperty

      public Statement getRequiredProperty(Resource s, Property p)
      Description copied from interface: Model
      Return a statement with given subject and property.

      If more than one statement witht the given subject and property exists in the model, it is undefined which will be returned. If none exist, an exception is thrown.

      Specified by:
      getRequiredProperty in interface Model
      Parameters:
      s - The subject of the statement to be returned.
      p - The property of the statement to be returned.
      Returns:
      A statement from the model with the given subject and property.
    • getRequiredProperty

      public Statement getRequiredProperty(Resource s, Property p, String lang)
      Description copied from interface: Model
      Return a statement with given subject and property.

      If more than one statement witht the given subject and property exists in the model, it is undefined which will be returned. If none exist, an exception is thrown.

      Specified by:
      getRequiredProperty in interface Model
      Parameters:
      s - The subject of the statement to be returned.
      p - The property of the statement to be returned.
      lang - The language
      Returns:
      A statement from the model with the given subject and property.
    • getProperty

      public Statement getProperty(Resource s, Property p)
      Description copied from interface: Model
      Answer a statement (s, p, ?O) from this model. If none exist, return null; if several exist, pick one arbitrarily.
      Specified by:
      getProperty in interface Model
      Parameters:
      s - the subject of the statement to return
      p - the predicate of the statement to return
      Returns:
      some statement (s, p, ?O) or null if none can be found
    • getProperty

      public Statement getProperty(Resource s, Property p, String lang)
      Description copied from interface: Model
      Answer a statement (s, p, ?O) from this model. If none exist, return null; if several exist, pick one arbitrarily.
      Specified by:
      getProperty in interface Model
      Parameters:
      s - the subject of the statement to return
      p - the predicate of the statement to return
      lang - language of the object
      Returns:
      some statement (s, p, ?O@lang) or null if none can be found
    • asNode

      public static Node asNode(RDFNode x)
    • listSubjects

      public ResIterator listSubjects()
      Description copied from interface: Model
      List all resources which are subjects of statements.

      Subsequent operations on those resource may modify this model.

      Specified by:
      listSubjects in interface Model
      Returns:
      an iterator over a set of resources which are subjects of statements in the model. .remove() is not implemented on this iterator.
    • listResourcesWithProperty

      public ResIterator listResourcesWithProperty(Property p)
      Description copied from interface: Model
      Answer an iterator [with no duplicates] over all the resources in this model that have property p. remove() is not implemented on this iterator.
      Specified by:
      listResourcesWithProperty in interface Model
    • listSubjectsWithProperty

      public ResIterator listSubjectsWithProperty(Property p)
      Description copied from interface: Model
      An alias for listResourcesWithProperty(Property), retained for backward compatibility. It may be deprecated in later releases.
      Specified by:
      listSubjectsWithProperty in interface Model
    • listResourcesWithProperty

      public ResIterator listResourcesWithProperty(Property p, RDFNode o)
      Description copied from interface: Model
      Answer an iterator [with no duplicates] over all the resources in this model that have property p with value o. remove() is not implemented on this iterator.
      Specified by:
      listResourcesWithProperty in interface Model
    • listObjects

      public NodeIterator listObjects()
      Description copied from interface: Model
      List all objects in a model.
      Specified by:
      listObjects in interface Model
      Returns:
      an iterator over the objects. .remove() is not implemented on this iterator.
    • listObjectsOfProperty

      public NodeIterator listObjectsOfProperty(Property p)
      Description copied from interface: Model
      List all objects of a given property. .remove() is not implemented on this iterator.
      Specified by:
      listObjectsOfProperty in interface Model
      Parameters:
      p - The predicate sought
      Returns:
      an iterator over the objects
    • listObjectsOfProperty

      public NodeIterator listObjectsOfProperty(Resource s, Property p)
      Description copied from interface: Model
      List the values of a property of a resource.
      Specified by:
      listObjectsOfProperty in interface Model
      p - The predicate sought
      Returns:
      an iterator over the objects. .remove() is not implemented on this iterator.
    • listStatements

      public StmtIterator listStatements(Selector selector)
      Description copied from interface: Model
      List the statements matching a selector.

      A statement is considered to match if the test method of s returns true when called on s.

      Specified by:
      listStatements in interface Model
      Parameters:
      selector - A selector object. .
      Returns:
      an iterator over the matching statements
    • findTriplesFrom

      public ExtendedIterator<Triple> findTriplesFrom(Selector s)
      Answer an [extended] iterator which returns the triples in this graph which are selected by the (S, P, O) triple in the selector, ignoring any special tests it may do.
      Parameters:
      s - a Selector used to supply subject, predicate, and object
      Returns:
      an extended iterator over the matching (S, P, O) triples
    • supportsTransactions

      public boolean supportsTransactions()
      Description copied from interface: Model
      Determine whether this model supports transactions.
      Specified by:
      supportsTransactions in interface Model
      Returns:
      true if this model supports transactions.
    • begin

      public Model begin()
      Description copied from interface: Model
      Begin a new transaction.

      All changes made to a model within a transaction, will either be made, or none of them will be made.

      Specified by:
      begin in interface Model
      Returns:
      this model to enable cascading.
    • abort

      public Model abort()
      Description copied from interface: Model
      Abort the current transaction and abandon any changes in progress.
      Specified by:
      abort in interface Model
      Returns:
      this model to enable cascading.
    • commit

      public Model commit()
      Description copied from interface: Model
      Commit the current transaction.
      Specified by:
      commit in interface Model
      Returns:
      this model to enable cascading.
    • executeInTxn

      public void executeInTxn(Runnable action)
      Description copied from interface: Model
      Execute the runnable action within a transaction. If it completes normally, commit the transaction, otherwise abort the transaction.
      Specified by:
      executeInTxn in interface Model
    • calculateInTxn

      public <T> T calculateInTxn(Supplier<T> action)
      Execute the supplier action within a transaction. If it completes normally, commit the transaction and return the result, otherwise abort the transaction.
      Specified by:
      calculateInTxn in interface Model
    • independent

      public boolean independent()
      Description copied from interface: Model
      Determine whether this model is independent.

      For efficiency reasons, some implementations may create models which which are dependent on others, i.e. a change in one model may cause a change in another. If this is the case this method will return false, otherwise it will return true.

      Specified by:
      independent in interface Model
      Returns:
      true if this model is indepdent of others
    • createResource

      public Resource createResource()
      Description copied from interface: Model
      Create a new anonymous resource whose model is this model. This bnode will have a new AnonId distinct from any allocated by any other call of this method.

      Subsequent operations on the returned resource may modify this model.

      Specified by:
      createResource in interface Model
      Returns:
      a new anonymous resource linked to this model.
    • createResource

      public Resource createResource(String uri)
      Description copied from interface: Model
      Create a new resource associated with this model. If the uri string is null, this creates a bnode, as per createResource(). Otherwise it creates a URI node. A URI resource is .equals() to any other URI Resource with the same URI (even in a different model - be warned).

      This method may return an existing Resource with the correct URI and model, or it may construct a fresh one, as it sees fit.

      Operations on the result Resource may change this model.

      Specified by:
      createResource in interface Model
      Parameters:
      uri - the URI of the resource to be created
      Returns:
      a new resource linked to this model.
    • createProperty

      public Property createProperty(String uri)
      Description copied from interface: ModelCon
      Create a property.

      Subsequent operations on the returned property may modify this model.

      Specified by:
      createProperty in interface ModelCon
      Parameters:
      uri - the URI of the property
      Returns:
      a property instance
    • createProperty

      public Property createProperty(String nameSpace, String localName)
      Description copied from interface: Model
      Create a property with a given URI composed from a namespace part and a localname part by concatenating the strings.

      This method may return an existing property with the correct URI and model, or it may construct a fresh one, as it sees fit.

      Subsequent operations on the returned property may modify this model.

      Specified by:
      createProperty in interface Model
      Parameters:
      nameSpace - the nameSpace of the property
      localName - the name of the property within its namespace
      Returns:
      a property instance
    • createStatement

      public Statement createStatement(Resource r, Property p, RDFNode o)
      create a Statement from the given r, p, and o.
      Specified by:
      createStatement in interface Model
      Parameters:
      r - the subject of the statement
      p - the predicate of the statement
      o - the object of the statement
      Returns:
      the new statement
    • createBag

      public Bag createBag(String uri)
      Description copied from interface: ModelCon
      Create a new bag.

      Subsequent operations on the bag or any of its parts may modify this model.

      A statement defining the type of the new bag is added to this model.

      Specified by:
      createBag in interface ModelCon
      Parameters:
      uri - The URI of the new Bag.
      Returns:
      a new bag.
    • createAlt

      public Alt createAlt(String uri)
      Description copied from interface: ModelCon
      Create a new alt.

      Subsequent operations on the alt or any of its parts may modify this model.

      A statement defining the type of the new alt is added to this model.

      Specified by:
      createAlt in interface ModelCon
      Parameters:
      uri - The URI of the new alt.
      Returns:
      a new alt.
    • createSeq

      public Seq createSeq(String uri)
      Description copied from interface: ModelCon
      Create a new seq.

      Subsequent operations on the seq or any of its parts may modify this model.

      A statement defining the type of the new seq is added to this model.

      Specified by:
      createSeq in interface ModelCon
      Parameters:
      uri - The URI of the new seq.
      Returns:
      a new seq.
    • asStatement

      public Statement asStatement(Triple t)
      Answer a Statement in this Model which encodes the given Triple.
      Specified by:
      asStatement in interface ModelGraphInterface
      Parameters:
      t - a triple to wrap as a statement
      Returns:
      a statement wrapping the triple and in this model
    • asStatements

      public Statement[] asStatements(Triple[] triples)
    • asStatements

      public List<Statement> asStatements(List<Triple> triples)
    • asModel

      public Model asModel(Graph g)
    • asStatements

      public StmtIterator asStatements(Iterator<Triple> it)
    • listBySubject

      public StmtIterator listBySubject(Container cont)
    • close

      public void close()
      Description copied from interface: Model
      Close the Model and free up resources held.

      Not all implementations of Model require this method to be called. But some do, so in general its best to call it when done with the object, rather than leave it to the finalizer.

      Specified by:
      close in interface Model
    • isClosed

      public boolean isClosed()
      Description copied from interface: Model
      Answer true iff .close() has been called on this Model.
      Specified by:
      isClosed in interface Model
    • supportsSetOperations

      public boolean supportsSetOperations()
      Description copied from interface: Model
      Determine whether this model supports set operations.
      Specified by:
      supportsSetOperations in interface Model
      Returns:
      true if this model supports set operations.
    • query

      public Model query(Selector selector)
      Description copied from interface: Model
      Create a new model containing the statements matching a query.

      A statement is considered to match if the test method of s returns true when called on s.

      Specified by:
      query in interface Model
      Parameters:
      selector - A selector object. .
      Returns:
      an iterator over the matching statements
    • union

      public Model union(Model model)
      Description copied from interface: Model
      Create a new, independant, model containing all the statements in this model together with all of those in another given model. By independant we mean that changes to the result model do not affect the operand models, and vice versa.

      The new model need not be of the same type as either this model or the argument model: typically it will be a memory-based model, even if this model is a database model.

      Specified by:
      union in interface Model
      Parameters:
      model - The other model whose statements are to be included.
      Returns:
      A new model containing all the statements that are in either model
    • intersection

      public Model intersection(Model other)
      Intersect this with another model. As an attempt at optimisation, we try and ensure we iterate over the smaller model first. Nowadays it's not clear that this is a good idea, since size() can be expensive on database and inference models.
      Specified by:
      intersection in interface Model
      Parameters:
      other - The other model.
      Returns:
      A new model containing all the statements that are in both models.
      See Also:
    • intersect

      public static Model intersect(Model smaller, Model larger)
      Answer a Model that is the intersection of the two argument models. The first argument is the model iterated over, and the second argument is the one used to check for membership. [So the first one should be "small" and the second one "membership cheap".]
    • difference

      public Model difference(Model model)
      Description copied from interface: Model
      Create a new, independant, model containing all the statements in this model which are not in another. The new model need not be of the same type as either this model or the argument model: typically it will be a memory-based model.
      Specified by:
      difference in interface Model
      Parameters:
      model - the other model whose statements are to be excluded.
      Returns:
      a new model containing all the statements in this model that are not in the given model.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • reifiedToString

      public String reifiedToString()
    • isIsomorphicWith

      public boolean isIsomorphicWith(Model m)
      Answer whether or not these two graphs are isomorphic.
      Specified by:
      isIsomorphicWith in interface Model
      Parameters:
      m - Compare against this.
      Returns:
      boolean True if the two RDF graphs are isomorphic.
    • getModelLock

      public Lock getModelLock()
    • getLock

      public Lock getLock()
      Description copied from interface: Model
      Get the model lock for this model. See also the convenience operations enterCriticalSection and leaveCriticalSection.
      Specified by:
      getLock in interface Model
      Returns:
      The ModelLock object associated with this model
      See Also:
    • enterCriticalSection

      public void enterCriticalSection(boolean requestReadLock)
      Description copied from interface: Lock
      Enter a critical section. The application must call leaveCriticialSection.
      Specified by:
      enterCriticalSection in interface Lock
      Parameters:
      requestReadLock - true implies a read lock, false implies write lock.
      See Also:
    • leaveCriticalSection

      public void leaveCriticalSection()
      Description copied from interface: Lock
      Leave a critical section. Releases the lock form the matching enterCriticalSection
      Specified by:
      leaveCriticalSection in interface Lock
      See Also:
    • register

      public Model register(ModelChangedListener listener)
      Register the listener with this model by registering its GraphListener adaption with the underlying Graph.
      Specified by:
      register in interface Model
      Parameters:
      listener - A ModelChangedListener to register for model events
      Returns:
      this model, for cascading
      See Also:
    • unregister

      public Model unregister(ModelChangedListener listener)
      Unregister the listener from this model by unregistering its GraphListener adaption from the underlying Graph.
      Specified by:
      unregister in interface Model
      Parameters:
      listener - A ModelChangedListener to unregister from model events
      Returns:
      this model, for cascading
      See Also:
    • adapt

      Answer a GraphListener that, when fed graph-level update events, fires the corresponding model-level event handlers in L.
      Parameters:
      L - a model listener to be wrapped as a graph listener
      Returns:
      a graph listener wrapping L
      See Also:
    • notifyEvent

      public Model notifyEvent(Object e)
      Description copied from interface: Model
      Notify any listeners that the event e has occurred.
      Specified by:
      notifyEvent in interface Model
      Parameters:
      e - the event that has occurred