Class ModelCom
- java.lang.Object
-
- org.apache.jena.enhanced.EnhGraph
-
- org.apache.jena.rdf.model.impl.ModelCom
-
- All Implemented Interfaces:
Model
,ModelCon
,ModelGraphInterface
,RDFReaderF
,RDFWriterF
,Lock
,PrefixMapping
- Direct Known Subclasses:
InfModelImpl
,MonitorModel
,OntModelImpl
public class ModelCom extends EnhGraph implements Model, PrefixMapping, Lock
Common methods for model implementations.This class implements common methods, mainly convenience methods, for model implementations. It is intended use is as a base class from which model implementations can be derived.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.jena.shared.PrefixMapping
PrefixMapping.Factory, PrefixMapping.IllegalPrefixException, PrefixMapping.JenaLockedException
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Model
abort()
Abort the current transaction and abandon any changes in progress.GraphListener
adapt(ModelChangedListener L)
Answer a GraphListener that, when fed graph-level update events, fires the corresponding model-level event handlers inL
.Model
add(java.util.List<Statement> statements)
Add all the statements to the model by converting the list to an array of Statement and removing that.Model
add(Model m)
Add all the statements in another model to this model, including the reified statements.Model
add(Resource s, Property p, java.lang.String o)
add a statement to this model.Model
add(Resource s, Property p, java.lang.String o, boolean wellFormed)
add a statement to this model.Model
add(Resource s, Property p, java.lang.String o, java.lang.String l)
add a statement to this model.Model
add(Resource s, Property p, java.lang.String o, java.lang.String lang, boolean wellFormed)
Model
add(Resource s, Property p, java.lang.String lex, RDFDatatype datatype)
add a statement to this model.Model
add(Resource s, Property p, RDFNode o)
add a statement to this model.Model
add(Statement s)
add a Statement to this Model by adding its SPO components.Model
add(Statement[] statements)
Add all the statements to the model by converting them to an array of corresponding triples and removing those from the underlying graph.Model
add(StmtIterator iter)
Add all the statements returned by an iterator 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, long o)
Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.Model
addLiteral(Resource s, Property p, java.lang.Object o)
Deprecated.Model
addLiteral(Resource s, Property p, Literal o)
add a statement to this model.static void
addNamespaces(Model m, java.util.Map<java.lang.String,java.util.Set<java.lang.String>> ns)
Service method to update the namespaces of a Model given the mappings from prefix names to sets of URIs.Model
asModel(Graph g)
static Node
asNode(RDFNode x)
RDFNode
asRDFNode(Node n)
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.Statement
asStatement(Triple t)
Answer a Statement in this Model which encodes the given Triple.StmtIterator
asStatements(java.util.Iterator<Triple> it)
java.util.List<Statement>
asStatements(java.util.List<Triple> triples)
Statement[]
asStatements(Triple[] triples)
Model
begin()
Begin a new transaction.<T> T
calculateInTxn(java.util.function.Supplier<T> action)
Execute the supplieraction
within a transaction.Model
clearNsPrefixMap()
Clear this prefix mapping of all mappingsvoid
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, java.lang.String o)
Determine if a statement is present in this model.boolean
contains(Resource s, Property p, java.lang.String o, java.lang.String l)
Determine if a statement is present in this model.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
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, java.lang.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
containsResource(RDFNode r)
determine if the RDFNode r appears in any statement of this model.Alt
createAlt()
Create a new anonymous alt.Alt
createAlt(java.lang.String uri)
Create a new alt.Bag
createBag()
Create a new anonymous bag.Bag
createBag(java.lang.String uri)
Create a new bag.RDFList
createList()
Answer a (the) new empty list Until this is made the object or subject in the model, it will not appear in a written form.RDFList
createList(java.util.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 RDF nodes from the given array, in orderLiteral
createLiteral(java.lang.String v)
create a literal from a String value.Literal
createLiteral(java.lang.String v, boolean wellFormed)
Create a literal from a String value.Literal
createLiteral(java.lang.String v, java.lang.String l)
Create an untyped literal from a String value with a specified language.Literal
createLiteral(java.lang.String v, java.lang.String l, boolean wellFormed)
Statement
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.Statement
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.Statement
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.Statement
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.Statement
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.Statement
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.Statement
createLiteralStatement(Resource r, Property p, java.lang.Object o)
Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.Property
createProperty(java.lang.String uri)
Create a property.Property
createProperty(java.lang.String nameSpace, java.lang.String localName)
Create a property with a given URI composed from a namespace part and a localname part by concatenating the strings.ReifiedStatement
createReifiedStatement(java.lang.String uri, Statement s)
answer a ReifiedStatement that encodes _s_, belongs to this Model, and is a Resource with that _uri_.ReifiedStatement
createReifiedStatement(Statement s)
create a ReifiedStatement that encodes _s_ and belongs to this Model.Resource
createResource()
Create a new anonymous resource whose model is this model.Resource
createResource(java.lang.String uri)
Create a new resource associated with this model.Resource
createResource(java.lang.String uri, Resource type)
Create a new resource with a given type.Resource
createResource(java.lang.String uri, ResourceF f)
Deprecated.Resource
createResource(AnonId id)
Create a blank node resource with a specified identifier.Resource
createResource(Resource type)
Create a new anonymous resource with a given type.Resource
createResource(ResourceF f)
Deprecated.Resource
createResource(Statement statement)
Create a resource that represents a statement.Seq
createSeq()
Create a new anonymous seq.Seq
createSeq(java.lang.String uri)
Create a new seq.Statement
createStatement(Resource r, Property p, java.lang.String o)
Create a Statement instance.Statement
createStatement(Resource r, Property p, java.lang.String o, boolean wellFormed)
Create a Statement instance.Statement
createStatement(Resource r, Property p, java.lang.String o, java.lang.String l)
Create a Statement instance.Statement
createStatement(Resource r, Property p, java.lang.String o, java.lang.String l, boolean wellFormed)
Create a Statement instance.Statement
createStatement(Resource r, Property p, RDFNode o)
create a Statement from the given r, p, and o.Literal
createTypedLiteral(boolean v)
create a type literal from a boolean value.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 a long integer value.Literal
createTypedLiteral(java.lang.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(java.lang.Object value, java.lang.String typeURI)
Build a typed literal from its value form.Literal
createTypedLiteral(java.lang.Object value, RDFDatatype dtype)
Build a typed literal from its value form.Literal
createTypedLiteral(java.lang.String v)
create a typed literal from a String value.Literal
createTypedLiteral(java.lang.String lex, java.lang.String typeURI)
Build a typed literal from its lexical form.Literal
createTypedLiteral(java.lang.String lex, RDFDatatype dtype)
Build a typed literal from its lexical form.Literal
createTypedLiteral(java.util.Calendar cal)
Create a typed literal xsd:dateTime from a Calendar object.Model
difference(Model model)
Create a new, independant, model containing all the statements in this model which are not in another.void
enterCriticalSection(boolean requestReadLock)
Enter a critical section.void
executeInTxn(java.lang.Runnable action)
Execute the runnableaction
within a transaction.java.lang.String
expandPrefix(java.lang.String prefixed)
Expand the uri using the prefix mappings if possible.ExtendedIterator<Triple>
findTriplesFrom(Selector s)
Answer an [extended] iterator which returns the triples in this graph which are selected by the (S, P, O) triple in the selector, ignoring any special tests it may do.Alt
getAlt(java.lang.String uri)
Return an Alt instance in this model.Alt
getAlt(Resource r)
Return an Alt instance based on a given resource.Resource
getAnyReifiedStatement(Statement s)
get any reification of the given statement in this model; make one if necessary.Bag
getBag(java.lang.String uri)
Return a Bag instance in this model.Bag
getBag(Resource r)
Return a bag instance based on a given resource.Graph
getGraph()
Answer the Graph which this Model is presenting.RDFList
getList(java.lang.String uri)
Return a RDF List instance in this model.RDFList
getList(Resource r)
Return a RDF List based on a given resource.Lock
getLock()
Get the model lock for this model.Lock
getModelLock()
java.util.Map<java.lang.String,java.lang.String>
getNsPrefixMap()
Return a copy of the internal mapping from names to URI strings.java.lang.String
getNsPrefixURI(java.lang.String prefix)
Get the URI bound to a specific prefix, null if there isn't one.java.lang.String
getNsURIPrefix(java.lang.String uri)
Answer the prefix for the given URI, or null if there isn't one.Property
getProperty(java.lang.String uri)
Return a Property instance in this model.Property
getProperty(java.lang.String nameSpace, java.lang.String localName)
Return a Property instance with the given URI in this model.Statement
getProperty(Resource s, Property p)
Answer a statement (s, p, ?O) from this model.Statement
getProperty(Resource s, Property p, java.lang.String lang)
Answer a statement (s, p, ?O) from this model.RDFNode
getRDFNode(Node n)
RDFReaderI
getReader()
return an RDFReader instance for the default serialization language.RDFReaderI
getReader(java.lang.String lang)
return an RDFReader instance for the specified serialization language.Statement
getRequiredProperty(Resource s, Property p)
Return a statement with given subject and property.Statement
getRequiredProperty(Resource s, Property p, java.lang.String lang)
Return a statement with given subject and property.Resource
getResource(java.lang.String uri)
Return a Resource instance with the given URI in this model.Resource
getResource(java.lang.String uri, ResourceF f)
Deprecated.Seq
getSeq(java.lang.String uri)
Return a Seq instance in this model.Seq
getSeq(Resource r)
Return a Seq instance based on a given resource.RDFWriterI
getWriter()
Get the model's writer after priming it with the model's namespace prefixes.RDFWriterI
getWriter(java.lang.String lang)
Get the model's writer after priming it with the model's namespace prefixes.boolean
hasNoMappings()
Return whether the prefix mapping has any defined prefixes.boolean
independent()
Determine whether this model is independent.static Model
intersect(Model smaller, Model larger)
Answer a Model that is the intersection of the two argument models.Model
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
isIsomorphicWith(Model m)
Answer whether or not these two graphs are isomorphic.boolean
isReified(Statement s)
Determine if this Statement has been reified in this Model.void
leaveCriticalSection()
Leave a critical section.StmtIterator
listBySubject(Container cont)
StmtIterator
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
.StmtIterator
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
.StmtIterator
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
.StmtIterator
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
.StmtIterator
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
.StmtIterator
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
.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 modelRSIterator
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 propertyp
.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, java.lang.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.ResIterator
listResourcesWithProperty(Property p, RDFNode o)
Answer an iterator [with no duplicates] over all the resources in this model that have propertyp
with valueo
.StmtIterator
listStatements()
List all statements.StmtIterator
listStatements(Resource S, Property P, java.lang.String O)
Find all the statements matching a pattern.StmtIterator
listStatements(Resource S, Property P, java.lang.String O, java.lang.String L)
Find all the statements matching a pattern.StmtIterator
listStatements(Resource S, Property P, RDFNode O)
Find all the statements matching a pattern.StmtIterator
listStatements(Selector selector)
List the statements matching a selector.ResIterator
listSubjects()
List all resources which are subjects of statements.ResIterator
listSubjectsWithProperty(Property p)
An alias forlistResourcesWithProperty(Property)
, retained for backward compatibility.ResIterator
listSubjectsWithProperty(Property p, java.lang.String o)
lists all subjects with a given property and property value.ResIterator
listSubjectsWithProperty(Property p, java.lang.String o, java.lang.String l)
lists all subjects with a given property and property value.ResIterator
listSubjectsWithProperty(Property p, RDFNode o)
An alias forlistResourcesWithProperty
, retained for backward compatibility.PrefixMapping
lock()
Lock the PrefixMapping so that changes can no longer be made to it.Model
notifyEvent(java.lang.Object e)
Notify any listeners that the event e has occurred.int
numPrefixes()
Return the number of defined prefixes.java.lang.String
qnameFor(java.lang.String uri)
Answer a qname with the expansion of the given uri, or null if no such qname can be constructed using the mapping's prefixes.Model
query(Selector selector)
Create a new model containing the statements matching a query.Model
read(java.io.InputStream reader, java.lang.String base)
Add statements from a document.Model
read(java.io.InputStream reader, java.lang.String base, java.lang.String lang)
Add RDF statements represented in languagelang
to the model.Model
read(java.io.Reader reader, java.lang.String base)
Using this method is often a mistake.Model
read(java.io.Reader reader, java.lang.String base, java.lang.String lang)
Using this method is often a mistake.Model
read(java.lang.String url)
Add the RDF statements from a document.Model
read(java.lang.String url, java.lang.String lang)
Add statements from a serializion in languagelang
to the model.Model
read(java.lang.String url, java.lang.String base, java.lang.String lang)
Read into this model the RDF aturl
, usingbaseURI
as the base URI if it is non-null.Model
register(ModelChangedListener listener)
Register the listener with this model by registering its GraphListener adaption with the underlying Graph.java.lang.String
reifiedToString()
Model
remove(java.util.List<Statement> statements)
Remove all the Statements from the model by converting the List to a List(Statement) and removing that.Model
remove(Model m)
Remove all the Statements in a given model, including reified statementsModel
remove(Resource s, Property p, RDFNode o)
remove the statement(s, p, o)
from this model and answer this model.Model
remove(Statement s)
Removes a statement.Model
remove(Statement[] statements)
remove all the Statements from the model by converting them to triples and removing those triples from the underlying graph.Model
remove(StmtIterator iter)
Remove all the Statements returned by an iterator.Model
removeAll()
Remove all the statements from this model.Model
removeAll(Resource s, Property p, RDFNode o)
Remove all the statements matching (s, p, o) from this model.void
removeAllReifications(Statement s)
remove any ReifiedStatements reifying the given statementModel
removeNsPrefix(java.lang.String prefix)
Remove any existing maplet with the given prefix name and answer this mapping.void
removeReification(ReifiedStatement rs)
Remove a particular reificiation.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.Model
setNsPrefix(java.lang.String prefix, java.lang.String uri)
Specify the prefix name for a URI prefix string.Model
setNsPrefixes(java.util.Map<java.lang.String,java.lang.String> map)
Copies the prefix mapping from other into this.Model
setNsPrefixes(PrefixMapping pm)
Copies the prefixes from other into this.java.lang.String
shortForm(java.lang.String uri)
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 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.java.lang.String
toString()
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 the listener from this model by unregistering its GraphListener adaption from the underlying Graph.Model
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.Resource
wrapAsResource(Node n)
Model
write(java.io.OutputStream writer)
Write a serialization of this model as an XML document.Model
write(java.io.OutputStream writer, java.lang.String lang)
Write a serialized representation of this model in a specified language.Model
write(java.io.OutputStream writer, java.lang.String lang, java.lang.String base)
Write a serialized representation of a model in a specified language.Model
write(java.io.Writer writer)
Write the model as an XML document.Model
write(java.io.Writer writer, java.lang.String lang)
Write a serialized representation of a model in a specified language.Model
write(java.io.Writer writer, java.lang.String lang, java.lang.String base)
Write a serialized representation of a model in a specified language.-
Methods inherited from class org.apache.jena.enhanced.EnhGraph
asGraph, equals, getNodeAs, hashCode, isIsomorphicWith, setNodeCache
-
-
-
-
Constructor Detail
-
ModelCom
public ModelCom(Graph base)
make a model based on the specified graph
-
ModelCom
public ModelCom(Graph base, Personality<RDFNode> personality)
-
-
Method Detail
-
getGraph
public Graph getGraph()
Description copied from interface:ModelGraphInterface
Answer the Graph which this Model is presenting.- Specified by:
getGraph
in interfaceModelGraphInterface
-
asRDFNode
public RDFNode asRDFNode(Node n)
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
public Resource wrapAsResource(Node n)
- Specified by:
wrapAsResource
in interfaceModelGraphInterface
-
getResource
@Deprecated public Resource getResource(java.lang.String uri, ResourceF f)
Deprecated.Description copied from interface:ModelCon
Return a Resource instance in this model.Subsequent operations on the returned object may modify this model.
The resource is assumed to already exist in the model. If it does not,
createResource
should be used instead.- Specified by:
getResource
in interfaceModelCon
- Parameters:
uri
- the URI of the resourcef
- the factory object- Returns:
- a resource instance created by the factory provided
-
addLiteral
public Model addLiteral(Resource s, Property p, boolean o)
Description copied from interface:ModelCon
Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.- Specified by:
addLiteral
in interfaceModelCon
-
addLiteral
public Model addLiteral(Resource s, Property p, long o)
Description copied from interface:ModelCon
Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.- Specified by:
addLiteral
in interfaceModelCon
-
addLiteral
public Model addLiteral(Resource s, Property p, int o)
Description copied from interface:ModelCon
Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.- Specified by:
addLiteral
in interfaceModelCon
-
addLiteral
public Model addLiteral(Resource s, Property p, char o)
Description copied from interface:ModelCon
Add the statement (s, p, createTypedLiteral( o )) to this model and answer this model.- Specified by:
addLiteral
in interfaceModelCon
-
addLiteral
public Model addLiteral(Resource s, Property p, float o)
Description copied from interface:ModelCon
Add the statement (s, p, o') to the model, where o' is the typed literal corresponding to o. Answer this model.- Specified by:
addLiteral
in interfaceModelCon
-
addLiteral
public Model addLiteral(Resource s, Property p, double o)
Description copied from interface:ModelCon
Add the statement (s, p, o') to the model, where o' is the typed literal corresponding to o. Answer this model.- Specified by:
addLiteral
in interfaceModelCon
-
add
public Model add(Resource s, Property p, java.lang.String o)
Description copied from interface:ModelCon
add a statement to this model.
-
add
public Model add(Resource s, Property p, java.lang.String o, boolean wellFormed)
Description copied from interface:ModelCon
add a statement to this model.
-
add
public Model add(Resource s, Property p, java.lang.String o, java.lang.String lang, boolean wellFormed)
-
add
public Model add(Resource s, Property p, java.lang.String lex, RDFDatatype datatype)
Description copied from interface:ModelCon
add a statement to this model.
-
add
public Model add(Resource s, Property p, java.lang.String o, java.lang.String l)
Description copied from interface:ModelCon
add a statement to this model.
-
addLiteral
@Deprecated public Model addLiteral(Resource s, Property p, java.lang.Object o)
Deprecated.Description copied from interface:ModelCon
add a statement to this model. Applications should use typed literals whereever possible.- Specified by:
addLiteral
in 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
-
addLiteral
public Model addLiteral(Resource s, Property p, Literal o)
Description copied from interface:ModelCon
add a statement to this model.- Specified by:
addLiteral
in 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
public Model add(StmtIterator iter)
Description copied from interface:Model
Add all the statements returned by an iterator to this model.
-
add
public Model add(Model m)
Description copied from interface:Model
Add all the statements in another model to this model, including the reified statements.
-
getReader
public RDFReaderI getReader()
Description copied from interface:RDFReaderF
return an RDFReader instance for the default serialization language.- Specified by:
getReader
in interfaceRDFReaderF
- Returns:
- an RDFReader instance for the default serialization language.
-
getReader
public RDFReaderI getReader(java.lang.String lang)
Description copied from interface:RDFReaderF
return an RDFReader instance for the specified serialization language.- Specified by:
getReader
in interfaceRDFReaderF
- Parameters:
lang
- the serialization language -null
selects the default- Returns:
- the RDFWriter instance
-
read
public Model read(java.lang.String url)
Description copied from interface:Model
Add the RDF statements from a document. Uses content negotiation to request appropriate mime types. If the content type is not found, it may guess from the URL.See
Model
for a description of how to traverse a firewall.See "Reading and Writing RDF in Apache Jena" for more information about determining the syntax.
-
read
public Model read(java.io.Reader reader, java.lang.String base)
Description copied from interface:Model
Using this method is often a mistake. Add statements from an RDF/XML serialization. It is generally better to use an InputStream if possible, otherwise there is a danger of a mismatch between the character encoding of say the FileReader and the character encoding of the data in the file. It is better to explicitly set the serialization format. 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
public Model read(java.io.InputStream reader, java.lang.String base)
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
public Model read(java.lang.String url, java.lang.String lang)
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
public Model read(java.lang.String url, java.lang.String base, java.lang.String lang)
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
public Model read(java.io.Reader reader, java.lang.String base, java.lang.String lang)
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
public Model read(java.io.InputStream reader, java.lang.String base, java.lang.String lang)
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") and "N3".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
public RDFWriterI getWriter()
Get the model's writer after priming it with the model's namespace prefixes.- Specified by:
getWriter
in interfaceRDFWriterF
- Returns:
- an RDFWriter instance for the default serialization language.
-
getWriter
public RDFWriterI getWriter(java.lang.String lang)
Get the model's writer after priming it with the model's namespace prefixes.- Specified by:
getWriter
in interfaceRDFWriterF
- Parameters:
lang
- the serialization language -null
selects the default- Returns:
- the RDFWriter instance
-
write
public Model write(java.io.Writer writer)
Description copied from interface:Model
Write the model as an XML document. It is often better to use an OutputStream rather than a Writer, since this will avoid character encoding errors.
-
write
public Model write(java.io.Writer writer, java.lang.String lang)
Description copied from interface:Model
Write a serialized representation of a model in a specified language. It is often better to use an OutputStream rather than a Writer, since this will avoid character encoding errors.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value, represented bynull
is "RDF/XML".
-
write
public Model write(java.io.Writer writer, java.lang.String lang, java.lang.String base)
Description copied from interface:Model
Write a serialized representation of a model in a specified language. It is often better to use an OutputStream rather than a Writer, since this will avoid character encoding errors.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value, represented bynull
, is "RDF/XML".
-
write
public Model write(java.io.OutputStream writer)
Description copied from interface:Model
Write a serialization of this model as an XML document.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value is represented bynull
is "RDF/XML".
-
write
public Model write(java.io.OutputStream writer, java.lang.String lang)
Description copied from interface:Model
Write a serialized representation of this model in a specified language.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value, represented bynull
, is "RDF/XML".
-
write
public Model write(java.io.OutputStream writer, java.lang.String lang, java.lang.String base)
Description copied from interface:Model
Write a serialized representation of a model in a specified language.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value, represented 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
public Model remove(Statement s)
Description copied from interface:Model
Removes a statement.The statement with the same subject, predicate and object as that supplied will be removed from the model.
-
remove
public Model remove(Resource s, Property p, RDFNode o)
Description copied from interface:ModelCon
remove the statement(s, p, o)
from this model and answer this model. None ofs, p, o
are permitted to benull
: for wildcard removal, seeremoveAll
.
-
remove
public Model remove(StmtIterator iter)
Description copied from interface:ModelCon
Remove all the Statements returned by an iterator.
-
remove
public Model remove(Model m)
Description copied from interface:ModelCon
Remove all the Statements in a given model, including reified statements
-
removeAll
public Model removeAll()
Description copied from interface:Model
Remove all the statements from this model.
-
removeAll
public Model removeAll(Resource s, Property p, RDFNode o)
Description copied from interface:Model
Remove all the statements matching (s, p, o) from this model.
-
containsLiteral
public boolean containsLiteral(Resource s, Property p, boolean o)
Description copied from interface:ModelCon
Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.- Specified by:
containsLiteral
in interfaceModelCon
-
containsLiteral
public boolean containsLiteral(Resource s, Property p, long o)
Description copied from interface:ModelCon
Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.- Specified by:
containsLiteral
in interfaceModelCon
-
containsLiteral
public boolean containsLiteral(Resource s, Property p, int o)
Description copied from interface:ModelCon
Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.- Specified by:
containsLiteral
in interfaceModelCon
-
containsLiteral
public boolean containsLiteral(Resource s, Property p, char o)
Description copied from interface:ModelCon
Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.- Specified by:
containsLiteral
in interfaceModelCon
-
containsLiteral
public boolean containsLiteral(Resource s, Property p, float o)
Description copied from interface:ModelCon
Answer true iff this model contains (s, p, o') where o' is the typed literal corresponding to o.- Specified by:
containsLiteral
in interfaceModelCon
-
containsLiteral
public boolean containsLiteral(Resource s, Property p, double o)
Description copied from interface:ModelCon
Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.- Specified by:
containsLiteral
in interfaceModelCon
-
contains
public boolean contains(Resource s, Property p, java.lang.String o)
Description copied from interface:ModelCon
Determine if a statement is present in this model.
-
contains
public boolean contains(Resource s, Property p, java.lang.String o, java.lang.String l)
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
public boolean containsLiteral(Resource s, Property p, java.lang.Object o)
Description copied from interface:ModelCon
Answer true iff this model contains the statement (s, p, o') where o' is the typed literal corresponding to the value o.- Specified by:
containsLiteral
in interfaceModelCon
-
containsAny
public boolean containsAny(Model model)
Description copied from interface:Model
Determine if any of the statements in a model are also contained in this model.- Specified by:
containsAny
in 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
public boolean containsAll(Model model)
Description copied from interface:Model
Determine if all of the statements in a model are also contained in this model.- Specified by:
containsAll
in 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
public boolean containsAny(StmtIterator iter)
Description copied from interface:Model
Determine if any of the statements returned by an iterator are contained in this model.- Specified by:
containsAny
in 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
public boolean containsAll(StmtIterator iter)
Description copied from interface:Model
Determine if all of the statements returned by an iterator are contained in this model.- Specified by:
containsAll
in 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
public StmtIterator listStatements(Resource S, Property P, RDFNode O)
Description copied from interface:Model
Find all the statements matching a pattern.Return an iterator over all the statements in a model that match a pattern. The statements selected are those whose subject matches the
subject
argument, whose predicate matches 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
public StmtIterator listStatements(Resource S, Property P, java.lang.String O)
Description copied from interface:ModelCon
Find all the statements matching a pattern.Return an iterator over all the statements in a model that match a pattern. The statements selected are those whose subject matches the
subject
argument, whose predicate matches 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
public StmtIterator listStatements(Resource S, Property P, java.lang.String O, java.lang.String L)
Description copied from interface:ModelCon
Find all the statements matching a pattern.Return an iterator over all the statements in a model that match a pattern. The statements selected are those whose subject matches the
subject
argument, whose predicate matches 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
public StmtIterator listLiteralStatements(Resource S, Property P, boolean O)
Description copied from interface:ModelCon
Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.- Specified by:
listLiteralStatements
in interfaceModelCon
-
listLiteralStatements
public StmtIterator listLiteralStatements(Resource S, Property P, long O)
Description copied from interface:ModelCon
Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.- Specified by:
listLiteralStatements
in interfaceModelCon
-
listLiteralStatements
public StmtIterator listLiteralStatements(Resource S, Property P, int O)
Description copied from interface:ModelCon
Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.- Specified by:
listLiteralStatements
in interfaceModelCon
-
listLiteralStatements
public StmtIterator listLiteralStatements(Resource S, Property P, char O)
Description copied from interface:ModelCon
Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.- Specified by:
listLiteralStatements
in interfaceModelCon
-
listLiteralStatements
public StmtIterator listLiteralStatements(Resource S, Property P, float O)
Description copied from interface:ModelCon
Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.- Specified by:
listLiteralStatements
in interfaceModelCon
-
listLiteralStatements
public StmtIterator listLiteralStatements(Resource S, Property P, double O)
Description copied from interface:ModelCon
Answer a statement iterator that will iterate over all the statements (S, P, O) in this model where S matchessubject
, P matchespredicate
, and O matches the typed literal corresponding toobject
.- Specified by:
listLiteralStatements
in interfaceModelCon
-
listResourcesWithProperty
public ResIterator listResourcesWithProperty(Property p, boolean o)
Description copied from interface:ModelCon
Answer an iterator [without duplicates] over all the resources in this model which have value o' for property p, where o' is the typed literal corresponding to o.- Specified by:
listResourcesWithProperty
in interfaceModelCon
-
listResourcesWithProperty
public ResIterator listResourcesWithProperty(Property p, char o)
Description copied from interface:ModelCon
Answer an iterator [without duplicates] over all the resources in this model which have value o' for property p, where o' is the typed literal corresponding to o.- Specified by:
listResourcesWithProperty
in interfaceModelCon
-
listResourcesWithProperty
public ResIterator listResourcesWithProperty(Property p, long o)
Description copied from interface:ModelCon
Answer an iterator [without duplicates] over all the resources in this model which have value o' for property p, where o' is the typed literal corresponding to o.- Specified by:
listResourcesWithProperty
in interfaceModelCon
-
listResourcesWithProperty
public ResIterator listResourcesWithProperty(Property p, float o)
Description copied from interface:ModelCon
Answer an iterator [without duplicates] over all the resources in this model which have value o' for property p, where o' is the typed literal corresponding to o.- Specified by:
listResourcesWithProperty
in interfaceModelCon
-
listResourcesWithProperty
public ResIterator listResourcesWithProperty(Property p, double o)
Description copied from interface:ModelCon
Answer an iterator [without duplicates] over all the resources in this model which have value o' for property p, where o' is the typed literal corresponding to o.- Specified by:
listResourcesWithProperty
in interfaceModelCon
-
listResourcesWithProperty
public ResIterator listResourcesWithProperty(Property p, java.lang.Object o)
Description copied from interface:ModelCon
Answer an iterator [without duplicates] over all the resources in this model which have value o' for property p, where o' is the typed literal corresponding to o.- Specified by:
listResourcesWithProperty
in interfaceModelCon
-
listSubjectsWithProperty
public ResIterator listSubjectsWithProperty(Property p, RDFNode o)
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
public ResIterator listSubjectsWithProperty(Property p, java.lang.String o)
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
public ResIterator listSubjectsWithProperty(Property p, java.lang.String o, java.lang.String l)
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
public Resource createResource(Resource type)
Description copied from interface:ModelCon
Create a new anonymous resource with a given type.Subsequent operations on the returned resource may modify this model.
The resource is created and an rdf:type property added to the model to specify its type.
- Specified by:
createResource
in interfaceModelCon
- Parameters:
type
- the type of the resource to be created.- Returns:
- a new anonymous resource linked to this model.
-
createResource
public Resource createResource(java.lang.String uri, Resource type)
Description copied from interface:ModelCon
Create a new resource with a given type.Subsequent operations on the returned resource may modify this model.
The resource is created and an rdf:type property added to the model to specify its type.
- Specified by:
createResource
in 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
@Deprecated public Resource createResource(ResourceF f)
Deprecated.Description copied from interface:ModelCon
Create a new anonymous resource using the supplied factory.Subsequent operations on the returned resource may modify this model.
- Specified by:
createResource
in interfaceModelCon
- Parameters:
f
- A factory object to create the returned object. .- Returns:
- a new anonymous resource linked to this model.
-
createResource
public Resource createResource(AnonId id)
Description copied from interface:Model
Create a blank node resource with a specified identifier. The resulting bnode will be equal to any other bnode with the same AnonId (even if they are in separate models - be warned). The intended use for this method is to allow bnode round-tripping between Jena models and other representations.This method may return an existing bnode with the correct AnonId and model, or it may construct a fresh one, as it sees fit.
Operations on the result may modify this model
- Specified by:
createResource
in interfaceModel
- Parameters:
id
- the identifier to use for this blank node- Returns:
- a blank node with that identifier
-
createResource
public Resource createResource(Statement statement)
Description copied from interface:Model
Create a resource that represents a statement. This is in support of RDF-star.- Specified by:
createResource
in interfaceModel
- Returns:
- a new resource linked to this model.
-
createResource
@Deprecated public Resource createResource(java.lang.String uri, ResourceF f)
Deprecated.Description copied from interface:ModelCon
Create a new resource using the supplied factory.Subsequent operations on the returned resource may modify this model.
- Specified by:
createResource
in interfaceModelCon
- Parameters:
uri
- the URI of the resourcef
- A factory to create the returned object. .- Returns:
- a new resource linked to this model.
-
createTypedLiteral
public Literal createTypedLiteral(boolean v)
create a type literal from a boolean value.The value is converted to a string using its
toString
method.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createTypedLiteral
public Literal createTypedLiteral(int v)
create a typed literal from an integer value.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createTypedLiteral
public Literal createTypedLiteral(long v)
create a typed literal from a long integer value.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createTypedLiteral
public Literal createTypedLiteral(char v)
create a typed literal from a char value.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createTypedLiteral
public Literal createTypedLiteral(float v)
create a typed literal from a float value.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createTypedLiteral
public Literal createTypedLiteral(double v)
create a typed literal from a double value.- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
v
- the value of the literal- Returns:
- a new literal representing the value v
-
createTypedLiteral
public Literal createTypedLiteral(java.lang.String v)
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
public Literal createTypedLiteral(java.util.Calendar cal)
Create a typed literal xsd:dateTime from a Calendar object.- Specified by:
createTypedLiteral
in interfaceModelCon
-
createTypedLiteral
public Literal createTypedLiteral(java.lang.String lex, RDFDatatype dtype) throws DatatypeFormatException
Build a typed literal from its lexical form. The lexical form will be parsed now and the value stored. If the form is not legal this will throw an exception.- Specified by:
createTypedLiteral
in 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
public Literal createTypedLiteral(java.lang.Object value, RDFDatatype dtype)
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
public Literal createTypedLiteral(java.lang.String lex, java.lang.String typeURI)
Build a typed literal from its lexical form. The lexical form will be parsed now and the value stored. If the form is not legal this will throw an exception.- Specified by:
createTypedLiteral
in 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
public Literal createTypedLiteral(java.lang.Object value, java.lang.String typeURI)
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
public Literal createTypedLiteral(java.lang.Object value)
Build a typed literal label from its value form using whatever datatype is currently registered as the the default representation for this java class. No language tag is supplied.- Specified by:
createTypedLiteral
in interfaceModel
- Specified by:
createTypedLiteral
in interfaceModelCon
- Parameters:
value
- the literal value to encapsulate- Returns:
- a new literal representing the value v
-
createLiteral
public Literal createLiteral(java.lang.String v)
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
public Literal createLiteral(java.lang.String v, java.lang.String l)
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
-
createLiteral
public Literal createLiteral(java.lang.String v, boolean wellFormed)
Description copied from interface:Model
Create a literal from a String value. An existing literal of the right value may be returned, or a fresh one created. The use of the wellFormed flag is to create typed literals of type rdf:XMLLiteral, without error checking. This should only be use when the lexical form is known to already be in exclusive canonical XML.- Specified by:
createLiteral
in interfaceModel
- Parameters:
v
- the lexical form of the literalwellFormed
- true if the Literal is well formed XML, in the lexical space of rdf:XMLLiteral- Returns:
- a new literal
-
createLiteral
public Literal createLiteral(java.lang.String v, java.lang.String l, boolean wellFormed)
-
createLiteralStatement
public Statement createLiteralStatement(Resource r, Property p, boolean o)
Description copied from interface:ModelCon
Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.- Specified by:
createLiteralStatement
in interfaceModelCon
-
createLiteralStatement
public Statement createLiteralStatement(Resource r, Property p, long o)
Description copied from interface:ModelCon
Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.- Specified by:
createLiteralStatement
in interfaceModelCon
-
createLiteralStatement
public Statement createLiteralStatement(Resource r, Property p, int o)
Description copied from interface:ModelCon
Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.- Specified by:
createLiteralStatement
in interfaceModelCon
-
createLiteralStatement
public Statement createLiteralStatement(Resource r, Property p, char o)
Description copied from interface:ModelCon
Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.- Specified by:
createLiteralStatement
in interfaceModelCon
-
createLiteralStatement
public Statement createLiteralStatement(Resource r, Property p, float o)
Description copied from interface:ModelCon
Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.- Specified by:
createLiteralStatement
in interfaceModelCon
-
createLiteralStatement
public Statement createLiteralStatement(Resource r, Property p, double o)
Description copied from interface:ModelCon
Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.- Specified by:
createLiteralStatement
in interfaceModelCon
-
createStatement
public Statement createStatement(Resource r, Property p, java.lang.String o)
Description copied from interface:ModelCon
Create a Statement instance.Subsequent operations on the statement or any of its parts may modify this model.
Creating a statement does not add it to the set of statements in the model.
The Object o will be converted to a Literal.
- Specified by:
createStatement
in 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
public Statement createLiteralStatement(Resource r, Property p, java.lang.Object o)
Description copied from interface:ModelCon
Answer a new Statement object (s, p, o') where o' is the typed literal corresponding to o using createTypedLiteral.- Specified by:
createLiteralStatement
in interfaceModelCon
-
createStatement
public Statement createStatement(Resource r, Property p, java.lang.String o, boolean wellFormed)
Description copied from interface:ModelCon
Create a Statement instance.Subsequent operations on the statement or any of its parts may modify this model.
Creating a statement does not add it to the set of statements in the model.
The Object o will be converted to a Literal.
- Specified by:
createStatement
in interfaceModelCon
- Parameters:
r
- 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 XML- Returns:
- the new statement
-
createStatement
public Statement createStatement(Resource r, Property p, java.lang.String o, java.lang.String l)
Description copied from interface:ModelCon
Create a Statement instance.Subsequent operations on the statement or any of its parts may modify this model.
Creating a statement does not add it to the set of statements in the model.
The Object o will be converted to a Literal.
- Specified by:
createStatement
in 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
-
createStatement
public Statement createStatement(Resource r, Property p, java.lang.String o, java.lang.String l, boolean wellFormed)
Description copied from interface:ModelCon
Create a Statement instance.Subsequent operations on the statement or any of its parts may modify this model.
Creating a statement does not add it to the set of statements in the model.
The Object o will be converted to a Literal.
- Specified by:
createStatement
in 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 objectwellFormed
- true of the string is well formed XML- Returns:
- the new statement
-
createBag
public Bag createBag()
Description copied from interface:ModelCon
Create a new anonymous bag.Subsequent operations on the bag or any of its parts may modify this model.
A statement defining the type of the new bag is added to this model.
-
createAlt
public Alt createAlt()
Description copied from interface:ModelCon
Create a new anonymous alt.Subsequent operations on the alt or any of its parts may modify this model.
A statement defining the type of the new alt is added to this model.
-
createSeq
public Seq createSeq()
Description copied from interface:ModelCon
Create a new anonymous seq.Subsequent operations on the seq or any of its parts may modify this model.
A statement defining the type of the new seq is added to this model.
-
createList
public RDFList createList()
Answer a (the) new empty list Until this is made the object or subject in the model, it will not appear in a written form.- Specified by:
createList
in interfaceModel
- Returns:
- An RDF-encoded list of no elements (ie nil)
-
createList
public RDFList createList(java.util.Iterator<? extends RDFNode> members)
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
public RDFList createList(RDFNode... members)
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
public RDFNode getRDFNode(Node n)
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
public Resource getResource(java.lang.String uri)
Description copied from interface:Model
Return a Resource instance with the given URI in this model. This method behaves identically tocreateResource(String)
and exists as legacy: createResource is now capable of, and allowed to, reuse existing objects.Subsequent operations on the returned object may modify this model.
- Specified by:
getResource
in interfaceModel
- Parameters:
uri
- the URI of the resource- Returns:
- a resource instance
-
getProperty
public Property getProperty(java.lang.String uri)
Description copied from interface:ModelCon
Return a Property instance in this model.Subsequent operations on the returned property may modify this model.
The property is assumed to already exist in the model. If it does not,
createProperty
should be used instead.- Specified by:
getProperty
in interfaceModelCon
- Parameters:
uri
- the URI of the property- Returns:
- a property object
-
getProperty
public Property getProperty(java.lang.String nameSpace, java.lang.String localName)
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
public Seq getSeq(java.lang.String uri)
Description copied from interface:ModelCon
Return a Seq instance in this model.Subsequent operations on the returned sequence may modify this model.
The seq is assumed to already exist in the model. If it does not,
createSeq
should be used instead.
-
getSeq
public Seq getSeq(Resource r)
Description copied from interface:ModelCon
Return a Seq instance based on a given resource.This method enables an application to treat any resource as a Seq. It is in effect an unsafe downcast.
Subsequent operations on the returned Seq may modify this model.
The Seq is assumed to already exist in the model. If it does not,
createSeq
should be used instead.
-
getBag
public Bag getBag(java.lang.String uri)
Description copied from interface:ModelCon
Return a Bag instance in this model.Subsequent operations on the returned bag may modify this model.
The bag is assumed to already exist in the model. If it does not,
createBag
should be used instead.
-
getBag
public Bag getBag(Resource r)
Description copied from interface:ModelCon
Return a bag instance based on a given resource.This method enables an application to treat any resource as a bag. It is in effect an unsafe downcast.
Subsequent operations on the returned bag may modify this model.
The bag is assumed to already exist in the model. If it does not,
createBag
should be used instead.
-
getList
public RDFList getList(java.lang.String uri)
Description copied from interface:ModelCon
Return a RDF List instance in this model.Subsequent operations on the returned list may modify this model.
The list is assumed to already exist in the model. If it does not,
createList
should be used instead.
-
getList
public RDFList getList(Resource r)
Description copied from interface:ModelCon
Return a RDF List based on a given resource.This method enables an application to treat any resource as a list. It is in effect an unsafe downcast.
Subsequent operations on the returned list may modify this model.
The list is assumed to already exist in the model. If it does not,
createList
should be used instead.
-
getAlt
public Alt getAlt(java.lang.String uri)
Description copied from interface:ModelCon
Return an Alt instance in this model.Subsequent operations on the returned object may modify this model.
The alt is assumed to already exist in the model. If it does not,
createAlt
should be used instead.
-
getAlt
public Alt getAlt(Resource r)
Description copied from interface:ModelCon
Return an Alt instance based on a given resource.This method enables an application to treat any resource as an Alt. It is in effect an unsafe downcast.
Subsequent operations on the returned Alt may modify this model.
The Alt is assumed to already exist in the model. If it does not,
createAlt
should be used instead.
-
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 numberof 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
public NsIterator listNameSpaces()
Description copied from interface:Model
(You probably don't want this method; more likely you want the PrefixMapping methods that Model supports.) List the namespaces used by predicates and types in the model. This method is really intended for use by the RDF/XML writer, which needs to know these namespaces to generate correct and vaguely pretty XML.The namespaces returned are those of (a) every URI used as a property in the model and (b) those of every URI that appears as the object of an rdf:type statement.
Note that the notion of "namespace" used here is not that of an XML prefix-namespace, but just of the minimal legal left part of a URI (see Util.splitNamespace for details). If you want the RDF/XML (or N3) namespaces, treat the Model as a PrefixMapping.
- Specified by:
listNameSpaces
in interfaceModel
- Returns:
- an iterator over every predicate and type namespace
- See Also:
PrefixMapping
-
samePrefixMappingAs
public boolean samePrefixMappingAs(PrefixMapping other)
Description copied from interface:PrefixMapping
Answer true iff this prefix-mappings are equal, that is, map the same prefixes to the same URIs; same asthis.getNsPrefixMap().equals( other.getNsPrefixMap() )
except that it may avoid unnecessary Map creations.- Specified by:
samePrefixMappingAs
in interfacePrefixMapping
-
lock
public PrefixMapping lock()
Description copied from interface:PrefixMapping
Lock the PrefixMapping so that changes can no longer be made to it. Primarily intended to lock Standard against mutation.- Specified by:
lock
in interfacePrefixMapping
- Returns:
- this mapping, locked against changes
-
setNsPrefix
public Model setNsPrefix(java.lang.String prefix, java.lang.String uri)
Description copied from interface:PrefixMapping
Specify the prefix name for a URI prefix string. Any existing use of that prefix name is overwritten. The result is this same prefixMapping. (The earlier restriction that adding second prefix for the same URI caused the earlier binding to be deleted has been withdrawn.)A prefix name must be a valid NCName, or the empty string. The empty string is reserved to mean "the default namespace".
Need not check the RFC2396 validity of the URI. Bad URIs are either silently ignored or behave as if they were good. The earlier restriction that the URI should end with a non-NCName character has been removed.
Note, in particular, that the prefix mapping can only be used if it includes the URI up to any '#' character because '#' is not legal in the local part of an NCName.
- Specified by:
setNsPrefix
in 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
public Model removeNsPrefix(java.lang.String prefix)
Description copied from interface:PrefixMapping
Remove any existing maplet with the given prefix name and answer this mapping. If the prefix is the empty string, then this removes the default namespace. If the prefix is not a legal prefix string, or is not present in the mapping, nothing happens.The reverse URI-to-prefix mapping is updated, but if there are multiple prefixes for the removed URI it is unspecified which of them will be chosen.
- Specified by:
removeNsPrefix
in interfaceModel
- Specified by:
removeNsPrefix
in interfacePrefixMapping
- Parameters:
prefix
- the prefix string to remove- Returns:
- this PrefixMapping
-
clearNsPrefixMap
public Model clearNsPrefixMap()
Description copied from interface:PrefixMapping
Clear this prefix mapping of all mappings- Specified by:
clearNsPrefixMap
in interfaceModel
- Specified by:
clearNsPrefixMap
in interfacePrefixMapping
-
setNsPrefixes
public Model setNsPrefixes(PrefixMapping pm)
Description copied from interface:PrefixMapping
Copies the prefixes from other into this. Any existing binding of the same prefix is lost. The result is this same prefixMapping.- Specified by:
setNsPrefixes
in interfaceModel
- Specified by:
setNsPrefixes
in interfacePrefixMapping
- Parameters:
pm
- the PrefixMapping to add- Returns:
- this PrefixMapping
-
setNsPrefixes
public Model setNsPrefixes(java.util.Map<java.lang.String,java.lang.String> map)
Description copied from interface:PrefixMapping
Copies the prefix mapping from other into this. Illegal prefix mappings are detected. Existing binds of the same prefix are lost. The result is this same prefixMapping.- Specified by:
setNsPrefixes
in interfaceModel
- Specified by:
setNsPrefixes
in interfacePrefixMapping
- Parameters:
map
- the Map whose maplets are to be added- Returns:
- this PrefixMapping
-
withDefaultMappings
public Model withDefaultMappings(PrefixMapping other)
Description copied from interface:PrefixMapping
Update this PrefixMapping with the bindings inmap
, only adding those (p, u) pairs for which neither p nor u appears in this mapping. Answer this PrefixMapping.- Specified by:
withDefaultMappings
in interfaceModel
- Specified by:
withDefaultMappings
in interfacePrefixMapping
-
getNsPrefixURI
public java.lang.String getNsPrefixURI(java.lang.String prefix)
Description copied from interface:PrefixMapping
Get the URI bound to a specific prefix, null if there isn't one.- Specified by:
getNsPrefixURI
in interfacePrefixMapping
- Parameters:
prefix
- the prefix name to be looked up- Returns:
- the most recent URI bound to that prefix name, null if none
-
getNsURIPrefix
public java.lang.String getNsURIPrefix(java.lang.String uri)
Description copied from interface:PrefixMapping
Answer the prefix for the given URI, or null if there isn't one. If there is more than one, one of them will be picked. If possible, it will be the most recently added prefix. (The cases where it's not possible is when a binding has been removed.)- Specified by:
getNsURIPrefix
in 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
public java.util.Map<java.lang.String,java.lang.String> getNsPrefixMap()
Description copied from interface:PrefixMapping
Return a copy of the internal mapping from names to URI strings. Updating this copy will have no effect on the PrefixMap.- Specified by:
getNsPrefixMap
in interfacePrefixMapping
- Returns:
- a copy of the internal String -> String mapping
-
expandPrefix
public java.lang.String expandPrefix(java.lang.String prefixed)
Description copied from interface:PrefixMapping
Expand the uri using the prefix mappings if possible. If prefixed has the form Foo:Bar, and Foo is a prefix bound to FooURI, return FooURI+Bar. Otherwise return prefixed unchanged.- Specified by:
expandPrefix
in interfacePrefixMapping
- Parameters:
prefixed
- a QName or URI- Returns:
- the expanded string if possible, otherwise the original string
-
qnameFor
public java.lang.String qnameFor(java.lang.String uri)
Description copied from interface:PrefixMapping
Answer a qname with the expansion of the given uri, or null if no such qname can be constructed using the mapping's prefixes.- Specified by:
qnameFor
in interfacePrefixMapping
-
shortForm
public java.lang.String shortForm(java.lang.String uri)
Description copied from interface:PrefixMapping
Compress the URI using the prefix mappings if possible. If there is a prefix mapping Name -> URIStart, and uri is URIStart+Tail, return Name:Tail; otherwise return uri unchanged. If there are multiple applicable mappings available, the "most recent" is chosen if that is possible, otherwise one is picked "at random".The result is primarily intended for human convenience: it is not necessarily a legal QName, as Tail need not be a legal NCName; and there's no way to tell a shortened name from a URI with an unusual scheme.
- Specified by:
shortForm
in 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
public static void addNamespaces(Model m, java.util.Map<java.lang.String,java.util.Set<java.lang.String>> ns)
Service method to update the namespaces of a Model given the mappings from prefix names to sets of URIs. If the prefix maps to multiple URIs, then we discard it completely.- Parameters:
m
- Model who's namespace is to be updatedns
- the namespace map to add to the Model
-
listStatements
public StmtIterator listStatements()
Description copied from interface:Model
List all statements.Subsequent operations on those statements may modify this model.
- Specified by:
listStatements
in interfaceModel
- Returns:
- an iterator over all statements in the model.
-
add
public Model add(Statement[] statements)
Add all the statements to the model by converting them to an array of corresponding triples and removing those from the underlying graph.
-
add
public Model add(java.util.List<Statement> statements)
Add all the statements to the model by converting the list to an array of Statement and removing that.
-
remove
public Model remove(Statement[] statements)
remove all the Statements from the model by converting them to triples and removing those triples from the underlying graph.
-
remove
public Model remove(java.util.List<Statement> statements)
Remove all the Statements from the model by converting the List to a List(Statement) and removing that.
-
add
public Model add(Resource s, Property p, RDFNode o)
Description copied from interface:ModelCon
add a statement to this model.
-
listReifiedStatements
public RSIterator listReifiedStatements()
Description copied from interface:Model
answer an iterator delivering all the reified statements "in" this model- Specified by:
listReifiedStatements
in interfaceModel
- Returns:
- an iterator which delivers all the ReifiedStatements in this model
-
listReifiedStatements
public RSIterator listReifiedStatements(Statement st)
Description copied from interface:Model
answer an iterator delivering all the reified statements "in" this model that match the statement _st_.- Specified by:
listReifiedStatements
in interfaceModel
- Returns:
- an iterator each of whose elements is a ReifiedStatement in this model such that it's getStatement().equals( st )
-
isReified
public boolean isReified(Statement s)
Description copied from interface:Model
Determine if this Statement has been reified in this Model.
-
getAnyReifiedStatement
public Resource getAnyReifiedStatement(Statement s)
get any reification of the given statement in this model; make one if necessary.- Specified by:
getAnyReifiedStatement
in interfaceModel
- Parameters:
s
- for which a reification is sought- Returns:
- a ReifiedStatement that reifies _s_
-
removeAllReifications
public void removeAllReifications(Statement s)
remove any ReifiedStatements reifying the given statement- Specified by:
removeAllReifications
in interfaceModel
- Parameters:
s
- the statement who's reifications are to be discarded
-
removeReification
public void removeReification(ReifiedStatement rs)
Description copied from interface:Model
Remove a particular reificiation.- Specified by:
removeReification
in interfaceModel
-
createReifiedStatement
public ReifiedStatement createReifiedStatement(Statement s)
create a ReifiedStatement that encodes _s_ and belongs to this Model.- Specified by:
createReifiedStatement
in interfaceModel
-
createReifiedStatement
public ReifiedStatement createReifiedStatement(java.lang.String uri, Statement s)
Description copied from interface:Model
answer a ReifiedStatement that encodes _s_, belongs to this Model, and is a Resource with that _uri_.- Specified by:
createReifiedStatement
in interfaceModel
-
contains
public boolean contains(Statement s)
Description copied from interface:Model
Determine if a statement is present in this model.
-
containsResource
public boolean containsResource(RDFNode r)
Description copied from interface:Model
determine if the RDFNode r appears in any statement of this model. (containsRDFNode is a horrible name, and in any case, even literals will be resources one day)- Specified by:
containsResource
in interfaceModel
- Parameters:
r
- the RDFNode to be searched for- Returns:
- true iff r appears as some subject, predicate, or object
-
contains
public boolean contains(Resource s, Property p)
Description copied from interface:Model
Determine whether this model contains any statements with a given subject and property.
-
contains
public boolean contains(Resource s, Property p, RDFNode o)
Description copied from interface:Model
Determine if an (S, P, O) pattern is present in this model, with null allowed to represent a wildcard match.- Specified by:
contains
in 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
public Statement getRequiredProperty(Resource s, Property p)
Description copied from interface:Model
Return a statement with given subject and property.If more than one statement witht the given subject and property exists in the model, it is undefined which will be returned. If none exist, an exception is thrown.
- Specified by:
getRequiredProperty
in 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
public Statement getRequiredProperty(Resource s, Property p, java.lang.String lang)
Description copied from interface:Model
Return a statement with given subject and property.If more than one statement witht the given subject and property exists in the model, it is undefined which will be returned. If none exist, an exception is thrown.
- Specified by:
getRequiredProperty
in 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
public Statement getProperty(Resource s, Property p)
Description copied from interface:Model
Answer a statement (s, p, ?O) from this model. If none exist, return null; if several exist, pick one arbitrarily.- Specified by:
getProperty
in 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
public Statement getProperty(Resource s, Property p, java.lang.String lang)
Description copied from interface:Model
Answer a statement (s, p, ?O) from this model. If none exist, return null; if several exist, pick one arbitrarily.- Specified by:
getProperty
in 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
-
listSubjects
public ResIterator listSubjects()
Description copied from interface:Model
List all resources which are subjects of statements.Subsequent operations on those resource may modify this model.
- Specified by:
listSubjects
in 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
public ResIterator listResourcesWithProperty(Property p)
Description copied from interface:Model
Answer an iterator [with no duplicates] over all the resources in this model that have propertyp
.remove()
is not implemented on this iterator.- Specified by:
listResourcesWithProperty
in interfaceModel
-
listSubjectsWithProperty
public ResIterator listSubjectsWithProperty(Property p)
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
public ResIterator listResourcesWithProperty(Property p, RDFNode o)
Description copied from interface:Model
Answer an iterator [with no duplicates] over all the resources in this model that have propertyp
with valueo
.remove()
is not implemented on this iterator.- Specified by:
listResourcesWithProperty
in interfaceModel
-
listObjects
public NodeIterator 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
public NodeIterator listObjectsOfProperty(Property p)
Description copied from interface:Model
List all objects of a given property. .remove() is not implemented on this iterator.- Specified by:
listObjectsOfProperty
in interfaceModel
- Parameters:
p
- The predicate sought- Returns:
- an iterator over the objects
-
listObjectsOfProperty
public NodeIterator listObjectsOfProperty(Resource s, Property p)
Description copied from interface:Model
List the values of a property of a resource.- Specified by:
listObjectsOfProperty
in interfaceModel
p
- The predicate sought- Returns:
- an iterator over the objects. .remove() is not implemented on this iterator.
-
listStatements
public StmtIterator listStatements(Selector selector)
Description copied from interface:Model
List the statements matching a selector.A statement is considered to match if the
test
method of s returns true when called on s.- Specified by:
listStatements
in interfaceModel
- Parameters:
selector
- A selector object. .- Returns:
- an iterator over the matching statements
-
findTriplesFrom
public ExtendedIterator<Triple> findTriplesFrom(Selector s)
Answer an [extended] iterator which returns the triples in this graph which are selected by the (S, P, O) triple in the selector, ignoring any special tests it may do.- Parameters:
s
- a Selector used to supply subject, predicate, and object- Returns:
- an extended iterator over the matching (S, P, O) triples
-
supportsTransactions
public boolean supportsTransactions()
Description copied from interface:Model
Determine whether this model supports transactions.- Specified by:
supportsTransactions
in interfaceModel
- Returns:
- true if this model supports transactions.
-
begin
public Model begin()
Description copied from interface:Model
Begin a new transaction.All changes made to a model within a transaction, will either be made, or none of them will be made.
-
abort
public Model abort()
Description copied from interface:Model
Abort the current transaction and abandon any changes in progress.
-
commit
public Model commit()
Description copied from interface:Model
Commit the current transaction.
-
executeInTxn
public void executeInTxn(java.lang.Runnable action)
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
public <T> T calculateInTxn(java.util.function.Supplier<T> action)
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
public Resource createResource()
Description copied from interface:Model
Create a new anonymous resource whose model is this model. This bnode will have a new AnonId distinct from any allocated by any other call of this method.Subsequent operations on the returned resource may modify this model.
- Specified by:
createResource
in interfaceModel
- Returns:
- a new anonymous resource linked to this model.
-
createResource
public Resource createResource(java.lang.String uri)
Description copied from interface:Model
Create a new resource associated with this model. If the uri string is null, this creates a bnode, as 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.
-
createProperty
public Property createProperty(java.lang.String uri)
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
public Property createProperty(java.lang.String nameSpace, java.lang.String localName)
Description copied from interface:Model
Create a property with a given URI composed from a namespace part and a localname part by concatenating the strings.This method may return an existing property with the correct URI and model, or it may construct a fresh one, as it sees fit.
Subsequent operations on the returned property may modify this model.
- Specified by:
createProperty
in interfaceModel
- Parameters:
nameSpace
- the nameSpace of the propertylocalName
- the name of the property within its namespace- Returns:
- a property instance
-
createStatement
public Statement createStatement(Resource r, Property p, RDFNode o)
create a Statement from the given r, p, and o.- Specified by:
createStatement
in interfaceModel
- Parameters:
r
- the subject of the statementp
- the predicate of the statemento
- the object of the statement- Returns:
- the new statement
-
createBag
public Bag createBag(java.lang.String uri)
Description copied from interface:ModelCon
Create a new bag.Subsequent operations on the bag or any of its parts may modify this model.
A statement defining the type of the new bag is added to this model.
-
createAlt
public Alt createAlt(java.lang.String uri)
Description copied from interface:ModelCon
Create a new alt.Subsequent operations on the alt or any of its parts may modify this model.
A statement defining the type of the new alt is added to this model.
-
createSeq
public Seq createSeq(java.lang.String uri)
Description copied from interface:ModelCon
Create a new seq.Subsequent operations on the seq or any of its parts may modify this model.
A statement defining the type of the new seq is added to this model.
-
asStatement
public Statement asStatement(Triple t)
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
public StmtIterator asStatements(java.util.Iterator<Triple> it)
-
listBySubject
public StmtIterator listBySubject(Container cont)
-
close
public void close()
Description copied from interface:Model
Close the Model and free up resources held.Not all implementations of Model require this method to be called. But some do, so in general its best to call it when done with the object, rather than leave it to the finalizer.
-
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.
-
query
public Model query(Selector selector)
Description copied from interface:Model
Create a new model containing the statements matching a query.A statement is considered to match if the
test
method of s returns true when called on s.
-
union
public Model union(Model model)
Description copied from interface:Model
Create a new, independant, model containing all the statements in this model together with all of those in another given model. By independant we mean that changes to the result model do not affect the operand models, and vice versa.The new model need not be of the same type as either this model or the argument model: typically it will be a memory-based model, even if this model is a database model.
-
intersection
public Model intersection(Model other)
Intersect this with another model. As an attempt at optimisation, we try and ensure we iterate over the smaller model first. Nowadays it's not clear that this is a good idea, 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:
Model.intersection(org.apache.jena.rdf.model.Model)
-
intersect
public static Model intersect(Model smaller, Model larger)
Answer a Model that is the intersection of the two argument models. The first argument is the model iterated over, and the second argument is the one used to check for membership. [So the first one should be "small" and the second one "membership cheap".]
-
difference
public Model difference(Model model)
Description copied from interface:Model
Create a new, independant, model containing all the statements in this model which are not in another. The new model need not be of the same type as either this model or the argument model: typically it will be a memory-based model.- Specified by:
difference
in 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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
reifiedToString
public java.lang.String reifiedToString()
-
isIsomorphicWith
public boolean isIsomorphicWith(Model m)
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
public Lock getModelLock()
-
getLock
public Lock getLock()
Description copied from interface:Model
Get the model lock for this model. See also the convenience operations enterCriticalSection and leaveCriticalSection.
-
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:
Lock.leaveCriticalSection()
-
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:
Lock.enterCriticalSection(boolean)
-
register
public Model register(ModelChangedListener listener)
Register the listener with this model by registering its GraphListener adaption with the underlying Graph.- Specified by:
register
in interfaceModel
- Parameters:
listener
- A ModelChangedListener to register for model events- Returns:
- this model, for cascading
- See Also:
ModelChangedListener
-
unregister
public Model unregister(ModelChangedListener listener)
Unregister the listener from this model by unregistering its GraphListener adaption from the underlying Graph.- Specified by:
unregister
in interfaceModel
- Parameters:
listener
- A ModelChangedListener to unregister from model events- Returns:
- this model, for cascading
- See Also:
ModelChangedListener
-
adapt
public GraphListener adapt(ModelChangedListener L)
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:
ModelListenerAdapter
-
notifyEvent
public Model notifyEvent(java.lang.Object e)
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
-
-