public class ModelCom extends EnhGraph implements Model, PrefixMapping, Lock
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.
PrefixMapping.Factory, PrefixMapping.IllegalPrefixException, PrefixMapping.JenaLockedException
Extended, Standard
Constructor and Description |
---|
ModelCom(Graph base)
make a model based on the specified graph
|
ModelCom(Graph base,
Personality<RDFNode> personality) |
Modifier and Type | Method and 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 in
L . |
Model |
add(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,
RDFNode o)
add a statement to this model.
|
Model |
add(Resource s,
Property p,
String o)
add a statement to this model.
|
Model |
add(Resource s,
Property p,
String o,
boolean wellFormed)
add a statement to this model.
|
Model |
add(Resource s,
Property p,
String lex,
RDFDatatype datatype)
add a statement to this model.
|
Model |
add(Resource s,
Property p,
String o,
String l)
add a statement to this model.
|
Model |
add(Resource s,
Property p,
String o,
String lang,
boolean wellFormed) |
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,
Literal o)
add a statement to this model.
|
Model |
addLiteral(Resource s,
Property p,
long o)
Add the statement (s, p, createTypedLiteral( o )) to this model and
answer this model.
|
Model |
addLiteral(Resource s,
Property p,
Object o)
Deprecated.
|
static void |
addNamespaces(Model m,
Map<String,Set<String>> ns)
Service method to update the namespaces of a Model given the
mappings from prefix names to sets of URIs.
|
Model |
asModel(Graph g) |
static Node |
asNode(RDFNode x) |
RDFNode |
asRDFNode(Node n)
Answer an RDF node wrapping
n suitably; URI nodes
become Resources with the same URI, blank nodes become Resources
with URI null but the same AnonId, and literal nodes become Literals
with n as their value carrier. |
Statement |
asStatement(Triple t)
Answer a Statement in this Model whcih encodes the given Triple.
|
StmtIterator |
asStatements(Iterator<Triple> it) |
List<Statement> |
asStatements(List<Triple> triples) |
Statement[] |
asStatements(Triple[] triples) |
Model |
begin()
Begin a new transaction.
|
<T> T |
calculateInTxn(Supplier<T> action)
Execute the supplier
action within a transaction. |
Model |
clearNsPrefixMap()
Clear this prefix mapping of all mappings
|
void |
close()
Close the Model and free up resources held.
|
Model |
commit()
Commit the current transaction.
|
boolean |
contains(Resource s,
Property p)
Determine whether this model contains any statements with a given subject
and property.
|
boolean |
contains(Resource s,
Property p,
RDFNode o)
Determine if an (S, P, O) pattern is present in this model, with null allowed
to represent a wildcard match.
|
boolean |
contains(Resource s,
Property p,
String o)
Determine if a statement is present in this model.
|
boolean |
contains(Resource s,
Property p,
String o,
String l)
Determine if a statement is present in this model.
|
boolean |
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,
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(String uri)
Create a new alt.
|
Bag |
createBag()
Create a new anonymous bag.
|
Bag |
createBag(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(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 order
|
Literal |
createLiteral(String v)
create a literal from a String value.
|
Literal |
createLiteral(String v,
boolean wellFormed)
Create a literal from a String value.
|
Literal |
createLiteral(String v,
String l)
Create an untyped literal from a String value with a specified language.
|
Literal |
createLiteral(String v,
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,
Object o)
Answer a new Statement object (s, p, o') where o' is the typed literal
corresponding to o using createTypedLiteral.
|
Property |
createProperty(String uri)
Create a property.
|
Property |
createProperty(String nameSpace,
String localName)
Create a property with a given URI composed from a namespace part and a
localname part by concatenating the strings.
|
ReifiedStatement |
createReifiedStatement(Statement s)
create a ReifiedStatement that encodes _s_ and belongs to this Model.
|
ReifiedStatement |
createReifiedStatement(String uri,
Statement s)
answer a ReifiedStatement that encodes _s_, belongs to this Model,
and is a Resource with that _uri_.
|
Resource |
createResource()
Create a new anonymous resource whose model is this model.
|
Resource |
createResource(AnonId id)
Create a blank node resource with a specified identifier.
|
Resource |
createResource(Resource type)
Create a new anonymous resource with a given type.
|
Resource |
createResource(ResourceF f)
Deprecated.
|
Resource |
createResource(String uri)
Create a new resource associated with this model.
|
Resource |
createResource(String uri,
Resource type)
Create a new resource with a given type.
|
Resource |
createResource(String uri,
ResourceF f)
Deprecated.
|
Seq |
createSeq()
Create a new anonymous seq.
|
Seq |
createSeq(String uri)
Create a new seq.
|
Statement |
createStatement(Resource r,
Property p,
RDFNode o)
create a Statement from the given r, p, and o.
|
Statement |
createStatement(Resource r,
Property p,
String o)
Create a Statement instance.
|
Statement |
createStatement(Resource r,
Property p,
String o,
boolean wellFormed)
Create a Statement instance.
|
Statement |
createStatement(Resource r,
Property p,
String o,
String l)
Create a Statement instance.
|
Statement |
createStatement(Resource r,
Property p,
String o,
String l,
boolean wellFormed)
Create a Statement instance.
|
Literal |
createTypedLiteral(boolean v)
create a type literal from a boolean value.
|
Literal |
createTypedLiteral(Calendar cal)
Create a typed literal xsd:dateTime from a Calendar object.
|
Literal |
createTypedLiteral(char v)
create a typed literal from a char value.
|
Literal |
createTypedLiteral(double v)
create a typed literal from a double value.
|
Literal |
createTypedLiteral(float v)
create a typed literal from a float value.
|
Literal |
createTypedLiteral(int v)
create a typed literal from an integer value.
|
Literal |
createTypedLiteral(long v)
create a typed literal from a long integer value.
|
Literal |
createTypedLiteral(Object value)
Build a typed literal label from its value form using
whatever datatype is currently registered as the the default
representation for this java class.
|
Literal |
createTypedLiteral(Object value,
RDFDatatype dtype)
Build a typed literal from its value form.
|
Literal |
createTypedLiteral(Object value,
String typeURI)
Build a typed literal from its value form.
|
Literal |
createTypedLiteral(String v)
create a typed literal from a String value.
|
Literal |
createTypedLiteral(String lex,
RDFDatatype dtype)
Build a typed literal from its lexical form.
|
Literal |
createTypedLiteral(String lex,
String typeURI)
Build a typed literal from its lexical form.
|
Model |
difference(Model model)
Create a new, independant, model containing all the statements in this model which
are not in another.
|
void |
enterCriticalSection(boolean requestReadLock)
Enter a critical section.
|
Object |
executeInTransaction(Command cmd)
If transactions are supported, execute the command c within a transaction
and return its result.
|
void |
executeInTxn(Runnable action)
Execute the runnable
action within a transaction. |
String |
expandPrefix(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(Resource r)
Return an Alt instance based on a given resource.
|
Alt |
getAlt(String uri)
Return an Alt instance in this model.
|
Resource |
getAnyReifiedStatement(Statement s)
get any reification of the given statement in this model; make
one if necessary.
|
Bag |
getBag(Resource r)
Return a bag instance based on a given resource.
|
Bag |
getBag(String uri)
Return a Bag instance in this model.
|
static PrefixMapping |
getDefaultModelPrefixes()
Deprecated.
This feature will be removed
|
Graph |
getGraph()
Answer the Graph which this Model is presenting.
|
RDFList |
getList(Resource r)
Return a RDF List based on a given resource.
|
RDFList |
getList(String uri)
Return a RDF List instance in this model.
|
Lock |
getLock()
Get the model lock for this model.
|
Lock |
getModelLock() |
Map<String,String> |
getNsPrefixMap()
Return a copy of the internal mapping from names to URI strings.
|
String |
getNsPrefixURI(String prefix)
Get the URI bound to a specific prefix, null if there isn't one.
|
String |
getNsURIPrefix(String uri)
Answer the prefix for the given URI, or null if there isn't one.
|
Statement |
getProperty(Resource s,
Property p)
Answer a statement (s, p, ?O) from this model.
|
Statement |
getProperty(Resource s,
Property p,
String lang)
Answer a statement (s, p, ?O) from this model.
|
Property |
getProperty(String uri)
Return a Property instance in this model.
|
Property |
getProperty(String nameSpace,
String localName)
Return a Property instance with the given URI in this model.
|
RDFNode |
getRDFNode(Node n)
|
RDFReader |
getReader()
return an RDFReader instance for the default serialization language.
|
RDFReader |
getReader(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,
String lang)
Return a statement with given subject and property.
|
Resource |
getResource(String uri)
Return a Resource instance with the given URI in this model.
|
Resource |
getResource(String uri,
ResourceF f)
Deprecated.
|
Seq |
getSeq(Resource r)
Return a Seq instance based on a given resource.
|
Seq |
getSeq(String uri)
Return a Seq instance in this model.
|
RDFWriter |
getWriter()
Get the model's writer after priming it with the model's namespace
prefixes.
|
RDFWriter |
getWriter(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 matches
subject , P
matches predicate , and O matches the typed literal
corresponding to object . |
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 matches
subject , P
matches predicate , and O matches the typed literal
corresponding to object . |
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 matches
subject , P
matches predicate , and O matches the typed literal
corresponding to object . |
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 matches
subject , P
matches predicate , and O matches the typed literal
corresponding to object . |
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 matches
subject , P
matches predicate , and O matches the typed literal
corresponding to object . |
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 matches
subject , P
matches predicate , and O matches the typed literal
corresponding to object . |
NsIterator |
listNameSpaces()
(You probably don't want this method; more likely you want the
PrefixMapping methods that Model supports.) List the namespaces used
by predicates and types in the model.
|
NodeIterator |
listObjects()
List all objects in a model.
|
NodeIterator |
listObjectsOfProperty(Property p)
List all objects of a given property.
|
NodeIterator |
listObjectsOfProperty(Resource s,
Property p)
List the values of a property of a resource.
|
RSIterator |
listReifiedStatements()
answer an iterator delivering all the reified statements "in" this model
|
RSIterator |
listReifiedStatements(Statement st)
answer an iterator delivering all the reified statements "in" this model
that match the statement _st_.
|
ResIterator |
listResourcesWithProperty(Property p)
Answer an iterator [with no duplicates] over all the resources in this
model that have property
p . |
ResIterator |
listResourcesWithProperty(Property p,
boolean o)
Answer an iterator [without duplicates] over all the resources in this
model which have value o' for property p, where o' is the typed literal
corresponding to o.
|
ResIterator |
listResourcesWithProperty(Property p,
char o)
Answer an iterator [without duplicates] over all the resources in this
model which have value o' for property p, where o' is the typed literal
corresponding to o.
|
ResIterator |
listResourcesWithProperty(Property p,
double o)
Answer an iterator [without duplicates] over all the resources in this
model which have value o' for property p, where o' is the typed literal
corresponding to o.
|
ResIterator |
listResourcesWithProperty(Property p,
float o)
Answer an iterator [without duplicates] over all the resources in this
model which have value o' for property p, where o' is the typed literal
corresponding to o.
|
ResIterator |
listResourcesWithProperty(Property p,
long o)
Answer an iterator [without duplicates] over all the resources in this
model which have value o' for property p, where o' is the typed literal
corresponding to o.
|
ResIterator |
listResourcesWithProperty(Property p,
Object o)
Answer an iterator [without duplicates] over all the resources in this
model which have value o' for property p, where o' is the typed literal
corresponding to o.
|
ResIterator |
listResourcesWithProperty(Property p,
RDFNode o)
Answer an iterator [with no duplicates] over all the resources in this
model that have property
p with value o . |
StmtIterator |
listStatements()
List all statements.
|
StmtIterator |
listStatements(Resource S,
Property P,
RDFNode O)
Find all the statements matching a pattern.
|
StmtIterator |
listStatements(Resource S,
Property P,
String O)
Find all the statements matching a pattern.
|
StmtIterator |
listStatements(Resource S,
Property P,
String O,
String L)
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 for
listResourcesWithProperty(Property) ,
retained for backward compatibility. |
ResIterator |
listSubjectsWithProperty(Property p,
RDFNode o)
An alias for
listResourcesWithProperty , retained for
backward compatibility. |
ResIterator |
listSubjectsWithProperty(Property p,
String o)
lists all subjects with a given property and property value.
|
ResIterator |
listSubjectsWithProperty(Property p,
String o,
String l)
lists all subjects with a given property and property value.
|
PrefixMapping |
lock()
Lock the PrefixMapping so that changes can no longer be made to it.
|
Model |
notifyEvent(Object e)
Notify any listeners that the event e has occurred.
|
int |
numPrefixes()
Return the number of defined prefixes.
|
String |
qnameFor(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(InputStream reader,
String base)
Add statements from a document.
|
Model |
read(InputStream reader,
String base,
String lang)
Add RDF statements represented in language
lang to the model. |
Model |
read(Reader reader,
String base)
Using this method is often a mistake.
|
Model |
read(Reader reader,
String base,
String lang)
Using this method is often a mistake.
|
Model |
read(String url)
Add the RDF statements from a document.
|
Model |
read(String url,
String lang)
Add statements from a serializion in language
lang to the
model. |
Model |
read(String url,
String base,
String lang)
Read into this model the RDF at
url , using
baseURI as the base URI if it is non-null. |
Model |
register(ModelChangedListener listener)
Register the listener with this model by registering its GraphListener
adaption with the underlying Graph.
|
String |
reifiedToString() |
Model |
remove(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 statements
|
Model |
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 statement
|
Model |
removeNsPrefix(String prefix)
Remove any existing maplet with the given prefix name and answer this
mapping.
|
String |
removeReader(String lang)
Deprecated.
|
void |
removeReification(ReifiedStatement rs)
Remove a particular reificiation.
|
String |
removeWriter(String lang)
Deprecated.
|
void |
resetRDFReaderF()
Deprecated.
|
void |
resetRDFWriterF()
Deprecated.
|
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.
|
static PrefixMapping |
setDefaultModelPrefixes(PrefixMapping pm)
Deprecated.
This feature will be removed
|
Model |
setNsPrefix(String prefix,
String uri)
Specify the prefix name for a URI prefix string.
|
Model |
setNsPrefixes(Map<String,String> map)
Copies the prefix mapping from other into this.
|
Model |
setNsPrefixes(PrefixMapping pm)
Copies the prefixes from other into this.
|
String |
setReaderClassName(String lang,
String className)
Deprecated.
Use
org.apache.jena.riot.RDFParserRegistry.register |
String |
setWriterClassName(String lang,
String className)
Deprecated.
Use
org.apache.jena.riot.RDFWriterRegistry.register |
String |
shortForm(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.
|
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 in
map , only
adding those (p, u) pairs for which neither p nor u appears in this mapping. |
Resource |
wrapAsResource(Node n) |
Model |
write(OutputStream writer)
Write a serialization of this model as an XML document.
|
Model |
write(OutputStream writer,
String lang)
Write a serialized representation of this model in a specified language.
|
Model |
write(OutputStream writer,
String lang,
String base)
Write a serialized representation of a model in a specified language.
|
Model |
write(Writer writer)
Write the model as an XML document.
|
Model |
write(Writer writer,
String lang)
Write a serialized representation of a model in a specified language.
|
Model |
write(Writer writer,
String lang,
String base)
Write a serialized representation of a model in a specified language.
|
asGraph, equals, getNodeAs, hashCode, isIsomorphicWith, setNodeCache
public ModelCom(Graph base)
public ModelCom(Graph base, Personality<RDFNode> personality)
@Deprecated public static PrefixMapping getDefaultModelPrefixes()
@Deprecated public static PrefixMapping setDefaultModelPrefixes(PrefixMapping pm)
public Graph getGraph()
ModelGraphInterface
getGraph
in interface ModelGraphInterface
public RDFNode asRDFNode(Node n)
ModelGraphInterface
n
suitably; URI nodes
become Resources with the same URI, blank nodes become Resources
with URI null but the same AnonId, and literal nodes become Literals
with n
as their value carrier.asRDFNode
in interface ModelGraphInterface
public Resource wrapAsResource(Node n)
wrapAsResource
in interface ModelGraphInterface
@Deprecated public Resource getResource(String uri, ResourceF f)
ModelCon
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.
getResource
in interface ModelCon
uri
- the URI of the resourcef
- the factory objectpublic Model addLiteral(Resource s, Property p, boolean o)
ModelCon
addLiteral
in interface ModelCon
public Model addLiteral(Resource s, Property p, long o)
ModelCon
addLiteral
in interface ModelCon
public Model addLiteral(Resource s, Property p, int o)
ModelCon
addLiteral
in interface ModelCon
public Model addLiteral(Resource s, Property p, char o)
ModelCon
addLiteral
in interface ModelCon
public Model addLiteral(Resource s, Property p, float o)
ModelCon
addLiteral
in interface ModelCon
public Model addLiteral(Resource s, Property p, double o)
ModelCon
addLiteral
in interface ModelCon
public Model add(Resource s, Property p, String o)
ModelCon
public Model add(Resource s, Property p, String o, boolean wellFormed)
ModelCon
public Model add(Resource s, Property p, String lex, RDFDatatype datatype)
ModelCon
public Model add(Resource s, Property p, String o, String l)
ModelCon
@Deprecated public Model addLiteral(Resource s, Property p, Object o)
ModelCon
addLiteral
in interface ModelCon
s
- the subject of the statement to addp
- the predicate of the statement to addo
- the object of the statement to addpublic Model addLiteral(Resource s, Property p, Literal o)
ModelCon
addLiteral
in interface ModelCon
s
- the subject of the statement to addp
- the predicate of the statement to addo
- the object of the statement to addpublic Model add(StmtIterator iter)
Model
public Model add(Model m)
Model
public RDFReader getReader()
RDFReaderF
getReader
in interface RDFReaderF
public RDFReader getReader(String lang)
RDFReaderF
getReader
in interface RDFReaderF
lang
- the serialization language - null
selects the
default@Deprecated public String setReaderClassName(String lang, String className)
org.apache.jena.riot.RDFParserRegistry.register
RDFReaderF
setReaderClassName
in interface RDFReaderF
lang
- the language for which this class should be usedclassName
- the class name for readers for this language@Deprecated public void resetRDFReaderF()
RDFReaderF
resetRDFReaderF
in interface RDFReaderF
@Deprecated public String removeReader(String lang) throws IllegalArgumentException
RDFReaderF
removeReader
in interface RDFReaderF
lang
- The lang to remove.IllegalArgumentException
- if lang is one of the initial languagespublic Model read(String url)
Model
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.
public Model read(Reader reader, String base)
Model
Model.read(InputStream, String, String)
for explicitily setting the serialization language.
See "Reading and Writing RDF in Apache Jena" for more information about concrete syntaxes.
public Model read(InputStream reader, String base)
Model
Model.read(InputStream, String, String)
for explicitly setting the language.
See "Reading and Writing RDF in Apache Jena" for more information about concrete syntaxes.
read
in interface Model
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 be null
.
If the base is the empty string, then relative URIs will be retained in
the model. This is typically unwise and will usually generate errors
when writing the model back out.public Model read(String url, String lang)
Model
lang
to the
model.
lang
are "RDF/XML", "N-TRIPLE",
"TURTLE" (or "TTL") and "N3".
null
represents the default language, "RDF/XML".
"RDF/XML-ABBREV" is a synonym for "RDF/XML".
See Model
for a description of how to traverse a firewall.
See "Reading and Writing RDF in Apache Jena" for more information about concrete syntaxes.
public Model read(String url, String base, String lang)
Model
url
, using
baseURI
as the base URI if it is non-null. The RDF is assumed
to be RDF/XML unless lang
is non-null, in which case it names
the language to be used. Answer this model.public Model read(Reader reader, String base, String lang)
Model
lang
to the model.
lang
are "RDF/XML", "N-TRIPLE",
"TURTLE" (or "TTL") and "N3".
null
represents the default language, "RDF/XML".
"RDF/XML-ABBREV" is a synonym for "RDF/XML".
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.read
in interface Model
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 be null
.
If the base is the empty string, then relative URIs will be retained in
the model. This is typically unwise and will usually generate errors
when writing the model back out.lang
- the language of the serialization null
selects the defaultpublic Model read(InputStream reader, String base, String lang)
Model
lang
to the model.
lang
are "RDF/XML", "N-TRIPLE",
"TURTLE" (or "TTL") and "N3".
null
represents the default language, "RDF/XML".
"RDF/XML-ABBREV" is a synonym for "RDF/XML".
read
in interface Model
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 be null
.
If the base is the empty string, then relative URIs will be retained in
the model. This is typically unwise and will usually generate errors
when writing the model back out.
See "Reading and Writing RDF in Apache Jena" for more information about concrete syntaxes.
lang
- the language of the serialization null
selects the defaultpublic RDFWriter getWriter()
getWriter
in interface RDFWriterF
public RDFWriter getWriter(String lang)
getWriter
in interface RDFWriterF
lang
- the serialization language - null
selects the
default@Deprecated public String setWriterClassName(String lang, String className)
org.apache.jena.riot.RDFWriterRegistry.register
RDFWriterF
setWriterClassName
in interface RDFWriterF
lang
- the language for which this class should be usedclassName
- the class name for writers for this language@Deprecated public void resetRDFWriterF()
RDFWriterF
resetRDFWriterF
in interface RDFWriterF
@Deprecated public String removeWriter(String lang) throws IllegalArgumentException
RDFWriterF
removeWriter
in interface RDFWriterF
lang
- The lang to remove.IllegalArgumentException
- if lang is one of the initial languagespublic Model write(Writer writer)
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.
public Model write(Writer writer, String lang)
Model
Write a serialized representation of a model in a specified language. It is often better to use an OutputStream rather than a Writer, since this will avoid character encoding errors.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value,
represented by null
is "RDF/XML".
public Model write(Writer writer, String lang, String base)
Model
Write a serialized representation of a model in a specified language. It is often better to use an OutputStream rather than a Writer, since this will avoid character encoding errors.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value,
represented by null
, is "RDF/XML".
public Model write(OutputStream writer)
Model
Write a serialization of this model as an XML document.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value is
represented by null
is "RDF/XML".
public Model write(OutputStream writer, String lang)
Model
Write a serialized representation of this model in a specified language.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value,
represented by null
, is "RDF/XML".
public Model write(OutputStream writer, String lang, String base)
Model
Write a serialized representation of a model in a specified language.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value,
represented by null
, is "RDF/XML".
write
in interface Model
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 of lang
, this value may be included in the output.public Model remove(Statement s)
Model
The statement with the same subject, predicate and object as that supplied will be removed from the model.
public Model remove(Resource s, Property p, RDFNode o)
ModelCon
(s, p, o)
from this model and
answer this model. None of s, p, o
are permitted to
be null
: for wildcard removal, see removeAll
.public Model remove(StmtIterator iter)
ModelCon
public Model remove(Model m)
ModelCon
public Model removeAll()
Model
public Model removeAll(Resource s, Property p, RDFNode o)
Model
public boolean containsLiteral(Resource s, Property p, boolean o)
ModelCon
containsLiteral
in interface ModelCon
public boolean containsLiteral(Resource s, Property p, long o)
ModelCon
containsLiteral
in interface ModelCon
public boolean containsLiteral(Resource s, Property p, int o)
ModelCon
containsLiteral
in interface ModelCon
public boolean containsLiteral(Resource s, Property p, char o)
ModelCon
containsLiteral
in interface ModelCon
public boolean containsLiteral(Resource s, Property p, float o)
ModelCon
containsLiteral
in interface ModelCon
public boolean containsLiteral(Resource s, Property p, double o)
ModelCon
containsLiteral
in interface ModelCon
public boolean contains(Resource s, Property p, String o)
ModelCon
public boolean contains(Resource s, Property p, String o, String l)
ModelCon
contains
in interface ModelCon
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 objectpublic boolean containsLiteral(Resource s, Property p, Object o)
ModelCon
containsLiteral
in interface ModelCon
public boolean containsAny(Model model)
Model
containsAny
in interface Model
model
- the model containing the statements to be testedpublic boolean containsAll(Model model)
Model
containsAll
in interface Model
model
- the model containing the statements to be testedpublic boolean containsAny(StmtIterator iter)
Model
containsAny
in interface Model
iter
- an iterator of the statements to be testedpublic boolean containsAll(StmtIterator iter)
Model
containsAll
in interface Model
iter
- an iterator of the statements to be testedpublic StmtIterator listStatements(Resource S, Property P, RDFNode O)
Model
Return an iterator over all the statements in a model
that match a pattern. The statements selected are those
whose subject matches the subject
argument,
whose predicate matches the predicate
argument
and whose object matches the object
argument.
If an argument is null
it matches anything.
listStatements
in interface Model
S
- The subject soughtP
- The predicate soughtO
- The value soughtpublic StmtIterator listStatements(Resource S, Property P, String O)
ModelCon
Return an iterator over all the statements in a model
that match a pattern. The statements selected are those
whose subject matches the subject
argument,
whose predicate matches the predicate
argument
and whose object matchesthe object
argument.
listStatements
in interface ModelCon
S
- The subject soughtP
- The predicate soughtO
- The value soughtpublic StmtIterator listStatements(Resource S, Property P, String O, String L)
ModelCon
Return an iterator over all the statements in a model
that match a pattern. The statements selected are those
whose subject matches the subject
argument,
whose predicate matches the predicate
argument
and whose object matchesthe object
argument.
If an argument is null
it matches anything.
listStatements
in interface ModelCon
S
- The subject soughtP
- The predicate soughtO
- The value soughtL
- The lang code ofthe string.public StmtIterator listLiteralStatements(Resource S, Property P, boolean O)
ModelCon
subject
, P
matches predicate
, and O matches the typed literal
corresponding to object
.listLiteralStatements
in interface ModelCon
public StmtIterator listLiteralStatements(Resource S, Property P, long O)
ModelCon
subject
, P
matches predicate
, and O matches the typed literal
corresponding to object
.listLiteralStatements
in interface ModelCon
public StmtIterator listLiteralStatements(Resource S, Property P, int O)
ModelCon
subject
, P
matches predicate
, and O matches the typed literal
corresponding to object
.listLiteralStatements
in interface ModelCon
public StmtIterator listLiteralStatements(Resource S, Property P, char O)
ModelCon
subject
, P
matches predicate
, and O matches the typed literal
corresponding to object
.listLiteralStatements
in interface ModelCon
public StmtIterator listLiteralStatements(Resource S, Property P, float O)
ModelCon
subject
, P
matches predicate
, and O matches the typed literal
corresponding to object
.listLiteralStatements
in interface ModelCon
public StmtIterator listLiteralStatements(Resource S, Property P, double O)
ModelCon
subject
, P
matches predicate
, and O matches the typed literal
corresponding to object
.listLiteralStatements
in interface ModelCon
public ResIterator listResourcesWithProperty(Property p, boolean o)
ModelCon
listResourcesWithProperty
in interface ModelCon
public ResIterator listResourcesWithProperty(Property p, char o)
ModelCon
listResourcesWithProperty
in interface ModelCon
public ResIterator listResourcesWithProperty(Property p, long o)
ModelCon
listResourcesWithProperty
in interface ModelCon
public ResIterator listResourcesWithProperty(Property p, float o)
ModelCon
listResourcesWithProperty
in interface ModelCon
public ResIterator listResourcesWithProperty(Property p, double o)
ModelCon
listResourcesWithProperty
in interface ModelCon
public ResIterator listResourcesWithProperty(Property p, Object o)
ModelCon
listResourcesWithProperty
in interface ModelCon
public ResIterator listSubjectsWithProperty(Property p, RDFNode o)
Model
listResourcesWithProperty
, retained for
backward compatibility. It may be deprecated in later releases.listSubjectsWithProperty
in interface Model
public ResIterator listSubjectsWithProperty(Property p, String o)
ModelCon
listSubjectsWithProperty
in interface ModelCon
p
- The predicate sought.o
- The property value sought.public ResIterator listSubjectsWithProperty(Property p, String o, String l)
ModelCon
listSubjectsWithProperty
in interface ModelCon
p
- The predicate sought.o
- The property value sought.l
- the language associated with the objectpublic Resource createResource(Resource type)
ModelCon
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.
createResource
in interface ModelCon
type
- the type of the resource to be created.public Resource createResource(String uri, Resource type)
ModelCon
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.
createResource
in interface ModelCon
uri
- The URI of the new resource.type
- the type of the resource to be created.@Deprecated public Resource createResource(ResourceF f)
ModelCon
Subsequent operations on the returned resource may modify this model.
createResource
in interface ModelCon
f
- A factory object to create the returned object.
.public Resource createResource(AnonId id)
Model
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
createResource
in interface Model
id
- the identifier to use for this blank node@Deprecated public Resource createResource(String uri, ResourceF f)
ModelCon
Subsequent operations on the returned resource may modify this model.
createResource
in interface ModelCon
uri
- the URI of the resourcef
- A factory to create the returned object.
.public Literal createTypedLiteral(boolean v)
The value is converted to a string using its toString
method.
createTypedLiteral
in interface ModelCon
v
- the value of the literalpublic Literal createTypedLiteral(int v)
createTypedLiteral
in interface ModelCon
v
- the value of the literalpublic Literal createTypedLiteral(long v)
createTypedLiteral
in interface ModelCon
v
- the value of the literalpublic Literal createTypedLiteral(char v)
createTypedLiteral
in interface ModelCon
v
- the value of the literalpublic Literal createTypedLiteral(float v)
createTypedLiteral
in interface ModelCon
v
- the value of the literalpublic Literal createTypedLiteral(double v)
createTypedLiteral
in interface ModelCon
v
- the value of the literalpublic Literal createTypedLiteral(String v)
createTypedLiteral
in interface ModelCon
v
- the value of the literalpublic Literal createTypedLiteral(Calendar cal)
createTypedLiteral
in interface ModelCon
public Literal createTypedLiteral(String lex, RDFDatatype dtype) throws DatatypeFormatException
createTypedLiteral
in interface Model
lex
- the lexical form of the literaldtype
- the type of the literal, null for old style "plain" literalsDatatypeFormatException
- if lex is not a legal form of dtypepublic Literal createTypedLiteral(Object value, RDFDatatype dtype)
createTypedLiteral
in interface Model
value
- the value of the literaldtype
- the type of the literal, null for old style "plain" literalspublic Literal createTypedLiteral(String lex, String typeURI)
createTypedLiteral
in interface ModelCon
lex
- the lexical form of the literaltypeURI
- the uri of the type of the literal, null for old style "plain" literalsDatatypeFormatException
- if lex is not a legal form of dtypepublic Literal createTypedLiteral(Object value, String typeURI)
createTypedLiteral
in interface ModelCon
value
- the value of the literaltypeURI
- the URI of the type of the literal, null for old style "plain" literalspublic Literal createTypedLiteral(Object value)
createTypedLiteral
in interface Model
createTypedLiteral
in interface ModelCon
value
- the literal value to encapsulatepublic Literal createLiteral(String v)
ModelCon
createLiteral
in interface ModelCon
v
- the value of the literalpublic Literal createLiteral(String v, String l)
Model
createLiteral
in interface Model
v
- the lexical form of the literall
- the language associated with the literalpublic Literal createLiteral(String v, boolean wellFormed)
Model
createLiteral
in interface Model
v
- the lexical form of the literalwellFormed
- true if the Literal is well formed XML, in the lexical space of rdf:XMLLiteralpublic Statement createLiteralStatement(Resource r, Property p, boolean o)
ModelCon
createLiteralStatement
in interface ModelCon
public Statement createLiteralStatement(Resource r, Property p, long o)
ModelCon
createLiteralStatement
in interface ModelCon
public Statement createLiteralStatement(Resource r, Property p, int o)
ModelCon
createLiteralStatement
in interface ModelCon
public Statement createLiteralStatement(Resource r, Property p, char o)
ModelCon
createLiteralStatement
in interface ModelCon
public Statement createLiteralStatement(Resource r, Property p, float o)
ModelCon
createLiteralStatement
in interface ModelCon
public Statement createLiteralStatement(Resource r, Property p, double o)
ModelCon
createLiteralStatement
in interface ModelCon
public Statement createStatement(Resource r, Property p, String o)
ModelCon
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.
createStatement
in interface ModelCon
r
- the subject of the statementp
- the predicate of the statemento
- is the value to be the object of the statementpublic Statement createLiteralStatement(Resource r, Property p, Object o)
ModelCon
createLiteralStatement
in interface ModelCon
public Statement createStatement(Resource r, Property p, String o, boolean wellFormed)
ModelCon
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.
createStatement
in interface ModelCon
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 XMLpublic Statement createStatement(Resource r, Property p, String o, String l)
ModelCon
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.
createStatement
in interface ModelCon
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 objectpublic Statement createStatement(Resource r, Property p, String o, String l, boolean wellFormed)
ModelCon
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.
createStatement
in interface ModelCon
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 XMLpublic Bag createBag()
ModelCon
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.
public Alt createAlt()
ModelCon
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.
public Seq createSeq()
ModelCon
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.
public RDFList createList()
createList
in interface Model
public RDFList createList(Iterator<? extends RDFNode> members)
Answer a new list containing the resources from the given iterator, in order.
createList
in interface Model
members
- An iterator, each value of which is expected to be an RDFNode.public RDFList createList(RDFNode... members)
Answer a new list containing the RDF nodes from the given array, in order
createList
in interface Model
members
- An array of RDFNodes that will be the members of the listpublic RDFNode getRDFNode(Node n)
ModelCon
Resource
or a Literal
)
from a graph Node. This is provided for users and
developers operating at the API/SPI interface, where Resources are
constructed from Nodes. Providing this method allows each Model
the opportunity to cache node-to-resource maps if it requires.getRDFNode
in interface ModelCon
n
- the graph.Node on which to base the Model.RDFNodepublic Resource getResource(String uri)
Model
createResource(String)
and exists as
legacy: createResource is now capable of, and allowed to, reuse existing objects.
Subsequent operations on the returned object may modify this model.
getResource
in interface Model
uri
- the URI of the resourcepublic Property getProperty(String uri)
ModelCon
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.
getProperty
in interface ModelCon
uri
- the URI of the propertypublic Property getProperty(String nameSpace, String localName)
Model
createProperty(String,String)
and exists as
legacy: createProperty is now capable of, and allowed to, reuse existing objects.
Subsequent operations on the returned property may modify this model.
getProperty
in interface Model
nameSpace
- the RDF namespace of the propertylocalName
- the localName of the property in its namespacepublic Seq getSeq(String uri)
ModelCon
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.
public Seq getSeq(Resource r)
ModelCon
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.
public Bag getBag(String uri)
ModelCon
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.
public Bag getBag(Resource r)
ModelCon
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.
public RDFList getList(String uri)
ModelCon
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.
public RDFList getList(Resource r)
ModelCon
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.
public Alt getAlt(String uri)
ModelCon
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.
public Alt getAlt(Resource r)
ModelCon
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.
public long size()
Model
public boolean isEmpty()
Model
public NsIterator listNameSpaces()
Model
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.
listNameSpaces
in interface Model
PrefixMapping
public boolean samePrefixMappingAs(PrefixMapping other)
PrefixMapping
this.getNsPrefixMap().equals( other.getNsPrefixMap() )except that it may avoid unnecessary Map creations.
samePrefixMappingAs
in interface PrefixMapping
public PrefixMapping lock()
PrefixMapping
lock
in interface PrefixMapping
public Model setNsPrefix(String prefix, String uri)
PrefixMapping
A prefix name must be a valid NCName, or the empty string. The empty string is reserved to mean "the default namespace".
Need not check the RFC2396 validity of the URI. Bad URIs are either silently ignored or behave as if they were good. The earlier restriction that the URI should end with a non-NCName character has been removed.
Note, in particular, that the prefix mapping can only be used if it includes the URI up to any '#' character because '#' is not legal in the local part of an NCName.
setNsPrefix
in interface Model
setNsPrefix
in interface PrefixMapping
prefix
- the string to be used for the prefix.uri
- the URI prefix to be namedpublic Model removeNsPrefix(String prefix)
PrefixMapping
The reverse URI-to-prefix mapping is updated, but if there are multiple prefixes for the removed URI it is unspecified which of them will be chosen.
removeNsPrefix
in interface Model
removeNsPrefix
in interface PrefixMapping
prefix
- the prefix string to removepublic Model clearNsPrefixMap()
PrefixMapping
clearNsPrefixMap
in interface Model
clearNsPrefixMap
in interface PrefixMapping
public Model setNsPrefixes(PrefixMapping pm)
PrefixMapping
setNsPrefixes
in interface Model
setNsPrefixes
in interface PrefixMapping
pm
- the PrefixMapping to addpublic Model setNsPrefixes(Map<String,String> map)
PrefixMapping
setNsPrefixes
in interface Model
setNsPrefixes
in interface PrefixMapping
map
- the Map whose maplets are to be addedpublic Model withDefaultMappings(PrefixMapping other)
PrefixMapping
map
, only
adding those (p, u) pairs for which neither p nor u appears in this mapping.
Answer this PrefixMapping.withDefaultMappings
in interface Model
withDefaultMappings
in interface PrefixMapping
public String getNsPrefixURI(String prefix)
PrefixMapping
getNsPrefixURI
in interface PrefixMapping
prefix
- the prefix name to be looked uppublic String getNsURIPrefix(String uri)
PrefixMapping
getNsURIPrefix
in interface PrefixMapping
uri
- the uri whose prefix is to be foundpublic Map<String,String> getNsPrefixMap()
PrefixMapping
getNsPrefixMap
in interface PrefixMapping
public String expandPrefix(String prefixed)
PrefixMapping
expandPrefix
in interface PrefixMapping
prefixed
- a QName or URIpublic String qnameFor(String uri)
PrefixMapping
qnameFor
in interface PrefixMapping
public String shortForm(String uri)
PrefixMapping
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.
shortForm
in interface PrefixMapping
uri
- the URI string to try and prefix-compresspublic boolean hasNoMappings()
PrefixMapping
hasNoMappings
in interface PrefixMapping
public int numPrefixes()
PrefixMapping
numPrefixes
in interface PrefixMapping
public static void addNamespaces(Model m, Map<String,Set<String>> ns)
m
- Model who's namespace is to be updatedns
- the namespace map to add to the Modelpublic StmtIterator listStatements()
Model
Subsequent operations on those statements may modify this model.
listStatements
in interface Model
public Model add(Statement[] statements)
public Model add(List<Statement> statements)
public Model remove(Statement[] statements)
public Model remove(List<Statement> statements)
public Model add(Resource s, Property p, RDFNode o)
ModelCon
public RSIterator listReifiedStatements()
Model
listReifiedStatements
in interface Model
public RSIterator listReifiedStatements(Statement st)
Model
listReifiedStatements
in interface Model
public boolean isReified(Statement s)
Model
public Resource getAnyReifiedStatement(Statement s)
getAnyReifiedStatement
in interface Model
s
- for which a reification is soughtpublic void removeAllReifications(Statement s)
removeAllReifications
in interface Model
s
- the statement who's reifications are to be discardedpublic void removeReification(ReifiedStatement rs)
Model
removeReification
in interface Model
public ReifiedStatement createReifiedStatement(Statement s)
createReifiedStatement
in interface Model
public ReifiedStatement createReifiedStatement(String uri, Statement s)
Model
createReifiedStatement
in interface Model
public boolean contains(Statement s)
Model
public boolean containsResource(RDFNode r)
Model
containsResource
in interface Model
r
- the RDFNode to be searched forpublic boolean contains(Resource s, Property p)
Model
public boolean contains(Resource s, Property p, RDFNode o)
Model
contains
in interface Model
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).public Statement getRequiredProperty(Resource s, Property p)
Model
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.
getRequiredProperty
in interface Model
s
- The subject of the statement to be returned.p
- The property of the statement to be returned.public Statement getRequiredProperty(Resource s, Property p, String lang)
Model
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.
getRequiredProperty
in interface Model
s
- The subject of the statement to be returned.p
- The property of the statement to be returned.lang
- The languagepublic Statement getProperty(Resource s, Property p)
Model
getProperty
in interface Model
s
- the subject of the statement to returnp
- the predicate of the statement to returnpublic Statement getProperty(Resource s, Property p, String lang)
Model
getProperty
in interface Model
s
- the subject of the statement to returnp
- the predicate of the statement to returnlang
- language of the objectpublic ResIterator listSubjects()
Model
Subsequent operations on those resource may modify this model.
listSubjects
in interface Model
public ResIterator listResourcesWithProperty(Property p)
Model
p
. remove()
is not implemented on this iterator.listResourcesWithProperty
in interface Model
public ResIterator listSubjectsWithProperty(Property p)
Model
listResourcesWithProperty(Property)
,
retained for backward compatibility. It may be deprecated in later
releases.listSubjectsWithProperty
in interface Model
public ResIterator listResourcesWithProperty(Property p, RDFNode o)
Model
p
with value o
.
remove()
is not implemented on this iterator.listResourcesWithProperty
in interface Model
public NodeIterator listObjects()
Model
listObjects
in interface Model
public NodeIterator listObjectsOfProperty(Property p)
Model
listObjectsOfProperty
in interface Model
p
- The predicate soughtpublic NodeIterator listObjectsOfProperty(Resource s, Property p)
Model
listObjectsOfProperty
in interface Model
p
- The predicate soughtpublic StmtIterator listStatements(Selector selector)
Model
A statement is considered to match if the test
method
of s returns true when called on s.
listStatements
in interface Model
selector
- A selector object.
.public ExtendedIterator<Triple> findTriplesFrom(Selector s)
s
- a Selector used to supply subject, predicate, and objectpublic boolean supportsTransactions()
Model
supportsTransactions
in interface Model
public Model begin()
Model
All changes made to a model within a transaction, will either be made, or none of them will be made.
public Model abort()
Model
public Model commit()
Model
public Object executeInTransaction(Command cmd)
Model
executeInTransaction
in interface Model
public void executeInTxn(Runnable action)
Model
action
within a transaction. If it completes normally,
commit the transaction, otherwise abort the transaction.executeInTxn
in interface Model
public <T> T calculateInTxn(Supplier<T> action)
action
within a transaction. If it completes normally,
commit the transaction and return the result, otherwise abort the transaction.calculateInTxn
in interface Model
public boolean independent()
Model
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.
independent
in interface Model
public Resource createResource()
Model
Subsequent operations on the returned resource may modify this model.
createResource
in interface Model
public Resource createResource(String uri)
Model
createResource()
. Otherwise it creates a URI node.
A URI resource is .equals() to any other URI Resource with the same URI (even in
a different model - be warned).
This method may return an existing Resource with the correct URI and model, or it may construct a fresh one, as it sees fit.
Operations on the result Resource may change this model.
createResource
in interface Model
uri
- the URI of the resource to be createdpublic Property createProperty(String uri)
ModelCon
Subsequent operations on the returned property may modify this model.
createProperty
in interface ModelCon
uri
- the URI of the propertypublic Property createProperty(String nameSpace, String localName)
Model
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.
createProperty
in interface Model
nameSpace
- the nameSpace of the propertylocalName
- the name of the property within its namespacepublic Statement createStatement(Resource r, Property p, RDFNode o)
createStatement
in interface Model
r
- the subject of the statementp
- the predicate of the statemento
- the object of the statementpublic Bag createBag(String uri)
ModelCon
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.
public Alt createAlt(String uri)
ModelCon
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.
public Seq createSeq(String uri)
ModelCon
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.
public Statement asStatement(Triple t)
asStatement
in interface ModelGraphInterface
t
- a triple to wrap as a statementpublic StmtIterator asStatements(Iterator<Triple> it)
public StmtIterator listBySubject(Container cont)
public void close()
Model
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.
public boolean isClosed()
Model
public boolean supportsSetOperations()
Model
supportsSetOperations
in interface Model
public Model query(Selector selector)
Model
A statement is considered to match if the test
method
of s returns true when called on s.
public Model union(Model model)
Model
The new model need not be of the same type as either this model or the argument model: typically it will be a memory-based model, even if this model is a database model.
public Model intersection(Model other)
size()
can be expensive on database and inference
models.intersection
in interface Model
other
- The other model.Model.intersection(org.apache.jena.rdf.model.Model)
public static Model intersect(Model smaller, Model larger)
public Model difference(Model model)
Model
difference
in interface Model
model
- the other model whose statements are to be excluded.public String reifiedToString()
public boolean isIsomorphicWith(Model m)
isIsomorphicWith
in interface Model
m
- Compare against this.public Lock getModelLock()
public Lock getLock()
Model
public void enterCriticalSection(boolean requestReadLock)
Lock
enterCriticalSection
in interface Lock
requestReadLock
- true implies a read lock, false implies write lock.Lock.leaveCriticalSection()
public void leaveCriticalSection()
Lock
leaveCriticalSection
in interface Lock
Lock.enterCriticalSection(boolean)
public Model register(ModelChangedListener listener)
register
in interface Model
listener
- A ModelChangedListener to register for model eventsModelChangedListener
public Model unregister(ModelChangedListener listener)
unregister
in interface Model
listener
- A ModelChangedListener to unregister from model eventsModelChangedListener
public GraphListener adapt(ModelChangedListener L)
L
.L
- a model listener to be wrapped as a graph listenerModelListenerAdapter
public Model notifyEvent(Object e)
Model
notifyEvent
in interface Model
e
- the event that has occurredLicenced under the Apache License, Version 2.0