- All Implemented Interfaces:
Model
,ModelCon
,ModelGraphInterface
,RDFReaderF
,RDFWriterF
,Lock
,PrefixMapping
- Direct Known Subclasses:
InfModelImpl
,MonitorModel
,OntModelImpl
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.jena.shared.PrefixMapping
PrefixMapping.Factory, PrefixMapping.IllegalPrefixException, PrefixMapping.JenaLockedException
-
Field Summary
Fields inherited from interface org.apache.jena.shared.PrefixMapping
Extended, Standard
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabort()
Abort the current transaction and abandon any changes in progress.Answer a GraphListener that, when fed graph-level update events, fires the corresponding model-level event handlers inL
.Add all the statements to the model by converting the list to an array of Statement and removing that.Add all the statements in another model to this model.add a statement to this model.add
(Resource s, Property p, String lex, RDFDatatype datatype) add a statement to this model.add a statement to this model.add a Statement to this Model by adding its SPO components.Add all the statements to the model by converting them to an array of corresponding triples and removing those from the underlying graph.add
(StmtIterator iter) Add all the statements returned by an iterator to this model.addLiteral
(Resource s, Property p, boolean o) Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.addLiteral
(Resource s, Property p, char o) Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.addLiteral
(Resource s, Property p, double o) Add the statement (s, p, o') to the model, where o' is the typed literal corresponding to o.addLiteral
(Resource s, Property p, float o) Add the statement (s, p, o') to the model, where o' is the typed literal corresponding to o.addLiteral
(Resource s, Property p, int o) Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.addLiteral
(Resource s, Property p, long o) Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.addLiteral
(Resource s, Property p, Literal o) add a statement to this model.static void
Service method to update the namespaces of a Model given the mappings from prefix names to sets of URIs.static Node
Answer an RDF node wrappingn
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 withn
as their value carrier.Answer a Statement in this Model which encodes the given Triple.asStatements
(Iterator<Triple> it) asStatements
(List<Triple> triples) asStatements
(Triple[] triples) begin()
Begin a new transaction.<T> T
calculateInTxn
(Supplier<T> action) Execute the supplieraction
within a transaction.Clear this prefix mapping of all mappingsvoid
close()
Close the Model and free up resources held.commit()
Commit the current transaction.boolean
Determine whether this model contains any statements with a given subject and property.boolean
Determine if a statement is present in this model.boolean
Determine if a statement is present in this model.boolean
Determine if an (S, P, O) pattern is present in this model, with null allowed to represent a wildcard match.boolean
Determine if a statement is present in this model.boolean
containsAll
(Model model) Determine if all of the statements in a model are also contained in this model.boolean
containsAll
(StmtIterator iter) Determine if all of the statements returned by an iterator are contained in this model.boolean
containsAny
(Model model) Determine if any of the statements in a model are also contained in this model.boolean
containsAny
(StmtIterator iter) Determine if any of the statements returned by an iterator are contained in this model.boolean
containsLiteral
(Resource s, Property p, boolean o) Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.boolean
containsLiteral
(Resource s, Property p, char o) Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.boolean
containsLiteral
(Resource s, Property p, double o) Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.boolean
containsLiteral
(Resource s, Property p, float o) Answer true iff this model contains (s, p, o') where o' is the typed literal corresponding to o.boolean
containsLiteral
(Resource s, Property p, int o) Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.boolean
containsLiteral
(Resource s, Property p, long o) Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.boolean
containsLiteral
(Resource s, Property p, Object o) Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.boolean
determine if the RDFNode r appears in any statement of this model.Create a new anonymous alt.Create a new alt.Create a new anonymous bag.Create a new bag.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.createList
(Iterator<? extends RDFNode> members) Answer a new list containing the resources from the given iterator, in order.createList
(RDFNode... members) Answer a new list containing the RDF nodes from the given array, in ordercreate a literal from a String value.createLiteral
(String v, String l) Create an untyped literal from a String value with a specified language.createLiteralStatement
(Resource r, Property p, boolean o) Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.createLiteralStatement
(Resource r, Property p, char o) Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.createLiteralStatement
(Resource r, Property p, double o) Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.createLiteralStatement
(Resource r, Property p, float o) Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.createLiteralStatement
(Resource r, Property p, int o) Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.createLiteralStatement
(Resource r, Property p, long o) Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.createLiteralStatement
(Resource r, Property p, Object o) Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.createProperty
(String uri) Create a property.createProperty
(String nameSpace, String localName) Create a property with a given URI composed from a namespace part and a localname part by concatenating the strings.Create a new anonymous resource whose model is this model.createResource
(String uri) Create a new resource associated with this model.createResource
(String uri, Resource type) Create a new resource with a given type.createResource
(AnonId anonId) Create a blank node resource with a specified identifier.createResource
(Resource type) Create a new anonymous resource with a given type.createResource
(Statement statement) Create a resource that represents a statement.Create a new anonymous seq.Create a new seq.createStatement
(Resource r, Property p, String o) Create a Statement instance.createStatement
(Resource r, Property p, String o, String l) Create a Statement instance.createStatement
(Resource r, Property p, RDFNode o) create a Statement from the given r, p, and o.createTypedLiteral
(boolean v) create a type literal from a boolean value.createTypedLiteral
(char v) create a typed literal from a char value.createTypedLiteral
(double v) create a typed literal from a double value.createTypedLiteral
(float v) create a typed literal from a float value.createTypedLiteral
(int v) create a typed literal from an integer value.createTypedLiteral
(long v) create a typed literal from a long integer value.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.createTypedLiteral
(Object value, String typeURI) Build a typed literal from its value form.createTypedLiteral
(Object value, RDFDatatype dtype) Build a typed literal from its value form.create a typed literal from a String value.createTypedLiteral
(String lex, String typeURI) Build a typed literal from its lexical form.createTypedLiteral
(String lex, RDFDatatype dtype) Build a typed literal from its lexical form.Create a typed literal xsd:dateTime from a Calendar object.difference
(Model model) Create a new, independent, model containing all the statements in this model which are not in another.void
enterCriticalSection
(boolean requestReadLock) Enter a critical section.void
executeInTxn
(Runnable action) Execute the runnableaction
within a transaction.expandPrefix
(String prefixed) Expand the uri using the prefix mappings if possible.Return an Alt instance in this model.Return an Alt instance based on a given resource.Return a Bag instance in this model.Return a bag instance based on a given resource.getGraph()
Answer the Graph which this Model is presenting.Return a RDF List instance in this model.Return a RDF List based on a given resource.getLock()
Get the model lock for this model.Return a copy of the internal mapping from names to URI strings.getNsPrefixURI
(String prefix) Get the URI bound to a specific prefix, null if there isn't one.getNsURIPrefix
(String uri) Answer the prefix for the given URI, or null if there isn't one.getProperty
(String uri) Return a Property instance in this model.getProperty
(String nameSpace, String localName) Return a Property instance with the given URI in this model.getProperty
(Resource s, Property p) Answer a statement (s, p, ?getProperty
(Resource s, Property p, String lang) Answer a statement (s, p, ?getRDFNode
(Node n) return an RDFReader instance for the specified serialization language.Return a statement with given subject and property.getRequiredProperty
(Resource s, Property p, String lang) Return a statement with given subject and property.getResource
(String uri) Return a Resource instance with the given URI in this model.getResource
(AnonId id) Return a Resource instance with the given URI in this model.Return a Seq instance in this model.Return a Seq instance based on a given resource.Get the model's writer after priming it with the model's namespace prefixes.boolean
Return whether the prefix mapping has any defined prefixes.boolean
Determine whether this model is independent.static Model
Answer a Model that is the intersection of the two argument models.intersection
(Model other) Intersect this with another model.boolean
isClosed()
Answer true iff .close() has been called on this Model.boolean
isEmpty()
Answer true iff the model contains no explicit statements (ie it's size is zero, listStatements() would deliver the empty iterator).boolean
Answer whether or not these two graphs are isomorphic.void
Leave a critical section.listBySubject
(Container cont) listLiteralStatements
(Resource S, Property P, boolean O) Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.listLiteralStatements
(Resource S, Property P, char O) Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.listLiteralStatements
(Resource S, Property P, double O) Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.listLiteralStatements
(Resource S, Property P, float O) Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.listLiteralStatements
(Resource S, Property P, int O) Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.listLiteralStatements
(Resource S, Property P, long O) Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.(You probably don't want this method; more likely you want the PrefixMapping methods that Model supports.)List all objects in a model.List all objects of a given property. .remove() is not implemented on this iterator.List the values of a property of a resource.Answer an iterator [with no duplicates] over all the resources in this model that have propertyp
.listResourcesWithProperty
(Property p, boolean o) 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.listResourcesWithProperty
(Property p, char o) 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.listResourcesWithProperty
(Property p, double o) 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.listResourcesWithProperty
(Property p, float o) 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.listResourcesWithProperty
(Property p, long o) 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.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.Answer an iterator [with no duplicates] over all the resources in this model that have propertyp
with valueo
.List all statements.listStatements
(Resource S, Property P, String O) Find all the statements matching a pattern.listStatements
(Resource S, Property P, String O, String L) Find all the statements matching a pattern.listStatements
(Resource S, Property P, RDFNode O) Find all the statements matching a pattern.List all resources which are subjects of statements.An alias forlistResourcesWithProperty(Property)
, retained for backward compatibility.lists all subjects with a given property and property value.listSubjectsWithProperty
(Property p, String o, String l) lists all subjects with a given property and property value.An alias forlistResourcesWithProperty
, retained for backward compatibility.lock()
Lock the PrefixMapping so that changes can no longer be made to it.Notify any listeners that the event e has occurred.int
Return the number of defined prefixes.Answer a qname with the expansion of the given uri, or null if no such qname can be constructed using the mapping's prefixes.read
(InputStream reader, String base) Add statements from a document.read
(InputStream reader, String base, String lang) Add RDF statements represented in languagelang
to the model.Using this method is often a mistake.Using this method is often a mistake.Add the RDF statements from a document.Add statements from a serializion in languagelang
to the model.Read into this model the RDF aturl
, usingbaseURI
as the base URI if it is non-null.register
(ModelChangedListener listener) Register the listener with this model by registering its GraphListener adaption with the underlying Graph.Remove all the Statements from the model by converting the List to a List(Statement) and removing that.Remove all the Statements in a given model, including reified statementsremove the statement(s, p, o)
from this model and answer this model.Removes a statement.remove all the Statements from the model by converting them to triples and removing those triples from the underlying graph.remove
(StmtIterator iter) Remove all the Statements returned by an iterator.Remove all the statements from this model.Remove all the statements matching (s, p, o) from this model.removeNsPrefix
(String prefix) Remove any existing maplet with the given prefix name and answer this mapping.boolean
samePrefixMappingAs
(PrefixMapping other) 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.setNsPrefix
(String prefix, String uri) Specify the prefix name for a URI prefix string.setNsPrefixes
(Map<String, String> map) Copies the prefix mapping from other into this.Copies the prefixes from other into this.Compress the URI using the prefix mappings if possible.long
size()
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.boolean
Determine whether this model supports set operations.boolean
Determine whether this model supports transactions.toString()
Create a new, independent, model containing all the statements in this model together with all of those in another given model.unregister
(ModelChangedListener listener) Unregister the listener from this model by unregistering its GraphListener adaption from the underlying Graph.withDefaultMappings
(PrefixMapping other) Update this PrefixMapping with the bindings inmap
, only adding those (p, u) pairs for which neither p nor u appears in this mapping.write
(OutputStream writer) Write a serialization of this model as an XML document.write
(OutputStream writer, String lang) Write a serialized representation of this model in a specified language.write
(OutputStream writer, String lang, String base) Write a serialized representation of a model in a specified language.Write the model as an XML document.Write a serialized representation of a model in a specified language.Write a serialized representation of a model in a specified language.
-
Constructor Details
-
ModelCom
make a model based on the specified graph -
ModelCom
-
-
Method Details
-
getGraph
Description copied from interface:ModelGraphInterface
Answer the Graph which this Model is presenting.- Specified by:
getGraph
in interfaceModelGraphInterface
-
asRDFNode
Description copied from interface:ModelGraphInterface
Answer an RDF node wrappingn
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 withn
as their value carrier.- Specified by:
asRDFNode
in interfaceModelGraphInterface
-
wrapAsResource
- Specified by:
wrapAsResource
in interfaceModelGraphInterface
-
addLiteral
Description copied from interface:ModelCon
Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.- Specified by:
addLiteral
in interfaceModelCon
-
addLiteral
Description copied from interface:ModelCon
Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.- Specified by:
addLiteral
in interfaceModelCon
-
addLiteral
Description copied from interface:ModelCon
Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.- Specified by:
addLiteral
in interfaceModelCon
-
addLiteral
Description copied from interface:ModelCon
Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.- Specified by:
addLiteral
in interfaceModelCon
-
addLiteral
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 interfaceModelCon
-
addLiteral
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 interfaceModelCon
-
add
Description copied from interface:ModelCon
add a statement to this model. -
add
Description copied from interface:ModelCon
add a statement to this model. -
add
-
addLiteral
Description copied from interface:ModelCon
add a statement to this model.- Specified by:
addLiteral
in interfaceModelCon
- Parameters:
s
- the subject of the statement to addp
- the predicate of the statement to addo
- the object of the statement to add- Returns:
- this model
-
add
Description copied from interface:Model
Add all the statements returned by an iterator to this model. -
add
Description copied from interface:Model
Add all the statements in another model to this model. -
getReader
Description copied from interface:RDFReaderF
return an RDFReader instance for the specified serialization language.- Specified by:
getReader
in interfaceModel
- Specified by:
getReader
in interfaceRDFReaderF
- Parameters:
lang
- the serialization language -null
selects the default (RDF/XML).- Returns:
- the RDFWriter instance
-
read
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.
-
read
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. SeeModel.read(InputStream, String, String)
for explicitily setting the serialization language.See "Reading and Writing RDF in Apache Jena" for more information about concrete syntaxes.
-
read
Description copied from interface:Model
Add statements from a document. This method assumes the concrete syntax is RDF/XML. SeeModel.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 interfaceModel
- Parameters:
reader
- the input streambase
- 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 benull
. 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
Description copied from interface:Model
Add statements from a serializion in languagelang
to the model.
Predefined values forlang
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.
-
read
Description copied from interface:Model
Read into this model the RDF aturl
, usingbaseURI
as the base URI if it is non-null. The RDF is assumed to be RDF/XML unlesslang
is non-null, in which case it names the language to be used. Answer this model. -
read
Description copied from interface:Model
Using this method is often a mistake. Add RDF statements represented in languagelang
to the model.
Predefined values forlang
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 interfaceModel
- Parameters:
reader
- the source of the input serializationbase
- 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 benull
. 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 serializationnull
selects the default- Returns:
- this model
-
read
Description copied from interface:Model
Add RDF statements represented in languagelang
to the model.
Predefined values forlang
are "RDF/XML", "N-TRIPLE", "TURTLE" (or "TTL").null
represents the default language, "RDF/XML". "RDF/XML-ABBREV" is a synonym for "RDF/XML".- Specified by:
read
in interfaceModel
- Parameters:
reader
- the source of the input serializationbase
- 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 benull
. 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 serializationnull
selects the default- Returns:
- this model
-
getWriter
Get the model's writer after priming it with the model's namespace prefixes.- Specified by:
getWriter
in interfaceModel
- Specified by:
getWriter
in interfaceRDFWriterF
- Parameters:
lang
- the serialization language -null
selects the default (RDF/XML)- Returns:
- the RDFWriter instance
-
write
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.
-
write
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 bynull
is "RDF/XML". -
write
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 bynull
, is "RDF/XML". -
write
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 bynull
is "RDF/XML". -
write
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 bynull
, is "RDF/XML". -
write
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 bynull
, is "RDF/XML".- Specified by:
write
in interfaceModel
- Parameters:
writer
- The output stream to which the RDF is writtenlang
- The language in which the RDF should be writtenbase
- 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 oflang
, this value may be included in the output.- Returns:
- This model
-
remove
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.
-
remove
Description copied from interface:ModelCon
remove the statement(s, p, o)
from this model and answer this model. None ofs, p, o
are permitted to benull
: for wildcard removal, seeremoveAll
. -
remove
Description copied from interface:ModelCon
Remove all the Statements returned by an iterator. -
remove
Description copied from interface:ModelCon
Remove all the Statements in a given model, including reified statements -
removeAll
Description copied from interface:Model
Remove all the statements from this model. -
removeAll
Description copied from interface:Model
Remove all the statements matching (s, p, o) from this model. -
containsLiteral
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 interfaceModelCon
-
containsLiteral
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 interfaceModelCon
-
containsLiteral
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 interfaceModelCon
-
containsLiteral
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 interfaceModelCon
-
containsLiteral
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 interfaceModelCon
-
containsLiteral
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 interfaceModelCon
-
contains
Description copied from interface:ModelCon
Determine if a statement is present in this model. -
contains
Description copied from interface:ModelCon
Determine if a statement is present in this model.- Specified by:
contains
in interfaceModelCon
- 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
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 interfaceModelCon
-
containsAny
Description copied from interface:Model
Determine if any of the statements in a model are also contained in this model.- Specified by:
containsAny
in interfaceModel
- 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
Description copied from interface:Model
Determine if all of the statements in a model are also contained in this model.- Specified by:
containsAll
in interfaceModel
- 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
Description copied from interface:Model
Determine if any of the statements returned by an iterator are contained in this model.- Specified by:
containsAny
in interfaceModel
- 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
Description copied from interface:Model
Determine if all of the statements returned by an iterator are contained in this model.- Specified by:
containsAll
in interfaceModel
- 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
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 thepredicate
argument and whose object matches theobject
argument. If an argument isnull
it matches anything.- Specified by:
listStatements
in interfaceModel
- Parameters:
S
- The subject soughtP
- The predicate soughtO
- The value sought- Returns:
- an iterator over the subjects
-
listStatements
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 thepredicate
argument and whose object matchestheobject
argument.- Specified by:
listStatements
in interfaceModelCon
- Parameters:
S
- The subject soughtP
- The predicate soughtO
- The value sought- Returns:
- an iterator over the subjects
-
listStatements
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 thepredicate
argument and whose object matchestheobject
argument. If an argument isnull
it matches anything.- Specified by:
listStatements
in interfaceModelCon
- Parameters:
S
- The subject soughtP
- The predicate soughtO
- The value soughtL
- The lang code ofthe string.- Returns:
- an iterator over the subjects
-
listLiteralStatements
Description copied from interface:ModelCon
Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.- Specified by:
listLiteralStatements
in interfaceModelCon
-
listLiteralStatements
Description copied from interface:ModelCon
Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.- Specified by:
listLiteralStatements
in interfaceModelCon
-
listLiteralStatements
Description copied from interface:ModelCon
Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.- Specified by:
listLiteralStatements
in interfaceModelCon
-
listLiteralStatements
Description copied from interface:ModelCon
Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.- Specified by:
listLiteralStatements
in interfaceModelCon
-
listLiteralStatements
Description copied from interface:ModelCon
Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.- Specified by:
listLiteralStatements
in interfaceModelCon
-
listLiteralStatements
Description copied from interface:ModelCon
Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.- Specified by:
listLiteralStatements
in interfaceModelCon
-
listResourcesWithProperty
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 interfaceModelCon
-
listResourcesWithProperty
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 interfaceModelCon
-
listResourcesWithProperty
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 interfaceModelCon
-
listResourcesWithProperty
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 interfaceModelCon
-
listResourcesWithProperty
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 interfaceModelCon
-
listResourcesWithProperty
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 interfaceModelCon
-
listSubjectsWithProperty
Description copied from interface:Model
An alias forlistResourcesWithProperty
, retained for backward compatibility. It may be deprecated in later releases.- Specified by:
listSubjectsWithProperty
in interfaceModel
-
listSubjectsWithProperty
Description copied from interface:ModelCon
lists all subjects with a given property and property value.- Specified by:
listSubjectsWithProperty
in interfaceModelCon
- Parameters:
p
- The predicate sought.o
- The property value sought.- Returns:
- an iterator over the set of subjects
-
listSubjectsWithProperty
Description copied from interface:ModelCon
lists all subjects with a given property and property value.- Specified by:
listSubjectsWithProperty
in interfaceModelCon
- 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
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 interfaceModelCon
- Parameters:
type
- the type of the resource to be created.- Returns:
- a new anonymous resource linked to this model.
-
createResource
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 interfaceModelCon
- 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
Description copied from interface:Model
Create a resource that represents a statement. This is in support of RDF-star.- Specified by:
createResource
in interfaceModel
- Returns:
- a new resource linked to this model.
-
createTypedLiteral
create a type literal from a boolean value.The value is converted to a string using its
toString
method.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createTypedLiteral
create a typed literal from an integer value.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createTypedLiteral
create a typed literal from a long integer value.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createTypedLiteral
create a typed literal from a char value.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createTypedLiteral
create a typed literal from a float value.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createTypedLiteral
create a typed literal from a double value.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createTypedLiteral
create a typed literal from a String value.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createTypedLiteral
Create a typed literal xsd:dateTime from a Calendar object.- Specified by:
createTypedLiteral
in interfaceModelCon
-
createTypedLiteral
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 interfaceModel
- Parameters:
lex
- the lexical form of the literaldtype
- the type of the literal, null for old style "plain" literals- Throws:
DatatypeFormatException
- if lex is not a legal form of dtype
-
createTypedLiteral
Build a typed literal from its value form.- Specified by:
createTypedLiteral
in interfaceModel
- Parameters:
value
- the value of the literaldtype
- the type of the literal, null for old style "plain" literals
-
createTypedLiteral
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 interfaceModelCon
- Parameters:
lex
- the lexical form of the literaltypeURI
- 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
Build a typed literal from its value form.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
value
- the value of the literaltypeURI
- the URI of the type of the literal, null for old style "plain" literals
-
createTypedLiteral
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 interfaceModel
- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
value
- the literal value to encapsulate- Returns:
- a new literal representing the value v
-
createLiteral
Description copied from interface:ModelCon
create a literal from a String value.- Specified by:
createLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createLiteral
Description copied from interface:Model
Create an untyped literal from a String value with a specified language.- Specified by:
createLiteral
in interfaceModel
- Parameters:
v
- the lexical form of the literall
- the language associated with the literal- Returns:
- a new literal representing the value v with the given language
-
createLiteralStatement
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 interfaceModelCon
-
createLiteralStatement
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 interfaceModelCon
-
createLiteralStatement
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 interfaceModelCon
-
createLiteralStatement
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 interfaceModelCon
-
createLiteralStatement
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 interfaceModelCon
-
createLiteralStatement
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 interfaceModelCon
-
createStatement
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 interfaceModelCon
- Parameters:
r
- the subject of the statementp
- the predicate of the statemento
- is the value to be the object of the statement- Returns:
- the new statement
-
createLiteralStatement
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 interfaceModelCon
-
createStatement
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 interfaceModelCon
- Parameters:
r
- the subject of the statementp
- the predicate of the statemento
- is the value to be the object of the statementl
- the language associated with the object- Returns:
- the new statement
-
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.
-
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.
-
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.
-
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 interfaceModel
- Returns:
- An RDF-encoded list of no elements (ie nil)
-
createList
Answer a new list containing the resources from the given iterator, in order.
- Specified by:
createList
in interfaceModel
- 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
Answer a new list containing the RDF nodes from the given array, in order
- Specified by:
createList
in interfaceModel
- Parameters:
members
- An array of RDFNodes that will be the members of the list- Returns:
- An RDF-encoded list
-
getRDFNode
Description copied from interface:ModelCon
Create or find an RDFNode (aResource
or aLiteral
) 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 interfaceModelCon
- Parameters:
n
- the graph.Node on which to base the Model.RDFNode- Returns:
- a suitable RDFNode
-
getResource
Description copied from interface:Model
Return a Resource instance with the given URI in this model. This method behaves identically to
.Model.createResource(String)
Subsequent operations on the returned object may modify this model.
- Specified by:
getResource
in interfaceModel
- Parameters:
uri
- the URI of the resource- Returns:
- a resource instance
-
getResource
Description copied from interface:Model
Return a Resource instance with the given URI in this model. This method behaves identically to
.Model.createResource(AnonId)
Subsequent operations on the returned object may modify this model.
- Specified by:
getResource
in interfaceModel
- Parameters:
id
- An anonymous bode Id.- Returns:
- a resource instance
-
getProperty
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 interfaceModelCon
- Parameters:
uri
- the URI of the property- Returns:
- a property object
-
getProperty
Description copied from interface:Model
Return a Property instance with the given URI in this model. This method behaves identically tocreateProperty(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 interfaceModel
- Parameters:
nameSpace
- the RDF namespace of the propertylocalName
- the localName of the property in its namespace- Returns:
- a property linked to this model
-
getSeq
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. -
getSeq
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. -
getBag
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. -
getBag
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. -
getList
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. -
getList
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. -
getAlt
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. -
getAlt
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. -
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. -
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). -
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 interfaceModel
- Returns:
- an iterator over every predicate and type namespace
- See Also:
-
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 interfacePrefixMapping
- Returns:
- this mapping, locked against changes
-
setNsPrefix
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 interfaceModel
- Specified by:
setNsPrefix
in interfacePrefixMapping
- Parameters:
prefix
- the string to be used for the prefix.uri
- the URI prefix to be named- Returns:
- this PrefixMapping
-
removeNsPrefix
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 interfaceModel
- Specified by:
removeNsPrefix
in interfacePrefixMapping
- Parameters:
prefix
- the prefix string to remove- Returns:
- this PrefixMapping
-
clearNsPrefixMap
Description copied from interface:PrefixMapping
Clear this prefix mapping of all mappings- Specified by:
clearNsPrefixMap
in interfaceModel
- Specified by:
clearNsPrefixMap
in interfacePrefixMapping
-
setNsPrefixes
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 interfaceModel
- Specified by:
setNsPrefixes
in interfacePrefixMapping
- Parameters:
map
- the Map whose maplets are to be added- Returns:
- this PrefixMapping
-
getNsPrefixURI
Description copied from interface:PrefixMapping
Get the URI bound to a specific prefix, null if there isn't one.- Specified by:
getNsPrefixURI
in interfacePrefixMapping
- Parameters:
prefix
- the prefix name to be looked up- Returns:
- the most recent URI bound to that prefix name, null if none
-
getNsURIPrefix
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 interfacePrefixMapping
- 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
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 interfacePrefixMapping
- Returns:
- a copy of the internal String -> String mapping
-
expandPrefix
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 interfacePrefixMapping
- Parameters:
prefixed
- a QName or URI- Returns:
- the expanded string if possible, otherwise the original string
-
qnameFor
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 interfacePrefixMapping
-
shortForm
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 interfacePrefixMapping
- 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 interfacePrefixMapping
-
numPrefixes
public int numPrefixes()Description copied from interface:PrefixMapping
Return the number of defined prefixes.- Specified by:
numPrefixes
in interfacePrefixMapping
-
addNamespaces
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 whose namespace is to be updatedns
- the namespace map to add to the Model
-
listStatements
Description copied from interface:Model
List all statements.Subsequent operations on those statements may modify this model.
- Specified by:
listStatements
in interfaceModel
- Returns:
- an iterator over all statements in the model.
-
add
add a Statement to this Model by adding its SPO components. -
add
Add all the statements to the model by converting them to an array of corresponding triples and removing those from the underlying graph. -
add
Add all the statements to the model by converting the list to an array of Statement and removing that. -
remove
remove all the Statements from the model by converting them to triples and removing those triples from the underlying graph. -
remove
Remove all the Statements from the model by converting the List to a List(Statement) and removing that. -
add
Description copied from interface:ModelCon
add a statement to this model. -
contains
Description copied from interface:Model
Determine if a statement is present in this model. -
containsResource
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 interfaceModel
- Parameters:
r
- the RDFNode to be searched for- Returns:
- true iff r appears as some subject, predicate, or object
-
contains
Description copied from interface:Model
Determine whether this model contains any statements with a given subject and property. -
contains
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 interfaceModel
- 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
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 interfaceModel
- 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
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 interfaceModel
- 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
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 interfaceModel
- Parameters:
s
- the subject of the statement to returnp
- the predicate of the statement to return- Returns:
- some statement (s, p, ?O) or null if none can be found
-
getProperty
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 interfaceModel
- Parameters:
s
- the subject of the statement to returnp
- the predicate of the statement to returnlang
- language of the object- Returns:
- some statement (s, p, ?O@lang) or null if none can be found
-
asNode
-
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 interfaceModel
- Returns:
- an iterator over a set of resources which are subjects of statements in the model. .remove() is not implemented on this iterator.
-
listResourcesWithProperty
Description copied from interface:Model
Answer an iterator [with no duplicates] over all the resources in this model that have propertyp
.remove()
is not implemented on this iterator.- Specified by:
listResourcesWithProperty
in interfaceModel
-
listSubjectsWithProperty
Description copied from interface:Model
An alias forlistResourcesWithProperty(Property)
, retained for backward compatibility. It may be deprecated in later releases.- Specified by:
listSubjectsWithProperty
in interfaceModel
-
listResourcesWithProperty
Description copied from interface:Model
Answer an iterator [with no duplicates] over all the resources in this model that have propertyp
with valueo
.remove()
is not implemented on this iterator.- Specified by:
listResourcesWithProperty
in interfaceModel
-
listObjects
Description copied from interface:Model
List all objects in a model.- Specified by:
listObjects
in interfaceModel
- Returns:
- an iterator over the objects. .remove() is not implemented on this iterator.
-
listObjectsOfProperty
Description copied from interface:Model
List all objects of a given property. .remove() is not implemented on this iterator.- Specified by:
listObjectsOfProperty
in interfaceModel
- Parameters:
p
- The predicate sought- Returns:
- an iterator over the objects
-
listObjectsOfProperty
Description copied from interface:Model
List the values of a property of a resource.- Specified by:
listObjectsOfProperty
in interfaceModel
p
- The predicate sought- Returns:
- an iterator over the objects. .remove() is not implemented on this iterator.
-
supportsTransactions
public boolean supportsTransactions()Description copied from interface:Model
Determine whether this model supports transactions.- Specified by:
supportsTransactions
in interfaceModel
- Returns:
- true if this model supports transactions.
-
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.
-
abort
Description copied from interface:Model
Abort the current transaction and abandon any changes in progress. -
commit
Description copied from interface:Model
Commit the current transaction. -
executeInTxn
Description copied from interface:Model
Execute the runnableaction
within a transaction. If it completes normally, commit the transaction, otherwise abort the transaction.- Specified by:
executeInTxn
in interfaceModel
-
calculateInTxn
Execute the supplieraction
within a transaction. If it completes normally, commit the transaction and return the result, otherwise abort the transaction.- Specified by:
calculateInTxn
in interfaceModel
-
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 interfaceModel
- Returns:
- true if this model is indepdent of others
-
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 interfaceModel
- Returns:
- a new anonymous resource linked to this model.
-
createResource
Description copied from interface:Model
Create a new resource associated with this model. If the uri string is null, this creates a bnode, as percreateResource()
. 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 interfaceModel
- Parameters:
uri
- the URI of the resource to be created- Returns:
- a new resource linked to this model.
-
createResource
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 interfaceModel
- Parameters:
anonId
- the identifier to use for this blank node- Returns:
- a blank node with that identifier
-
createProperty
Description copied from interface:ModelCon
Create a property.Subsequent operations on the returned property may modify this model.
- Specified by:
createProperty
in interfaceModelCon
- Parameters:
uri
- the URI of the property- Returns:
- a property instance
-
createProperty
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 interfaceModel
- Parameters:
nameSpace
- the nameSpace of the propertylocalName
- the name of the property within its namespace- Returns:
- a property instance
-
createStatement
create a Statement from the given r, p, and o.- Specified by:
createStatement
in interfaceModel
- Parameters:
r
- the subject of the statementp
- the predicate of the statemento
- the object of the statement- Returns:
- the new statement
-
createBag
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.
-
createAlt
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.
-
createSeq
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.
-
asStatement
Answer a Statement in this Model which encodes the given Triple.- Specified by:
asStatement
in interfaceModelGraphInterface
- Parameters:
t
- a triple to wrap as a statement- Returns:
- a statement wrapping the triple and in this model
-
asStatements
-
asStatements
-
asModel
-
asStatements
-
listBySubject
-
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.
-
isClosed
public boolean isClosed()Description copied from interface:Model
Answer true iff .close() has been called on this Model. -
supportsSetOperations
public boolean supportsSetOperations()Description copied from interface:Model
Determine whether this model supports set operations.- Specified by:
supportsSetOperations
in interfaceModel
- Returns:
- true if this model supports set operations.
-
union
Description copied from interface:Model
Create a new, independent, model containing all the statements in this model together with all of those in another given model. By independent 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.
-
intersection
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, sincesize()
can be expensive on database and inference models.- Specified by:
intersection
in interfaceModel
- Parameters:
other
- The other model.- Returns:
- A new model containing all the statements that are in both models.
- See Also:
-
intersect
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
Description copied from interface:Model
Create a new, independent, 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 interfaceModel
- 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
-
reifiedToString
-
isIsomorphicWith
Answer whether or not these two graphs are isomorphic.- Specified by:
isIsomorphicWith
in interfaceModel
- Parameters:
m
- Compare against this.- Returns:
- boolean True if the two RDF graphs are isomorphic.
-
getModelLock
-
getLock
Description copied from interface:Model
Get the model lock for this model.See also the operations
Lock.enterCriticalSection(boolean)
andLock.leaveCriticalSection()
.It is better to use transactions.
-
enterCriticalSection
public void enterCriticalSection(boolean requestReadLock) Description copied from interface:Lock
Enter a critical section. The application must call leaveCriticialSection.- Specified by:
enterCriticalSection
in interfaceLock
- 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 interfaceLock
- See Also:
-
register
Register the listener with this model by registering its GraphListener adaption with the underlying Graph. -
unregister
Unregister the listener from this model by unregistering its GraphListener adaption from the underlying Graph.- Specified by:
unregister
in interfaceModel
- 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 inL
.- Parameters:
L
- a model listener to be wrapped as a graph listener- Returns:
- a graph listener wrapping L
- See Also:
-
notifyEvent
Description copied from interface:Model
Notify any listeners that the event e has occurred.- Specified by:
notifyEvent
in interfaceModel
- Parameters:
e
- the event that has occurred
-