public interface ModelCon
Model
interface.
The Model
interface provides a set of primitive operations on
an RDF model. This interface extends those methods with a
set of convenience methods.
This interface provides methods supporting typed literals. This means
that methods are provided which will translate a built in type, or an
object to an RDF Literal. This translation is done by invoking the
toString()
method of the object, or its built in equivalent.
The reverse translation is also supported. This is built in for built
in types. Factory objects, provided by the application, are used
for application objects.
This interface provides methods for supporting enhanced resources. An enhanced resource is a resource to which the application has added behaviour. RDF containers are examples of enhanced resources built in to this package. Enhanced resources are supported by encapsulating a resource created by an implementation in another class which adds the extra behaviour. Factory objects are used to construct such enhanced resources.
Modifier and Type | Method and Description |
---|---|
Model |
add(Resource s,
Property p,
RDFNode o)
add a statement to this model.
|
Model |
add(Resource s,
Property p,
String o)
add a statement to this model.
|
Model |
add(Resource s,
Property p,
String o,
boolean wellFormed)
add a statement to this model.
|
Model |
add(Resource s,
Property p,
String lex,
RDFDatatype datatype)
add a statement to this model.
|
Model |
add(Resource s,
Property p,
String o,
String l)
add a statement to this model.
|
Model |
addLiteral(Resource s,
Property p,
boolean o)
Add the statement (s, p, createTypedLiteral( o )) to this model and
answer this model.
|
Model |
addLiteral(Resource s,
Property p,
char o)
Add the statement (s, p, createTypedLiteral( o )) to this model and
answer this model.
|
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.
|
Model |
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.
|
Model |
addLiteral(Resource s,
Property p,
int o)
Add the statement (s, p, createTypedLiteral( o )) to this model and
answer this model.
|
Model |
addLiteral(Resource s,
Property p,
Literal o)
add a statement to this model.
|
Model |
addLiteral(Resource s,
Property p,
long o)
Add the statement (s, p, createTypedLiteral( o )) to this model and
answer this model.
|
Model |
addLiteral(Resource s,
Property p,
Object o)
Deprecated.
Freshly (should have been done a while ago)
|
boolean |
contains(Resource s,
Property p,
String o)
Determine if a statement is present in this model.
|
boolean |
contains(Resource s,
Property p,
String o,
String l)
Determine if a statement is present 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.
|
Alt |
createAlt()
Create a new anonymous alt.
|
Alt |
createAlt(String uri)
Create a new alt.
|
Bag |
createBag()
Create a new anonymous bag.
|
Bag |
createBag(String uri)
Create a new bag.
|
Literal |
createLiteral(String v)
create a literal from a String value.
|
Statement |
createLiteralStatement(Resource s,
Property p,
boolean o)
Answer a new Statement object (s, p, o') where o' is the typed literal
corresponding to o using createTypedLiteral.
|
Statement |
createLiteralStatement(Resource s,
Property p,
char o)
Answer a new Statement object (s, p, o') where o' is the typed literal
corresponding to o using createTypedLiteral.
|
Statement |
createLiteralStatement(Resource s,
Property p,
double o)
Answer a new Statement object (s, p, o') where o' is the typed literal
corresponding to o using createTypedLiteral.
|
Statement |
createLiteralStatement(Resource s,
Property p,
float o)
Answer a new Statement object (s, p, o') where o' is the typed literal
corresponding to o using createTypedLiteral.
|
Statement |
createLiteralStatement(Resource s,
Property p,
int o)
Answer a new Statement object (s, p, o') where o' is the typed literal
corresponding to o using createTypedLiteral.
|
Statement |
createLiteralStatement(Resource s,
Property p,
long o)
Answer a new Statement object (s, p, o') where o' is the typed literal
corresponding to o using createTypedLiteral.
|
Statement |
createLiteralStatement(Resource s,
Property p,
Object o)
Answer a new Statement object (s, p, o') where o' is the typed literal
corresponding to o using createTypedLiteral.
|
Property |
createProperty(String uri)
Create a property.
|
Resource |
createResource(Resource type)
Create a new anonymous resource with a given type.
|
Resource |
createResource(ResourceF f)
Deprecated.
|
Resource |
createResource(String uri,
Resource type)
Create a new resource with a given type.
|
Resource |
createResource(String uri,
ResourceF f)
Deprecated.
|
Seq |
createSeq()
Create a new anonymous seq.
|
Seq |
createSeq(String uri)
Create a new seq.
|
Statement |
createStatement(Resource s,
Property p,
String o)
Create a Statement instance.
|
Statement |
createStatement(Resource s,
Property p,
String o,
boolean wellFormed)
Create a Statement instance.
|
Statement |
createStatement(Resource s,
Property p,
String o,
String l)
Create a Statement instance.
|
Statement |
createStatement(Resource s,
Property p,
String o,
String l,
boolean wellFormed)
Create a Statement instance.
|
Literal |
createTypedLiteral(boolean v)
create a type literal from a boolean value.
|
Literal |
createTypedLiteral(Calendar d)
Create a typed literal of type xsd:dateTime from a Calendar object.
|
Literal |
createTypedLiteral(char v)
create a typed literal from a char value.
|
Literal |
createTypedLiteral(double v)
create a typed literal from a double value.
|
Literal |
createTypedLiteral(float v)
create a typed literal from a float value.
|
Literal |
createTypedLiteral(int v)
create a typed literal from an integer value.
|
Literal |
createTypedLiteral(long v)
create a typed literal from an integer value.
|
Literal |
createTypedLiteral(Object v)
create a literal from an Object.
|
Literal |
createTypedLiteral(Object value,
String typeURI)
Build a typed literal from its value form.
|
Literal |
createTypedLiteral(String v)
create a typed literal from a String value.
|
Literal |
createTypedLiteral(String lex,
String typeURI)
Build a typed literal from its lexical form.
|
Alt |
getAlt(Resource r)
Return an Alt instance based on a given resource.
|
Alt |
getAlt(String uri)
Return an Alt instance in this model.
|
Bag |
getBag(Resource r)
Return a bag instance based on a given resource.
|
Bag |
getBag(String uri)
Return a Bag instance in this model.
|
Property |
getProperty(String uri)
Return a Property instance in this model.
|
RDFNode |
getRDFNode(Node n)
|
Resource |
getResource(String uri,
ResourceF f)
Deprecated.
|
Seq |
getSeq(Resource r)
Return a Seq instance based on a given resource.
|
Seq |
getSeq(String uri)
Return a Seq instance in this model.
|
StmtIterator |
listLiteralStatements(Resource subject,
Property predicate,
boolean object)
Answer a statement iterator that will iterate over all the statements
(S, P, O) in this model where S matches
subject , P
matches predicate , and O matches the typed literal
corresponding to object . |
StmtIterator |
listLiteralStatements(Resource subject,
Property predicate,
char object)
Answer a statement iterator that will iterate over all the statements
(S, P, O) in this model where S matches
subject , P
matches predicate , and O matches the typed literal
corresponding to object . |
StmtIterator |
listLiteralStatements(Resource subject,
Property predicate,
double object)
Answer a statement iterator that will iterate over all the statements
(S, P, O) in this model where S matches
subject , P
matches predicate , and O matches the typed literal
corresponding to object . |
StmtIterator |
listLiteralStatements(Resource subject,
Property predicate,
float object)
Answer a statement iterator that will iterate over all the statements
(S, P, O) in this model where S matches
subject , P
matches predicate , and O matches the typed literal
corresponding to object . |
StmtIterator |
listLiteralStatements(Resource subject,
Property predicate,
int object)
Answer a statement iterator that will iterate over all the statements
(S, P, O) in this model where S matches
subject , P
matches predicate , and O matches the typed literal
corresponding to object . |
StmtIterator |
listLiteralStatements(Resource subject,
Property predicate,
long object)
Answer a statement iterator that will iterate over all the statements
(S, P, O) in this model where S matches
subject , P
matches predicate , and O matches the typed literal
corresponding to object . |
ResIterator |
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.
|
ResIterator |
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.
|
ResIterator |
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.
|
ResIterator |
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.
|
ResIterator |
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.
|
ResIterator |
listResourcesWithProperty(Property p,
Object 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.
|
StmtIterator |
listStatements(Resource subject,
Property predicate,
String object)
Find all the statements matching a pattern.
|
StmtIterator |
listStatements(Resource subject,
Property predicate,
String object,
String lang)
Find all the statements matching a pattern.
|
ResIterator |
listSubjectsWithProperty(Property p,
String o)
lists all subjects with a given property and property value.
|
ResIterator |
listSubjectsWithProperty(Property p,
String o,
String l)
lists all subjects with a given property and property value.
|
Model |
remove(Model m)
Remove all the Statements in a given model, including reified statements
|
Model |
remove(Resource s,
Property p,
RDFNode o)
remove the statement
(s, p, o) from this model and
answer this model. |
Model |
remove(StmtIterator iter)
Remove all the Statements returned by an iterator.
|
@Deprecated Resource getResource(String uri, ResourceF f)
Subsequent operations on the returned object may modify this model.
The resource is assumed to already exist in the model. If it does not,
createResource
should be used instead.
uri
- the URI of the resourcef
- the factory objectProperty getProperty(String uri)
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.
uri
- the URI of the propertyBag getBag(String uri)
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.
uri
- the URI of the bag.Bag getBag(Resource r)
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.
r
- an untyped Resource instanceAlt getAlt(String uri)
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.
uri
- the URI of the altAlt getAlt(Resource r)
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 bag is assumed to already exist in the model. If it does not,
createAlt
should be used instead.
r
- an untyped Resource instanceSeq getSeq(String uri)
Subsequent operations on the returned bag may modify this model.
The seq is assumed to already exist in the model. If it does not,
createSeq
should be used instead.
uri
- the URI of the seqSeq getSeq(Resource r)
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,
createAlt
should be used instead.
r
- an untyped Resource instanceResource createResource(Resource 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.
type
- the type of the resource to be created.RDFNode getRDFNode(Node n)
Resource
or a Literal
)
from a graph Node. This is provided for users and
developers operating at the API/SPI interface, where Resources are
constructed from Nodes. Providing this method allows each Model
the opportunity to cache node-to-resource maps if it requires.n
- the graph.Node on which to base the Model.RDFNodeResource createResource(String uri, Resource 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.
type
- the type of the resource to be created.uri
- The URI of the new resource.@Deprecated Resource createResource(ResourceF f)
Subsequent operations on the returned resource may modify this model.
f
- A factory object to create the returned object.
.@Deprecated Resource createResource(String uri, ResourceF f)
Subsequent operations on the returned resource may modify this model.
uri
- the URI of the resourcef
- A factory to create the returned object.
.Property createProperty(String uri)
Subsequent operations on the returned property may modify this model.
uri
- the URI of the propertyLiteral createLiteral(String v)
v
- the value of the literalLiteral createTypedLiteral(boolean v)
The value is converted to a string using its toString
method.
v
- the value of the literalLiteral createTypedLiteral(int v)
v
- the value of the literalLiteral createTypedLiteral(long v)
v
- the value of the literalLiteral createTypedLiteral(Calendar d)
Literal createTypedLiteral(char v)
v
- the value of the literalLiteral createTypedLiteral(float v)
v
- the value of the literalLiteral createTypedLiteral(double v)
v
- the value of the literalLiteral createTypedLiteral(String v)
v
- the value of the literalLiteral createTypedLiteral(Object v)
v
- the value of the literal.Literal createTypedLiteral(String lex, String typeURI)
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 literaltypeURI
- the uri of the type of the literal, null for old style "plain" literalsDatatypeFormatException
- if lex is not a legal form of dtypeLiteral createTypedLiteral(Object value, String typeURI)
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 literaltypeURI
- the URI of the type of the literal, null for old style "plain" literalsStatement createLiteralStatement(Resource s, Property p, boolean o)
Statement createLiteralStatement(Resource s, Property p, float o)
Statement createLiteralStatement(Resource s, Property p, double o)
Statement createLiteralStatement(Resource s, Property p, long o)
Statement createLiteralStatement(Resource s, Property p, int o)
Statement createLiteralStatement(Resource s, Property p, char o)
Statement createLiteralStatement(Resource s, Property p, Object o)
Statement createStatement(Resource s, Property p, String o)
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.
s
- the subject of the statementp
- the predicate of the statemento
- is the value to be the object of the statementStatement createStatement(Resource s, Property p, String o, String l)
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.
s
- 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 objectStatement createStatement(Resource s, Property p, String o, boolean wellFormed)
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.
s
- the subject of the statementp
- the predicate of the statemento
- is the value to be the object of the statementwellFormed
- true if the string is well formed XMLStatement createStatement(Resource s, Property p, String o, String l, boolean wellFormed)
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.
s
- 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 objectwellFormed
- true of the string is well formed XMLBag createBag()
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.
Bag createBag(String uri)
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.
uri
- The URI of the new Bag.Alt createAlt()
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.
Alt createAlt(String uri)
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.
uri
- The URI of the new alt.Seq createSeq()
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.
Seq createSeq(String uri)
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.
uri
- The URI of the new seq.Model add(Resource s, Property p, RDFNode o)
s
- the subject of the statement to addp
- the predicate of the statement to addo
- the object of the statement to addModel addLiteral(Resource s, Property p, boolean o)
Model addLiteral(Resource s, Property p, long o)
Model addLiteral(Resource s, Property p, int o)
Model addLiteral(Resource s, Property p, char o)
Model addLiteral(Resource s, Property p, float o)
Model addLiteral(Resource s, Property p, double o)
@Deprecated Model addLiteral(Resource s, Property p, Object o)
s
- the subject of the statement to addp
- the predicate of the statement to addo
- the object of the statement to addModel addLiteral(Resource s, Property p, Literal o)
s
- the subject of the statement to addp
- the predicate of the statement to addo
- the object of the statement to addModel add(Resource s, Property p, String o)
s
- the subject of the statement to addp
- the predicate of the statement to addo
- the object of the statement to addModel add(Resource s, Property p, String lex, RDFDatatype datatype)
s
- the subject of the statement to addp
- the predicate of the statement to addlex
- the lexcial form of the literaldatatype
- the datatype of the literalModel add(Resource s, Property p, String o, boolean wellFormed)
s
- the subject of the statement to addp
- the predicate of the statement to addo
- the object of the statement to addwellFormed
- true if o is well formed XMLModel add(Resource s, Property p, String o, String l)
s
- the subject of the statement to addp
- the predicate of the statement to addo
- the object of the statement to addl
- the language associated with the objectModel remove(Resource s, Property p, RDFNode o)
(s, p, o)
from this model and
answer this model. None of s, p, o
are permitted to
be null
: for wildcard removal, see removeAll
.Model remove(StmtIterator iter)
iter
- the iterator which returns the statements to be removed.Model remove(Model m)
m
- the model containing the statements to be removed.StmtIterator listLiteralStatements(Resource subject, Property predicate, boolean object)
subject
, P
matches predicate
, and O matches the typed literal
corresponding to object
.StmtIterator listLiteralStatements(Resource subject, Property predicate, char object)
subject
, P
matches predicate
, and O matches the typed literal
corresponding to object
.StmtIterator listLiteralStatements(Resource subject, Property predicate, long object)
subject
, P
matches predicate
, and O matches the typed literal
corresponding to object
.StmtIterator listLiteralStatements(Resource subject, Property predicate, int object)
subject
, P
matches predicate
, and O matches the typed literal
corresponding to object
.StmtIterator listLiteralStatements(Resource subject, Property predicate, float object)
subject
, P
matches predicate
, and O matches the typed literal
corresponding to object
.StmtIterator listLiteralStatements(Resource subject, Property predicate, double object)
subject
, P
matches predicate
, and O matches the typed literal
corresponding to object
.StmtIterator listStatements(Resource subject, Property predicate, String object)
Return an iterator over all the statements in a model
that match a pattern. The statements selected are those
whose subject matches the subject
argument,
whose predicate matches the predicate
argument
and whose object matchesthe object
argument.
subject
- The subject soughtpredicate
- The predicate soughtobject
- The value soughtStmtIterator listStatements(Resource subject, Property predicate, String object, String lang)
Return an iterator over all the statements in a model
that match a pattern. The statements selected are those
whose subject matches the subject
argument,
whose predicate matches the predicate
argument
and whose object matchesthe object
argument.
If an argument is null
it matches anything.
subject
- The subject soughtpredicate
- The predicate soughtobject
- The value soughtlang
- The lang code ofthe string.ResIterator listResourcesWithProperty(Property p, boolean o)
ResIterator listResourcesWithProperty(Property p, long o)
ResIterator listResourcesWithProperty(Property p, char o)
ResIterator listResourcesWithProperty(Property p, float o)
ResIterator listResourcesWithProperty(Property p, double o)
ResIterator listResourcesWithProperty(Property p, Object o)
ResIterator listSubjectsWithProperty(Property p, String o)
p
- The predicate sought.o
- The property value sought.ResIterator listSubjectsWithProperty(Property p, String o, String l)
p
- The predicate sought.o
- The property value sought.l
- the language associated with the objectboolean containsLiteral(Resource s, Property p, boolean o)
boolean containsLiteral(Resource s, Property p, long o)
boolean containsLiteral(Resource s, Property p, int o)
boolean containsLiteral(Resource s, Property p, char o)
boolean containsLiteral(Resource s, Property p, float o)
boolean containsLiteral(Resource s, Property p, double o)
boolean containsLiteral(Resource s, Property p, Object o)
boolean contains(Resource s, Property p, String o)
s
- The subject of the statment tested.p
- The predicate of the statement tested.o
- The object of the statement tested.boolean contains(Resource s, Property p, String o, String l)
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 objectLicenced under the Apache License, Version 2.0