|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An RDF Model.
An RDF model is a set of Statements. Methods are provided for creating resources, properties and literals and the Statements which link them, for adding statements to and removing them from a model, for querying a model and set operations for combining models.
This interface defines a set of primitive methods. A set of
convenience methods which extends this interface, e.g. performing
automatic type conversions and support for enhanced resources,
is defined in ModelCon
.
Some of the methods, e.g. the read methods, may have to traverse a firewall. This can be accomplished using the standard java method of setting system properties. To use a socks proxy, include on the java command line:
-DsocksProxyHost=[your-proxy-domain-name-or-ip-address]
To use an http proxy, include on the command line:
-DproxySet=true -DproxyHost=[your-proxy] -DproxyPort=[your-proxy-port-number]
Alternatively, these properties can be set programatically, e.g.
System.getProperties().put("proxySet","true");
System.getProperties().put("proxyHost","proxy.hostname");
System.getProperties().put("proxyPort",port_number);
Nested Class Summary |
Nested classes inherited from class com.hp.hpl.jena.shared.PrefixMapping |
com.hp.hpl.jena.shared.PrefixMapping.Factory, com.hp.hpl.jena.shared.PrefixMapping.IllegalPrefixException, com.hp.hpl.jena.shared.PrefixMapping.JenaLockedException |
Field Summary |
Fields inherited from interface com.hp.hpl.jena.shared.PrefixMapping |
Standard |
Fields inherited from interface com.hp.hpl.jena.rdf.model.ModelLock |
READ, WRITE |
Method Summary | |
Model |
abort()
Abort the current transaction and abandon any changes in progress. |
Model |
add(java.util.List statements)
add all the statements in the List to this Model, going through the bulk update interface (which means turning them into triples in one form or another). |
Model |
add(Model m)
Add all the statements in another model to this model. |
Model |
add(Statement s)
Add a statement to this model. |
Model |
add(Statement[] statements)
Add all the statements to the Model, using through the bulk update interface. |
Model |
add(StmtIterator iter)
Add all the statements returned by an iterator to this model. |
Model |
begin()
Begin a new transation. |
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 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 |
containsResource(RDFNode r)
determine if the RDFNode r appears in any statement of this model. |
RDFList |
createList()
Answer a new empty list. |
RDFList |
createList(java.util.Iterator members)
Answer a new list containing the resources from the given iterator, in order. |
RDFList |
createList(RDFNode[] members)
Answer a new list containing the nodes from the given array, in order |
Literal |
createLiteral(java.lang.String v,
java.lang.String language)
Create a literal from a String value with a specified language. |
Literal |
createLiteral(java.lang.String v,
java.lang.String language,
boolean wellFormed)
Create a literal from a String value with a specified language. |
Property |
createProperty(java.lang.String nameSpace,
java.lang.String localName)
Create a property. |
ReifiedStatement |
createReifiedStatement(Statement s)
Answer a ReifiedStatement that encodes _s_ and belongs to this Model. |
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_. |
Resource |
createResource()
Create a new anonymous resource. |
Resource |
createResource(AnonId id)
create a blank node resource with a specified identifier/ |
Resource |
createResource(java.lang.String uri)
Create a new resource. |
Statement |
createStatement(Resource s,
Property p,
RDFNode o)
Create a Statement instance. |
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 lang,
RDFDatatype dtype)
Build a typed literal from its value form. |
Literal |
createTypedLiteral(java.lang.String lex,
java.lang.String lang,
RDFDatatype dtype)
Build a typed literal from its lexical form. |
Model |
difference(Model model)
Create a new model containing all the statements in this model which are not in another. |
boolean |
equals(java.lang.Object model)
Test whether one model is the equal to another. |
java.lang.Object |
executeInTransaction(com.hp.hpl.jena.shared.Command cmd)
Execute the command cmd inside a transaction. |
Resource |
getAnyReifiedStatement(Statement s)
Find or create a ReifiedStatement corresponding to a Statement. |
Graph |
getGraph()
Every model is based on some Graph |
ModelLock |
getModelLock()
Get the model lock for this model. |
Statement |
getProperty(Resource s,
Property p)
Return a statement with given subject and property. |
Property |
getProperty(java.lang.String nameSpace,
java.lang.String localName)
Return a Property instance in this model. |
Resource |
getResource(java.lang.String uri)
Return a Resource instance in this model. |
boolean |
independent()
Determine whether this model is independent. |
Model |
intersection(Model model)
Create a new model containing all the statements which are in both this model and another. |
boolean |
isEmpty()
Answer true iff the model contains no explicit statements (ie it's size is zero, listStatements() would deliver the empty iterator). |
boolean |
isIsomorphicWith(Model g)
Compare this Model with another for equality ignoring the labels on bNodes. |
boolean |
isReified(Statement s)
Determine if this Statement has been reified in this Model. |
NsIterator |
listNameSpaces()
List all namespaces of predicates 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_. |
StmtIterator |
listStatements()
List all statements. |
StmtIterator |
listStatements(Resource s,
Property p,
RDFNode o)
Find all the statements matching a pattern. |
StmtIterator |
listStatements(Selector s)
List the statements matching a selector. |
ResIterator |
listSubjects()
List all resources which are subjects of statements. |
ResIterator |
listSubjectsWithProperty(Property p)
List all subjects with a given property. |
ResIterator |
listSubjectsWithProperty(Property p,
RDFNode o)
List all subjects with a given property and property value |
Model |
query(Selector s)
Create a new model containing the statements matching a query. |
ExtendedIterator |
queryBindingsWith(Model query,
Resource[] variables)
Answer an iterator over all the bindings implied by the query model. |
QueryHandler |
queryHandler()
Every Model has a QueryHandler |
Model |
read(java.io.InputStream in,
java.lang.String base)
Add statements from an RDF/XML serialization. |
Model |
read(java.io.InputStream in,
java.lang.String base,
java.lang.String lang)
Add RDF statements represented in language lang 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 an XML document. |
Model |
read(java.lang.String url,
java.lang.String lang)
Add statements from a serializion in language lang to the
model.
|
Model |
register(ModelChangedListener listener)
Register a listener for model-changed events on this model. |
Model |
remove(java.util.List statements)
Remove all the statements in the list from this model, using the bulk update interface. |
Model |
remove(Statement s)
Removes a statement. |
Model |
remove(Statement[] statements)
Remove all the statements from the Model, using the bulk update interface. |
void |
removeAllReifications(Statement s)
Remove all reifications (ie implicit reification quads) of _s_. |
void |
removeReification(ReifiedStatement rs)
Remove a particular reificiation. |
long |
size()
(Unwise) Computes the number of statements in the model. |
boolean |
supportsSetOperations()
Determine whether this model supports set operations. |
boolean |
supportsTransactions()
Determine whether this model supports transactions. |
Model |
union(Model model)
Create a new model containing all the statements in this model together with all of those in another given model. |
Model |
unregister(ModelChangedListener listener)
Unregister a listener from model-changed events on this model. |
Model |
write(java.io.OutputStream out)
Write a serialization of this model as an XML document. |
Model |
write(java.io.OutputStream out,
java.lang.String lang)
Write a serialized represention of this model in a specified language. |
Model |
write(java.io.OutputStream out,
java.lang.String lang,
java.lang.String base)
Write a serialized represention 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 represention of a model in a specified language. |
Model |
write(java.io.Writer writer,
java.lang.String lang,
java.lang.String base)
Write a serialized represention of a model in a specified language. |
Methods inherited from interface com.hp.hpl.jena.rdf.model.RDFReaderF |
getReader, getReader, setReaderClassName |
Methods inherited from interface com.hp.hpl.jena.rdf.model.RDFWriterF |
getWriter, getWriter, setWriterClassName |
Methods inherited from interface com.hp.hpl.jena.shared.PrefixMapping |
expandPrefix, getNsPrefixMap, getNsPrefixURI, getNsURIPrefix, lock, setNsPrefix, setNsPrefixes, setNsPrefixes, usePrefix |
Methods inherited from interface com.hp.hpl.jena.rdf.model.ModelLock |
enterCriticalSection, leaveCriticalSection |
Method Detail |
public Graph getGraph()
public QueryHandler queryHandler()
public long size()
public boolean isEmpty()
public ResIterator listSubjects()
Subsequent operations on those resource may modify this model.
public NsIterator listNameSpaces()
public ExtendedIterator queryBindingsWith(Model query, Resource[] variables)
public Resource getResource(java.lang.String uri)
Subsequent operations on the returned object may modify this model.
This method should be called if the resource may already exist in the
model so that an implementation may reuse the same object. If it does
not an object will be created. If it is known that an object for the
resource does not already exist, then it may be more efficient to call
createResource
instead.
uri
- the URI of the resource
.
public Property getProperty(java.lang.String nameSpace, java.lang.String localName)
Subsequent operations on the returned property may modify this model.
This method should be called if the property may already exist in the
model so that an implementation may reuse the same object. If it does
not an object will be created. If it is known that an object for the
property does not already exist, then it may be more efficient to call
createProperty
instead.
nameSpace
- the RDF namespace of the propertylocalName
- the localName of the property in its namespace
public Resource createResource()
Subsequent operations on the returned resource may modify this model.
.
public Resource createResource(AnonId id)
id
- the identifier to use for this blank node
public Resource createResource(java.lang.String uri)
Subsequent operations on the returned resource may modify this model.
uri
- the URI of the resource to be created
.
public Property createProperty(java.lang.String nameSpace, java.lang.String localName)
Subsequent operations on the returned property may modify this model.
nameSpace
- the nameSpace of the propertylocalName
- the name of the property within its namespace
public Literal createLiteral(java.lang.String v, java.lang.String language)
If v is null, then a literal with an empty string is created.
v
- the value of the literallanguage
- the language associated with the literal
public Literal createLiteral(java.lang.String v, java.lang.String language, boolean wellFormed)
If v is null, then a literal with an empty string is created.
v
- the value of the literallanguage
- the language associated with the literalwellFormed
- true if the Literal is well formed XML
public Literal createTypedLiteral(java.lang.String lex, java.lang.String lang, RDFDatatype dtype)
lex
- the lexical form of the literallang
- the optional language tagdtype
- the type of the literal, null for old style "plain" literals
DatatypeFormatException
- if lex is not a legal form of dtypepublic Literal createTypedLiteral(java.lang.Object value, java.lang.String lang, RDFDatatype dtype)
value
- the value of the literallang
- the optional language tagdtype
- the type of the literal, null for old style "plain" literalspublic Literal createTypedLiteral(java.lang.Object value)
createTypedLiteral
in interface ModelCon
value
- the literal value to encapsulate
public Statement createStatement(Resource s, Property p, RDFNode o)
Subsequent operations on the statement or any of its parts will modify this model.
Creating a statement does not add it to the set of statements in the model.
s
- the subject of the statementp
- the predicate of the statemento
- the object of the statement
public RDFList createList()
Answer a new empty list. This is equivalent to a list consisting only
of rdf:nil
.
public RDFList createList(java.util.Iterator members)
Answer a new list containing the resources from the given iterator, in order.
members
- An iterator, each value of which is expected to be an RDFNode
public RDFList createList(RDFNode[] members)
Answer a new list containing the nodes from the given array, in order
members
- An array of RDF nodes that will be the members of the list
public Model add(Statement s)
s
- The statement to be added.
public Model add(Statement[] statements)
statements
- the array of statements to add
public Model remove(Statement[] statements)
statements
- the array of statements to be added
public Model add(java.util.List statements)
statements
- a List of Statements
public Model remove(java.util.List statements)
statements
- a List of Statements to remove
public Model add(StmtIterator iter)
iter
- An iterator which returns the statements to be added.
public Model add(Model m)
m
- The model whose statements are to be added.
public Model read(java.lang.String url)
See Model
for a description of how to traverse a firewall.
url
- of the document containing the RDF statements.
public Model read(java.io.InputStream in, java.lang.String base)
in
- the source of the RDF/XMLbase
- the base to use when converting relative to absolute uri's.
The base URI may be null if there are no relative URIs to convert.
A base URI of "" may permit relative URIs to be used in the
model unconverted.
public Model read(java.io.InputStream in, java.lang.String base, java.lang.String lang)
lang
to the model.
lang
are "RDF/XML", "N-TRIPLE"
and "N3". null
represents the default language, "RDF/XML".
"RDF/XML-ABBREV" is a synonym for "RDF/XML".
base
- the base uri to be used when converting relative
URI's to absolute URI's.
The base URI may be null if there are no relative URIs to
convert.
A base URI of "" may permit relative URIs to be used in the
model.lang
- the langauge of the serialization null
selects the defaultin
- the source of the input serialization
- Returns:
- this model
public Model read(java.io.Reader reader, java.lang.String base)
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.
reader
- the source of the RDF/XMLbase
- the base to use when converting relative to absolute uri's.
The base URI may be null if there are no relative URIs to
convert.
A base URI of "" may permit relative URIs to be used in the
model.
* @return the current modelpublic Model read(java.lang.String url, java.lang.String lang)
lang
to the
model.
lang
are "RDF/XML", "N-TRIPLE"
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.
url
- a string representation of the url to read fromlang
- the language of the serialization
public Model read(java.io.Reader reader, java.lang.String base, java.lang.String lang)
lang
to the model.
lang
are "RDF/XML", "N-TRIPLE"
and "N3". null
represents the default language, "RDF/XML".
"RDF/XML-ABBREV" is a synonym for "RDF/XML".
read(InputStream,String)
, otherwise there is a danger of a
mismatch between the character encoding of say the FileReader and the
character encoding of the data in the file.
base
- the base uri to be used when converting relative
URI's to absolute URI's.
The base URI may be null if there are no relative URIs to
convert.
A base URI of "" may permit relative URIs to be used in the
model.lang
- the langauge of the serialization null
selects the defaultreader
- the source of the input serialization
- Returns:
- this model
public Model write(java.io.Writer writer)
Write the model as an XML document. It is often better to use an OutputStream rather than a Writer, since this will avoid character encoding errors.
writer
- A writer to which the XML will be written
public Model write(java.io.Writer writer, java.lang.String lang)
Write a serialized represention 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" and "N3". The default value,
represented by null
is "RDF/XML".
writer
- The output writerlang
- The output language
public Model write(java.io.Writer writer, java.lang.String lang, java.lang.String base)
Write a serialized represention 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" and "N3". The default value,
represented by null
, is "RDF/XML".
writer
- The output writerbase
- The base uri for relative URI calculations.
null
means use only absolute URI's.lang
- The language in which the RDF should be written
public Model write(java.io.OutputStream out)
Write a serialization of this model as an XML document.
The language in which to write the model is specified by the
lang
argument. Predefined values are "RDF/XML",
"RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value is
represented by null
is "RDF/XML".
out
- The output stream to which the XML will be written
public Model write(java.io.OutputStream out, java.lang.String lang)
Write a serialized represention 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" and "N3". The default value,
represented by null
, is "RDF/XML".
out
- The output stream to which the RDF is writtenlang
- The output langauge
public Model write(java.io.OutputStream out, java.lang.String lang, java.lang.String base)
Write a serialized represention 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" and "N3". The default value,
represented by null
, is "RDF/XML".
out
- The output stream to which the RDF is writtenbase
- The base uri to use when writing relative URI's. null
means use only absolute URI's.lang
- The language in which the RDF should be written
public Model remove(Statement s)
The statement with the same subject, predicate and object as that supplied will be removed from the model.
s
- The statement to be removed.
public Statement getProperty(Resource s, Property p)
If more than one statement witht the given subject and property exists in the model, it is undefined which will be returned.
s
- The subject of the statement to be returned.p
- The property of the statement to be returned.
public ResIterator listSubjectsWithProperty(Property p)
p
- the property sought.
public ResIterator listSubjectsWithProperty(Property p, RDFNode o)
p
- The predicate soughto
- The value sought
public NodeIterator listObjects()
public NodeIterator listObjectsOfProperty(Property p)
p
- The predicate sought
public NodeIterator listObjectsOfProperty(Resource s, Property p)
p
- The predicate sought
public boolean contains(Resource s, Property p)
s
- The subject sought.p
- The predicate sought.
public boolean containsResource(RDFNode r)
r
- the RDFNode to be searched for
public boolean contains(Resource s, Property p, RDFNode o)
s
- The subject of the statment tested.p
- The predicate of the statement tested.o
- The object of the statement tested.
public boolean contains(Statement s)
s
- The statement tested.
public boolean containsAny(StmtIterator iter)
iter
- an iterator of the statements to be tested
public boolean containsAll(StmtIterator iter)
iter
- an iterator of the statements to be tested
public boolean containsAny(Model model)
model
- the model containing the statements to be tested
public boolean containsAll(Model model)
model
- the model containing the statements to be tested
public boolean isReified(Statement s)
s
- The statement tested.
public Resource getAnyReifiedStatement(Statement s)
ReifiedStatement
corresponding to a Statement.
s
- Statement which may or may not already be reified
public void removeAllReifications(Statement s)
public void removeReification(ReifiedStatement rs)
public StmtIterator listStatements()
Subsequent operations on those statements may modify this model.
public StmtIterator listStatements(Selector s)
A statment is considered to match if the test
method
of s returns true when called on s.
s
- A selector object.
.
public StmtIterator listStatements(Resource s, Property p, RDFNode o)
Return an iterator over all the statements in a model
that match a pattern. The statements selected are those
whose subject matches the subject
argument,
whose predicate matches the predicate
argument
and whose object matches the object
argument.
If an argument is null
it matches anything.
s
- The subject soughtp
- The predicate soughto
- The value sought
public ReifiedStatement createReifiedStatement(Statement s)
public ReifiedStatement createReifiedStatement(java.lang.String uri, Statement s)
public RSIterator listReifiedStatements()
public RSIterator listReifiedStatements(Statement st)
public Model query(Selector s)
A statment is considered to match if the test
method
of s returns true when called on s.
s
- A selector object.
.
public Model union(Model model)
model
- The other model whose statements are to be included.
public Model intersection(Model model)
model
- The other model.
public Model difference(Model model)
model
- the other model whose statements are to be excluded.
public boolean equals(java.lang.Object model)
model
- the model to be compared
public Model begin()
All changes made to a model within a transaction, will either be made, or none of them will be made.
public Model abort()
public Model commit()
public java.lang.Object executeInTransaction(com.hp.hpl.jena.shared.Command cmd)
cmd
inside a transaction. If it
completes, commit the transaction and return the result; if it fails
(by throwing an exception), abort the transaction and throw an
exception.
public boolean independent()
For efficiency reasons, some implementations may create models which which are dependent on others, i.e. a change in one model may cause a change in another. If this is the case this method will return false, otherwise it will return true.
public boolean supportsTransactions()
public boolean supportsSetOperations()
public boolean isIsomorphicWith(Model g)
Two models are isomorphic when each statement in one can be matched with a statement in the other. Statements which are identical match.
Special treatment is given to anonymous nodes. A binding is a one to
one mapping which maps each anonymous node in this
model to
an anonymous node in model
. Two statements s1 and s2 match
under a binding if if s1.subject is anonymous and s2.subject is anonymous
and the binding maps s1.subject to s2.subject.
Two models are isomorphic if there is a binding that allows all the statements in one model to match a a statement in the other.
g
- Compare against this.
public void close()
Not all implementations of Model require this method to be called. But some do, so in general its best to call it when done with the object, rather than leave it to the finalizer.
public ModelLock getModelLock()
ModelLock
public Model register(ModelChangedListener listener)
The same listener may be registered many times; if so, it's methods will be called as many times as it's registered for each event.
ModelChangedListener
public Model unregister(ModelChangedListener listener)
ModelChangedListener
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |