com.hp.hpl.jena.rdf.model
Interface Model

All Superinterfaces:
ModelCon, ModelLock, com.hp.hpl.jena.shared.PrefixMapping, RDFReaderF, RDFWriterF
All Known Subinterfaces:
InfModel, OntModel
All Known Implementing Classes:
com.hp.hpl.jena.rdf.model.impl.ModelCom, ModelRDB

public interface Model
extends ModelCon, RDFReaderF, RDFWriterF, com.hp.hpl.jena.shared.PrefixMapping, ModelLock

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.

System Properties

Firewalls and Proxies

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);
 

Version:
$Name: $ $Revision: 1.30 $Date: 2003/07/15 14:44:17 $'
Author:
bwm

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.ModelCon
add, add, add, add, add, add, add, add, add, add, add, contains, contains, contains, contains, contains, contains, contains, contains, createAlt, createAlt, createBag, createBag, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createLiteral, createProperty, createResource, createResource, createResource, createResource, createSeq, createSeq, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createStatement, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, createTypedLiteral, getAlt, getAlt, getBag, getBag, getProperty, getRDFNode, getResource, getSeq, getSeq, listStatements, listStatements, listStatements, listStatements, listStatements, listStatements, listStatements, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, listSubjectsWithProperty, remove, remove
 
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

getGraph

public Graph getGraph()
Every model is based on some Graph


queryHandler

public QueryHandler queryHandler()
Every Model has a QueryHandler


size

public long size()
(Unwise) Computes the number of statements in the model. Many implementations cannot do this efficiently.

Returns:
the number of statements in the model

isEmpty

public boolean isEmpty()
Answer true iff the model contains no explicit statements (ie it's size is zero, listStatements() would deliver the empty iterator).

Returns:
true iff the model contains no explicit statements.

listSubjects

public ResIterator listSubjects()
List all resources which are subjects of statements.

Subsequent operations on those resource may modify this model.

Returns:
an iterator over a set of resources which are subjects of statements in the model.

listNameSpaces

public NsIterator listNameSpaces()
List all namespaces of predicates in the model.

Returns:
an iterator over the set of namespaces associated with predicates in the model.

queryBindingsWith

public ExtendedIterator queryBindingsWith(Model query,
                                          Resource[] variables)
Answer an iterator over all the bindings implied by the query model. TODO complete this explanation.


getResource

public Resource getResource(java.lang.String uri)
Return a Resource instance in this model.

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.

Parameters:
uri - the URI of the resource .
Returns:
a resource instance

getProperty

public Property getProperty(java.lang.String nameSpace,
                            java.lang.String localName)
Return a Property instance in this model.

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.

Parameters:
nameSpace - the RDF namespace of the property
localName - the localName of the property in its namespace
Returns:
a property linked to this model

createResource

public Resource createResource()
Create a new anonymous resource.

Subsequent operations on the returned resource may modify this model.

.

Returns:
a new anonymous resource linked to this model.

createResource

public Resource createResource(AnonId id)
create a blank node resource with a specified identifier/

Parameters:
id - the identifier to use for this blank node
Returns:
a blank node with that identifier

createResource

public Resource createResource(java.lang.String uri)
Create a new resource.

Subsequent operations on the returned resource may modify this model.

Parameters:
uri - the URI of the resource to be created .
Returns:
a new resource linked to this model.

createProperty

public Property createProperty(java.lang.String nameSpace,
                               java.lang.String localName)
Create a property.

Subsequent operations on the returned property may modify this model.

Parameters:
nameSpace - the nameSpace of the property
localName - the name of the property within its namespace
Returns:
a property instance

createLiteral

public Literal createLiteral(java.lang.String v,
                             java.lang.String language)
Create a literal from a String value with a specified language.

If v is null, then a literal with an empty string is created.

Parameters:
v - the value of the literal
language - the language associated with the literal
Returns:
a new literal representing the value v with the given language

createLiteral

public Literal createLiteral(java.lang.String v,
                             java.lang.String language,
                             boolean wellFormed)
Create a literal from a String value with a specified language.

If v is null, then a literal with an empty string is created.

Parameters:
v - the value of the literal
language - the language associated with the literal
wellFormed - true if the Literal is well formed XML
Returns:
a new literal representing the value v with the given language

createTypedLiteral

public Literal createTypedLiteral(java.lang.String lex,
                                  java.lang.String lang,
                                  RDFDatatype dtype)
Build a typed literal from its lexical form. The lexical form will be parsed now and the value stored. If the form is not legal this will throw an exception.

Parameters:
lex - the lexical form of the literal
lang - the optional language tag
dtype - the type of the literal, null for old style "plain" literals
Throws:
DatatypeFormatException - if lex is not a legal form of dtype

createTypedLiteral

public Literal createTypedLiteral(java.lang.Object value,
                                  java.lang.String lang,
                                  RDFDatatype dtype)
Build a typed literal from its value form.

Parameters:
value - the value of the literal
lang - the optional language tag
dtype - the type of the literal, null for old style "plain" literals

createTypedLiteral

public Literal createTypedLiteral(java.lang.Object value)
Build a typed literal label from its value form using whatever datatype is currently registered as the the default representation for this java class. No language tag is supplied.

Specified by:
createTypedLiteral in interface ModelCon
Parameters:
value - the literal value to encapsulate
Returns:
a new literal representing the value v

createStatement

public Statement createStatement(Resource s,
                                 Property p,
                                 RDFNode o)
Create a Statement instance.

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.

Parameters:
s - the subject of the statement
p - the predicate of the statement
o - the object of the statement
Returns:
the new statement

createList

public RDFList createList()

Answer a new empty list. This is equivalent to a list consisting only of rdf:nil.

Returns:
An RDF-encoded list of no elements

createList

public RDFList createList(java.util.Iterator members)

Answer a new list containing the resources from the given iterator, in order.

Parameters:
members - An iterator, each value of which is expected to be an RDFNode
Returns:
An RDF-encoded list of the elements of the iterator

createList

public RDFList createList(RDFNode[] members)

Answer a new list containing the nodes from the given array, in order

Parameters:
members - An array of RDF nodes that will be the members of the list
Returns:
An RDF-encoded list

add

public Model add(Statement s)
Add a statement to this model.

Parameters:
s - The statement to be added.
Returns:
This model.

add

public Model add(Statement[] statements)
Add all the statements to the Model, using through the bulk update interface.

Parameters:
statements - the array of statements to add
Returns:
this model, to allow cascading

remove

public Model remove(Statement[] statements)
Remove all the statements from the Model, using the bulk update interface.

Parameters:
statements - the array of statements to be added
Returns:
this model, to allow cascading

add

public 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).

Parameters:
statements - a List of Statements
Returns:
this model, to allow cascading

remove

public Model remove(java.util.List statements)
Remove all the statements in the list from this model, using the bulk update interface.

Parameters:
statements - a List of Statements to remove
Returns:
this model, to allow cascading

add

public Model add(StmtIterator iter)
Add all the statements returned by an iterator to this model.

Parameters:
iter - An iterator which returns the statements to be added.
Returns:
this model

add

public Model add(Model m)
Add all the statements in another model to this model.

Parameters:
m - The model whose statements are to be added.
Returns:
this model

read

public Model read(java.lang.String url)
Add the RDF statements from an XML document.

See Model for a description of how to traverse a firewall.

Parameters:
url - of the document containing the RDF statements.
Returns:
this model

read

public Model read(java.io.InputStream in,
                  java.lang.String base)
Add statements from an RDF/XML serialization.

Parameters:
in - the source of the RDF/XML
base - 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.
Returns:
the current model

read

public Model read(java.io.InputStream in,
                  java.lang.String base,
                  java.lang.String lang)
Add RDF statements represented in language lang to the model.
Predefined values for lang are "RDF/XML", "N-TRIPLE" and "N3". null represents the default language, "RDF/XML". "RDF/XML-ABBREV" is a synonym for "RDF/XML".

Parameters:
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 default
in - the source of the input serialization
Returns:
this model

read

public Model read(java.io.Reader reader,
                  java.lang.String base)
Using this method is often a mistake. Add statements from an RDF/XML serialization. It is generally better to use an InputStream if possible. 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.

Parameters:
reader - the source of the RDF/XML
base - 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 model

read

public Model read(java.lang.String url,
                  java.lang.String lang)
Add statements from a serializion in language lang to the model.
Predefined values for 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.

Parameters:
url - a string representation of the url to read from
lang - the language of the serialization
Returns:
this model

read

public Model read(java.io.Reader reader,
                  java.lang.String base,
                  java.lang.String lang)
Using this method is often a mistake. Add RDF statements represented in language lang to the model.
Predefined values for lang are "RDF/XML", "N-TRIPLE" and "N3". null represents the default language, "RDF/XML". "RDF/XML-ABBREV" is a synonym for "RDF/XML".
It is generally better to use an InputStream if possible. 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.

Parameters:
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 default
reader - the source of the input serialization
Returns:
this model

write

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.

Parameters:
writer - A writer to which the XML will be written
Returns:
this model

write

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".

Parameters:
writer - The output writer
lang - The output language
Returns:
this model

write

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".

Parameters:
writer - The output writer
base - The base uri for relative URI calculations. null means use only absolute URI's.
lang - The language in which the RDF should be written
Returns:
this model

write

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".

Parameters:
out - The output stream to which the XML will be written
Returns:
This model

write

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".

Parameters:
out - The output stream to which the RDF is written
lang - The output langauge
Returns:
This model

write

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".

Parameters:
out - The output stream to which the RDF is written
base - 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
Returns:
This model

remove

public Model remove(Statement s)
Removes a statement.

The statement with the same subject, predicate and object as that supplied will be removed from the model.

Parameters:
s - The statement to be removed.
Returns:
this model

getProperty

public Statement getProperty(Resource s,
                             Property p)
Return a statement with given subject and property.

If more than one statement witht the given subject and property exists in the model, it is undefined which will be returned.

Parameters:
s - The subject of the statement to be returned.
p - The property of the statement to be returned.
Returns:
A statement from the model with the given subject and property.

listSubjectsWithProperty

public ResIterator listSubjectsWithProperty(Property p)
List all subjects with a given property.

Parameters:
p - the property sought.
Returns:
an iterator over the subjects

listSubjectsWithProperty

public ResIterator listSubjectsWithProperty(Property p,
                                            RDFNode o)
List all subjects with a given property and property value

Parameters:
p - The predicate sought
o - The value sought
Returns:
an iterator over the subjects

listObjects

public NodeIterator listObjects()
List all objects in a model.

Returns:
an iterator over the objects

listObjectsOfProperty

public NodeIterator listObjectsOfProperty(Property p)
List all objects of a given property.

Parameters:
p - The predicate sought
Returns:
an iterator over the objects

listObjectsOfProperty

public NodeIterator listObjectsOfProperty(Resource s,
                                          Property p)
List the values of a property of a resource.

Parameters:
p - The predicate sought
Returns:
an iterator over the objects

contains

public boolean contains(Resource s,
                        Property p)
Determine whether this model contains any statements with a given subject and property.

Parameters:
s - The subject sought.
p - The predicate sought.
Returns:
true if there exists within this model a statement with subject s and property p, false otherwise

containsResource

public boolean containsResource(RDFNode r)
determine if the RDFNode r appears in any statement of this model. (containsRDFNode is a horrible name, and in any case, even literals will be resources one day)

Parameters:
r - the RDFNode to be searched for
Returns:
true iff r appears as some subject, predicate, or object

contains

public boolean contains(Resource s,
                        Property p,
                        RDFNode o)
Determine if a statement is present in this model.

Parameters:
s - The subject of the statment tested.
p - The predicate of the statement tested.
o - The object of the statement tested.
Returns:
true if the statement with subject s, property p and object o is in the model, false otherwise

contains

public boolean contains(Statement s)
Determine if a statement is present in this model.

Parameters:
s - The statement tested.
Returns:
true if the statement s is in this model, false otherwise

containsAny

public boolean containsAny(StmtIterator iter)
Determine if any of the statements returned by an iterator are contained in this model.

Parameters:
iter - an iterator of the statements to be tested
Returns:
true if any of the statements returns by iter are contained in this model and false otherwise.

containsAll

public boolean containsAll(StmtIterator iter)
Determine if all of the statements returned by an iterator are contained in this model.

Parameters:
iter - an iterator of the statements to be tested
Returns:
true if any of the statements returns by iter are contained in this model and false otherwise.

containsAny

public boolean containsAny(Model model)
Determine if any of the statements in a model are also contained in this model.

Parameters:
model - the model containing the statements to be tested
Returns:
true if any of the statements in model are also contained in this model and false otherwise.

containsAll

public boolean containsAll(Model model)
Determine if all of the statements in a model are also contained in this model.

Parameters:
model - the model containing the statements to be tested
Returns:
true if all of the statements in model are also contained in this model and false otherwise.

isReified

public boolean isReified(Statement s)
Determine if this Statement has been reified in this Model.

Parameters:
s - The statement tested.
Returns:
true iff a ReifiedStatement(s) has been created in this model

getAnyReifiedStatement

public Resource getAnyReifiedStatement(Statement s)
Find or create a ReifiedStatement corresponding to a Statement.

Parameters:
s - Statement which may or may not already be reified
Returns:
a Resource [ReifiedStatement] that reifies the specified Statement.

removeAllReifications

public void removeAllReifications(Statement s)
Remove all reifications (ie implicit reification quads) of _s_.


removeReification

public void removeReification(ReifiedStatement rs)
Remove a particular reificiation.


listStatements

public StmtIterator listStatements()
List all statements.

Subsequent operations on those statements may modify this model.

Returns:
an iterator over all statements in the model.

listStatements

public StmtIterator listStatements(Selector s)
List the statements matching a selector.

A statment is considered to match if the test method of s returns true when called on s.

Parameters:
s - A selector object. .
Returns:
an iterator over the matching statements

listStatements

public StmtIterator listStatements(Resource s,
                                   Property p,
                                   RDFNode o)
Find all the statements matching a pattern.

Return an iterator over all the statements in a model that match a pattern. The statements selected are those whose subject matches the subject argument, whose predicate matches the predicate argument and whose object matches the object argument. If an argument is null it matches anything.

Parameters:
s - The subject sought
p - The predicate sought
o - The value sought
Returns:
an iterator over the subjects

createReifiedStatement

public ReifiedStatement createReifiedStatement(Statement s)
Answer a ReifiedStatement that encodes _s_ and belongs to this Model.
result.getModel() == this
result.getStatement() .equals ( s )


createReifiedStatement

public 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_.


listReifiedStatements

public RSIterator listReifiedStatements()
answer an iterator delivering all the reified statements "in" this model


listReifiedStatements

public RSIterator listReifiedStatements(Statement st)
answer an iterator delivering all the reified statements "in" this model that match the statement _st_.


query

public Model query(Selector s)
Create a new model containing the statements matching a query.

A statment is considered to match if the test method of s returns true when called on s.

Parameters:
s - A selector object. .
Returns:
an iterator over the matching statements

union

public Model union(Model model)
Create a new model containing all the statements in this model together with all of those in another given model.

Parameters:
model - The other model whose statements are to be included.
Returns:
A new model containing all the statements that are in either model

intersection

public Model intersection(Model model)
Create a new model containing all the statements which are in both this model and another. As models are sets of statements, a statement contained in both models will only appear once in the resulting model.

Parameters:
model - The other model.
Returns:
A new model containing all the statements that are in both models.

difference

public Model difference(Model model)
Create a new model containing all the statements in this model which are not in another.

Parameters:
model - the other model whose statements are to be excluded.
Returns:
a new model containing all the statements in this model that are not in the given model.

equals

public boolean equals(java.lang.Object model)
Test whether one model is the equal to another. Two Models are equal iff the underlying graphs are identical Java objects.

Parameters:
model - the model to be compared
Returns:
true if the models are equal

begin

public Model begin()
Begin a new transation.

All changes made to a model within a transaction, will either be made, or none of them will be made.

Returns:
this model to enable cascading.

abort

public Model abort()
Abort the current transaction and abandon any changes in progress.

Returns:
this model to enable cascading.

commit

public Model commit()
Commit the current transaction.

Returns:
this model to enable cascading.

executeInTransaction

public java.lang.Object executeInTransaction(com.hp.hpl.jena.shared.Command cmd)
Execute the command 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.


independent

public boolean independent()
Determine whether this model is independent.

For efficiency reasons, some implementations may create models which which are dependent on others, i.e. a change in one model may cause a change in another. If this is the case this method will return false, otherwise it will return true.

Returns:
true if this model is indepdent of others

supportsTransactions

public boolean supportsTransactions()
Determine whether this model supports transactions.

Returns:
true if this model supports transactions.

supportsSetOperations

public boolean supportsSetOperations()
Determine whether this model supports set operations.

Returns:
true if this model supports set operations.

isIsomorphicWith

public boolean isIsomorphicWith(Model g)
Compare this Model with another for equality ignoring the labels on bNodes. See RDF Concepts.

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.

Parameters:
g - Compare against this.
Returns:
boolean True if the two RDF graphs are isomorphic.

close

public void close()
Close the Model and free up resources held.

Not all implementations of Model require this method to be called. But some do, so in general its best to call it when done with the object, rather than leave it to the finalizer.


getModelLock

public ModelLock getModelLock()
Get the model lock for this model. See also the convenience operations enterCriticalSection and leaveCriticalSection.

Returns:
The ModelLock object associated with this model
See Also:
ModelLock

register

public Model register(ModelChangedListener listener)
Register a listener for model-changed events on this model. The methods on the listener will be called when API add/remove calls on the model succeed [in whole or in part].

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.

Returns:
this model, for cascading
See Also:
ModelChangedListener

unregister

public Model unregister(ModelChangedListener listener)
Unregister a listener from model-changed events on this model. The listener is dtached from the model. The model is returned to permit cascading. If the listener is not attached to the model, then nothing happens.

Returns:
this model, for cascading
See Also:
ModelChangedListener


Copyright © 2001-2003 Hewlett-Packard. All Rights Reserved.