public interface Model extends ModelCon, ModelGraphInterface, RDFReaderF, RDFWriterF, PrefixMapping, Lock
An RDF model is a set of Statements. Methods are provided for creating resources, properties and literals and the Statements which link them, for adding statements to and removing them from a model, for querying a model and set operations for combining models.
Models may create Resources [URI nodes and bnodes]. Creating a Resource does not make the Resource visible to the model; Resources are only "in" Models if Statements about them are added to the Model. Similarly the only way to "remove" a Resource from a Model is to remove all the Statements that mention it.
When a Resource or Literal is created by a Model, the Model is free to re-use an existing Resource or Literal object with the correct values, or it may create a fresh one. [All Jena RDFNodes and Statements are immutable, so this is generally safe.]
This interface defines a set of primitive methods. A set of
convenience methods which extends this interface, e.g. performing
automatic type conversions and support for enhanced resources,
is defined in ModelCon
.
-DsocksProxyHost=[your-proxy-domain-name-or-ip-address]
To use an http proxy, include on the command line:
-DproxySet=true -DproxyHost=[your-proxy] -DproxyPort=[your-proxy-port-number]
Alternatively, these properties can be set programatically, e.g.
System.getProperties().put("proxySet","true");
System.getProperties().put("proxyHost","proxy.hostname");
System.getProperties().put("proxyPort",port_number);
PrefixMapping.Factory, PrefixMapping.IllegalPrefixException, PrefixMapping.JenaLockedException
Extended, Standard
Modifier and Type | Method and Description |
---|---|
Model |
abort()
Abort the current transaction and abandon any changes in progress.
|
Model |
add(List<Statement> statements)
add all the statements in the List to this Model, going through the bulk
update interface (which means turning them into triples in one form or
another).
|
Model |
add(Model m)
Add all the statements in another model to this model, including the
reified statements.
|
Model |
add(Statement s)
Add a statement to this model.
|
Model |
add(Statement[] statements)
Add all the statements to the Model, using through the bulk update interface.
|
Model |
add(StmtIterator iter)
Add all the statements returned by an iterator to this model.
|
Model |
begin()
Begin a new transaction.
|
<T> T |
calculateInTxn(Supplier<T> action)
Execute the supplier
action within a transaction. |
Model |
clearNsPrefixMap()
Clear this prefix mapping of all mappings
|
void |
close()
Close the Model and free up resources held.
|
Model |
commit()
Commit the current transaction.
|
boolean |
contains(Resource s,
Property p)
Determine whether this model contains any statements with a given subject
and property.
|
boolean |
contains(Resource s,
Property p,
RDFNode o)
Determine if an (S, P, O) pattern is present in this model, with null allowed
to represent a wildcard match.
|
boolean |
contains(Statement s)
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 |
containsResource(RDFNode r)
determine if the RDFNode r appears in any statement of this model.
|
RDFList |
createList()
Answer a new empty list.
|
RDFList |
createList(Iterator<? extends RDFNode> members)
Answer a new list containing the resources from the given iterator, in order.
|
RDFList |
createList(RDFNode... members)
Answer a new list containing the nodes from the given eleemnts, in order.
|
Literal |
createLiteral(String v,
boolean wellFormed)
Create a literal from a String value.
|
Literal |
createLiteral(String v,
String language)
Create an untyped literal from a String value with a specified language.
|
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.
|
ReifiedStatement |
createReifiedStatement(Statement s)
Answer a ReifiedStatement that encodes _s_ and belongs to this Model.
|
ReifiedStatement |
createReifiedStatement(String uri,
Statement s)
answer a ReifiedStatement that encodes _s_, belongs to this Model,
and is a Resource with that _uri_.
|
Resource |
createResource()
Create a new anonymous resource whose model is this model.
|
Resource |
createResource(AnonId id)
Create a blank node resource with a specified identifier.
|
Resource |
createResource(String uri)
Create a new resource associated with this model.
|
Statement |
createStatement(Resource s,
Property p,
RDFNode o)
Create a Statement instance.
|
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.
|
Literal |
createTypedLiteral(Object value,
RDFDatatype dtype)
Build a typed literal from its value form.
|
Literal |
createTypedLiteral(String lex,
RDFDatatype dtype)
Build a typed literal from its lexical form.
|
Model |
difference(Model model)
Create a new, independant, model containing all the statements in this model which
are not in another.
|
boolean |
equals(Object m)
Test whether the given object
m
is a model that is equal to this model,
which is true iff the underlying graphs are identical Java
objects. |
Object |
executeInTransaction(Command cmd)
Deprecated.
use
calculateInTxn(Supplier) or migrate to executeInTxn(Runnable) . |
void |
executeInTxn(Runnable action)
Execute the runnable
action within a transaction. |
Resource |
getAnyReifiedStatement(Statement s)
Find or create a
ReifiedStatement corresponding to a Statement. |
Lock |
getLock()
Get the model lock for this model.
|
Statement |
getProperty(Resource s,
Property p)
Answer a statement (s, p, ?O) from this model.
|
Statement |
getProperty(Resource s,
Property p,
String lang)
Answer a statement (s, p, ?O) from this model.
|
Property |
getProperty(String nameSpace,
String localName)
Return a Property instance with the given URI in this model.
|
Statement |
getRequiredProperty(Resource s,
Property p)
Return a statement with given subject and property.
|
Statement |
getRequiredProperty(Resource s,
Property p,
String lang)
Return a statement with given subject and property.
|
Resource |
getResource(String uri)
Return a Resource instance with the given URI in this model.
|
boolean |
independent()
Determine whether this model is independent.
|
Model |
intersection(Model model)
Create a new, independant, model containing all the statements which are in both
this model and another.
|
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 |
isIsomorphicWith(Model g)
Compare this Model with another for equality ignoring the labels on
bNodes.
|
boolean |
isReified(Statement s)
Determine if this Statement has been reified in this Model.
|
NsIterator |
listNameSpaces()
(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.
|
NodeIterator |
listObjects()
List all objects in a model.
|
NodeIterator |
listObjectsOfProperty(Property p)
List all objects of a given property.
|
NodeIterator |
listObjectsOfProperty(Resource s,
Property p)
List the values of a property of a resource.
|
RSIterator |
listReifiedStatements()
answer an iterator delivering all the reified statements "in" this model
|
RSIterator |
listReifiedStatements(Statement st)
answer an iterator delivering all the reified statements "in" this model
that match the statement _st_.
|
ResIterator |
listResourcesWithProperty(Property p)
Answer an iterator [with no duplicates] over all the resources in this
model that have property
p . |
ResIterator |
listResourcesWithProperty(Property p,
RDFNode o)
Answer an iterator [with no duplicates] over all the resources in this
model that have property
p with value o . |
StmtIterator |
listStatements()
List all statements.
|
StmtIterator |
listStatements(Resource s,
Property p,
RDFNode o)
Find all the statements matching a pattern.
|
StmtIterator |
listStatements(Selector s)
List the statements matching a selector.
|
ResIterator |
listSubjects()
List all resources which are subjects of statements.
|
ResIterator |
listSubjectsWithProperty(Property p)
An alias for
listResourcesWithProperty(Property) ,
retained for backward compatibility. |
ResIterator |
listSubjectsWithProperty(Property p,
RDFNode o)
An alias for
listResourcesWithProperty , retained for
backward compatibility. |
Model |
notifyEvent(Object e)
Notify any listeners that the event e has occurred.
|
Model |
query(Selector s)
Create a new model containing the statements matching a query.
|
Model |
read(InputStream in,
String base)
Add statements from a document.
|
Model |
read(InputStream in,
String base,
String lang)
Add RDF statements represented in language
lang to the model. |
Model |
read(Reader reader,
String base)
Using this method is often a mistake.
|
Model |
read(Reader reader,
String base,
String lang)
Using this method is often a mistake.
|
Model |
read(String url)
Add the RDF statements from a document.
|
Model |
read(String url,
String lang)
Add statements from a serializion in language
lang to the
model. |
Model |
read(String url,
String base,
String lang)
Read into this model the RDF at
url , using
baseURI as the base URI if it is non-null. |
Model |
register(ModelChangedListener listener)
Register a listener for model-changed events on this model.
|
Model |
remove(List<Statement> statements)
Remove all the statements in the list from this model, using the bulk
update interface.
|
Model |
remove(Statement s)
Removes a statement.
|
Model |
remove(Statement[] statements)
Remove all the statements from the Model, using the bulk update interface.
|
Model |
removeAll()
Remove all the statements from this model.
|
Model |
removeAll(Resource s,
Property p,
RDFNode r)
Remove all the statements matching (s, p, o) from this model.
|
void |
removeAllReifications(Statement s)
Remove all reifications (ie implicit reification quads) of _s_.
|
Model |
removeNsPrefix(String prefix)
Remove any existing maplet with the given prefix name and answer this
mapping.
|
void |
removeReification(ReifiedStatement rs)
Remove a particular reificiation.
|
Model |
setNsPrefix(String prefix,
String uri)
Specify the prefix name for a URI prefix string.
|
Model |
setNsPrefixes(Map<String,String> map)
Copies the prefix mapping from other into this.
|
Model |
setNsPrefixes(PrefixMapping other)
Copies the prefixes from other into this.
|
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 numberof statements
in the model but it is possible for a subsequent listStatements on
such a model to discover more statements than size() indicated.
|
boolean |
supportsSetOperations()
Determine whether this model supports set operations.
|
boolean |
supportsTransactions()
Determine whether this model supports transactions.
|
Model |
union(Model model)
Create a new, independant, model containing all the statements in this model
together with all of those in another given model.
|
Model |
unregister(ModelChangedListener listener)
Unregister a listener from model-changed events on this model.
|
Model |
withDefaultMappings(PrefixMapping map)
Update this PrefixMapping with the bindings in
map , only
adding those (p, u) pairs for which neither p nor u appears in this mapping. |
Model |
write(OutputStream out)
Write a serialization of this model as an XML document.
|
Model |
write(OutputStream out,
String lang)
Write a serialized representation of this model in a specified language.
|
Model |
write(OutputStream out,
String lang,
String base)
Write a serialized representation of a model in a specified language.
|
Model |
write(Writer writer)
Write the model as an XML document.
|
Model |
write(Writer writer,
String lang)
Write a serialized representation of a model in a specified language.
|
Model |
write(Writer writer,
String lang,
String base)
Write a serialized representation of a model in a specified language.
|
add, add, add, add, add, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, contains, contains, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, containsLiteral, createAlt, createAlt, createBag, createBag, createLiteral, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createLiteralStatement, createProperty, createResource, createResource, createResource, createResource, createSeq, createSeq, createStatement, createStatement, createStatement, createStatement, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, getAlt, getAlt, getBag, getBag, getList, getList, getProperty, getRDFNode, getResource, getSeq, getSeq, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listLiteralStatements, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listResourcesWithProperty, listStatements, listStatements, listSubjectsWithProperty, listSubjectsWithProperty, remove, remove, remove
asRDFNode, asStatement, getGraph, wrapAsResource
getReader, getReader, removeReader, resetRDFReaderF, setReaderClassName
getWriter, getWriter, removeWriter, resetRDFWriterF, setWriterClassName
expandPrefix, getNsPrefixMap, getNsPrefixURI, getNsURIPrefix, hasNoMappings, lock, numPrefixes, qnameFor, samePrefixMappingAs, shortForm
enterCriticalSection, leaveCriticalSection
long size()
boolean isEmpty()
ResIterator listSubjects()
Subsequent operations on those resource may modify this model.
NsIterator listNameSpaces()
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.
PrefixMapping
Resource getResource(String uri)
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.
uri
- the URI of the resourceProperty getProperty(String nameSpace, String localName)
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.
nameSpace
- the RDF namespace of the propertylocalName
- the localName of the property in its namespaceResource createResource()
Subsequent operations on the returned resource may modify this model.
Resource createResource(AnonId id)
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
id
- the identifier to use for this blank nodeResource createResource(String uri)
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.
uri
- the URI of the resource to be createdProperty createProperty(String nameSpace, String localName)
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.
nameSpace
- the nameSpace of the propertylocalName
- the name of the property within its namespaceLiteral createLiteral(String v, String language)
v
- the lexical form of the literallanguage
- the language associated with the literalLiteral createLiteral(String v, boolean wellFormed)
v
- the lexical form of the literalwellFormed
- true if the Literal is well formed XML, in the lexical space of rdf:XMLLiteralLiteral createTypedLiteral(String lex, RDFDatatype dtype)
Note that in preview releases of Jena2 it was also possible to specify
a language type. Changes to the RDF specification mean that this is no longer
legal except for plain literals. To create a plain literal with a language tag
use createLiteral
.
lex
- the lexical form of the literaldtype
- the type of the literal, null for old style "plain" literalsDatatypeFormatException
- if lex is not a legal form of dtypeLiteral createTypedLiteral(Object value, RDFDatatype dtype)
Note that in preview releases of Jena2 it was also possible to specify
a language type. Changes to the RDF specification mean that this is no longer
legal except for plain literals. To create a plain literal with a language tag
use createLiteral
.
value
- the value of the literaldtype
- the type of the literal, null for old style "plain" literalsLiteral createTypedLiteral(Object value)
createTypedLiteral
in interface ModelCon
value
- the literal value to encapsulateStatement createStatement(Resource s, Property p, RDFNode o)
Subsequent operations on the statement or any of its parts may modify this model.
s
- the subject of the statementp
- the predicate of the statemento
- the object of the statementRDFList createList()
rdf:nil
.RDFList createList(Iterator<? extends RDFNode> members)
Answer a new list containing the resources from the given iterator, in order.
members
- An iterator, each value of which is expected to be an RDFNodeRDFList createList(RDFNode... members)
Answer a new list containing the nodes from the given eleemnts, in order. If the list of elements is empty, until the list is made the object or subject in the model, or has an element added, it will not appear in the model (e.g. when written out).
members
- An array of RDF nodes that will be the members of the listModel add(Statement s)
s
- The statement to be added.Model add(Statement[] statements)
statements
- the array of statements to addModel remove(Statement[] statements)
statements
- the array of statements to be addedModel add(List<Statement> statements)
statements
- a List of StatementsModel remove(List<Statement> statements)
statements
- a List of Statements to removeModel add(StmtIterator iter)
iter
- An iterator which returns the statements to be added.Model add(Model m)
m
- The model whose statements are to be added.Model read(String 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.
url
- of the document containing the RDF statements.Model read(InputStream in, String base)
read(InputStream, String, String)
for explicitly setting the language.
See "Reading and Writing RDF in Apache Jena" for more information about concrete syntaxes.
in
- 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 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.Model read(InputStream in, String base, String lang)
lang
to the model.
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".
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 defaultin
- the source of the input serializationModel read(Reader reader, String base)
read(InputStream, String, String)
for explicitily setting the serialization language.
See "Reading and Writing RDF in Apache Jena" for more information about concrete syntaxes.
reader
- base
- the base uri to be used when converting relative URI's to absolute URI's and to guess the RDF serialization syntax.Model read(String url, String lang)
lang
to the
model.
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.
url
- a string representation of the url to read fromlang
- the language of the serializationModel read(Reader reader, String base, String lang)
lang
to the model.
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".
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.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 defaultreader
- the source of the input serializationModel read(String url, String base, String lang)
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.Model write(Writer writer)
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.
writer
- A writer to which the XML will be writtenModel write(Writer writer, String lang)
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".
writer
- The output writerlang
- The output languageModel write(Writer writer, String lang, String base)
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".
writer
- The output writerbase
- The base uri for relative URI calculations.
null
means use only absolute URI's.lang
- The language in which the RDF should be writtenModel write(OutputStream out)
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".
out
- The output stream to which the XML will be writtenModel write(OutputStream out, String lang)
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".
out
- The output stream to which the RDF is writtenlang
- The output languageModel write(OutputStream out, String lang, String base)
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".
out
- The output stream to which the RDF is 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 of lang
, this value may be included in the output.lang
- The language in which the RDF should be writtenModel remove(Statement s)
The statement with the same subject, predicate and object as that supplied will be removed from the model.
s
- The statement to be removed.Statement getRequiredProperty(Resource s, Property p)
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.
s
- The subject of the statement to be returned.p
- The property of the statement to be returned.PropertyNotFoundException
Statement getRequiredProperty(Resource s, Property p, String lang)
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.
s
- The subject of the statement to be returned.p
- The property of the statement to be returned.lang
- The languagePropertyNotFoundException
Statement getProperty(Resource s, Property p)
s
- the subject of the statement to returnp
- the predicate of the statement to returnStatement getProperty(Resource s, Property p, String lang)
s
- the subject of the statement to returnp
- the predicate of the statement to returnlang
- language of the objectResIterator listSubjectsWithProperty(Property p)
listResourcesWithProperty(Property)
,
retained for backward compatibility. It may be deprecated in later
releases.ResIterator listResourcesWithProperty(Property p)
p
. remove()
is not implemented on this iterator.ResIterator listSubjectsWithProperty(Property p, RDFNode o)
listResourcesWithProperty
, retained for
backward compatibility. It may be deprecated in later releases.ResIterator listResourcesWithProperty(Property p, RDFNode o)
p
with value o
.
remove()
is not implemented on this iterator.NodeIterator listObjects()
NodeIterator listObjectsOfProperty(Property p)
p
- The predicate soughtNodeIterator listObjectsOfProperty(Resource s, Property p)
p
- The predicate soughtboolean contains(Resource s, Property p)
s
- The subject sought (null for any).p
- The predicate sought (null for any).boolean containsResource(RDFNode r)
r
- the RDFNode to be searched forboolean contains(Resource s, Property p, RDFNode o)
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).boolean contains(Statement s)
s
- The statement tested.boolean containsAny(StmtIterator iter)
iter
- an iterator of the statements to be testedboolean containsAll(StmtIterator iter)
iter
- an iterator of the statements to be testedboolean containsAny(Model model)
model
- the model containing the statements to be testedboolean containsAll(Model model)
model
- the model containing the statements to be testedboolean isReified(Statement s)
s
- The statement tested.Resource getAnyReifiedStatement(Statement s)
ReifiedStatement
corresponding to a Statement.s
- Statement which may or may not already be reifiedvoid removeAllReifications(Statement s)
void removeReification(ReifiedStatement rs)
StmtIterator listStatements()
Subsequent operations on those statements may modify this model.
StmtIterator listStatements(Selector s)
A statement is considered to match if the test
method
of s returns true when called on s.
s
- A selector object.
.StmtIterator listStatements(Resource s, Property p, RDFNode o)
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.
s
- The subject soughtp
- The predicate soughto
- The value soughtReifiedStatement createReifiedStatement(Statement s)
ReifiedStatement createReifiedStatement(String uri, Statement s)
RSIterator listReifiedStatements()
RSIterator listReifiedStatements(Statement st)
Model query(Selector s)
A statement is considered to match if the test
method
of s returns true when called on s.
s
- A selector object.
.Model union(Model model)
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.
model
- The other model whose statements are to be included.Model intersection(Model model)
model
- The other model.Model difference(Model model)
model
- the other model whose statements are to be excluded.boolean equals(Object m)
m
is a model that is equal to this model,
which is true iff the underlying graphs are identical Java
objects. This is not the same test as comparing whether two models
have the same structure (i.e. contain the same set of statements).
To test for strucutural equivalence, see isIsomorphicWith(org.apache.jena.rdf.model.Model)
.equals
in class Object
m
- the model to be comparedm
shares a graph object with this modelisIsomorphicWith(Model)
Model begin()
All changes made to a model within a transaction, will either be made, or none of them will be made.
Model abort()
Model commit()
@Deprecated Object executeInTransaction(Command cmd)
calculateInTxn(Supplier)
or migrate to executeInTxn(Runnable)
.void executeInTxn(Runnable action)
action
within a transaction. If it completes normally,
commit the transaction, otherwise abort the transaction.<T> T calculateInTxn(Supplier<T> action)
action
within a transaction. If it completes normally,
commit the transaction and return the result, otherwise abort the transaction.boolean 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.
boolean supportsTransactions()
boolean supportsSetOperations()
boolean isIsomorphicWith(Model g)
Two models are isomorphic when each statement in one can be matched with a statement in the other. Statements which are identical match.
Special treatment is given to anonymous nodes. A binding is a one to
one mapping which maps each anonymous node in this
model to
an anonymous node in model
. Two statements s1 and s2 match
under a binding if s1.subject is anonymous and s2.subject is anonymous
and the binding maps s1.subject to s2.subject.
Two models are isomorphic if there is a binding that allows all the statements in one model to match a a statement in the other.
g
- Compare against this.void close()
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.
Lock getLock()
Lock
Model register(ModelChangedListener listener)
The same listener may be registered many times; if so, it's methods will be called as many times as it's registered for each event.
ModelChangedListener
Model unregister(ModelChangedListener listener)
ModelChangedListener
Model notifyEvent(Object e)
e
- the event that has occurredModel removeAll()
Model removeAll(Resource s, Property p, RDFNode r)
boolean isClosed()
Model setNsPrefix(String prefix, String uri)
PrefixMapping
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.
setNsPrefix
in interface PrefixMapping
prefix
- the string to be used for the prefix.uri
- the URI prefix to be namedModel removeNsPrefix(String prefix)
PrefixMapping
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.
removeNsPrefix
in interface PrefixMapping
prefix
- the prefix string to removeModel clearNsPrefixMap()
PrefixMapping
clearNsPrefixMap
in interface PrefixMapping
Model setNsPrefixes(PrefixMapping other)
PrefixMapping
setNsPrefixes
in interface PrefixMapping
other
- the PrefixMapping to addModel setNsPrefixes(Map<String,String> map)
PrefixMapping
setNsPrefixes
in interface PrefixMapping
map
- the Map whose maplets are to be addedModel withDefaultMappings(PrefixMapping map)
PrefixMapping
map
, only
adding those (p, u) pairs for which neither p nor u appears in this mapping.
Answer this PrefixMapping.withDefaultMappings
in interface PrefixMapping
Licenced under the Apache License, Version 2.0