Reification in RDF and Jena is the ability to treat a
Resource, and hence to make assertions about that
statement. A statement may be reified as many different
resources, allowing different manifestations ("statings") of
that statement to be treated differently if required.
RDF represents a reified statement as four statements with
particular RDF properties and objects: the statement
(S, P, O), reified by resource
R, is represented by:
R rdf:type rdf:Statement
R rdf:subject S
R rdf:predicate P
R rdf:object O
We shall call these four such statements a reification quad
and the components quadlets. Users of reification in Jena
may, by default, simply manipulate reified statements as these quads.
However, just as for
RDF lists in ordinary models,
or ontology classes and individuals in
Jena has additional support for manipulating reified statements.
It also optimises the storage for complete reification quads,
avoiding having to store the extra four statements merely to
represent one reification.
ReifiedStatement is used to represent
a reified statement as a Jena
Resource that has direct access to
the statement it reifies. The method
Statementthat the resource is reifying. All the other
Resourcemethods, of course, may be applied to a
Ris associated with a reified statement, but might not itself be a
ReifiedStatementobject, the conversion method
RDFNode::as(Class)can be used to find (or create) a
If there is no such associated reified statement,
CannotReifyException is thrown. To find out in
advance if the conversion is possible, use the predicate
only counts as "an associated reified statement" a resource
with exactly one
rdf:object which has
It can of course have other properties.)
ReifiedStatement has been constructed,
it retains its
Statement even if some (or all)
of the original quadlets are removed from the model. This is
a feature of the current implementation that might go away; do
not rely on it.
Statementis reified. The methods
Model::isreified(Statement)return true if (and only if) the statement has been reified in the model. Note that the
Statementmethod tests to see if the statement is reified in its own model, and the model method tests to see if the
Statementis reified in that model; there is no test to see if a
Statementis reified in any other models.
listStatementsis used to find the statements present in some model, there are methods for finding the reified statements of a model. Each of them returns a
RSIteratorobject, which is an iterator each of who's elements are
ReifiedStatements and for which the convenience method
nextRS()will deliver a suitably-cast reified statement.
Statement::listReifiedStatements()- all the reifications of this statement in its model.
Model::listReifiedStatements()- all the reified statements in this model.
Model::listReifiedStatements(Statement s)- all the reified statements reifiying
sin this model.
Model; they can be created directly from their
Statements using one of the methods:
getStatement()method delivers the original statement (actually, a
.equals()statement; it may not be the identical statement). If the creation method passed in a (non-null)
ReifiedStatementis a named resource and that string is its URI. Otherwise it is a newly-minted bnode. The methods on
Statementcreate a reified statement in that statements model; those on
Modelcreate a reified statement in that model.
It is not permitted for two different (non-equals) statements
to be reified onto the same resource. An attempt to do so will
The additional method
returns some reification of the supplied
existing one if possible, otherwise a fresh one (reified by a
true, then the reified statements are not copied. (This choice arose from comments on earlier versions of the Jena 2 API; users expected the reified statements to be copied.)
Model::add(Model), the method
model.remove(Model m)will remove all the reified statements of
model, and the two-argument form
ReifiedStatements. Similarly, explicitly created
ReifiedStatements are visible as statement quads.
Sometimes this is not desirable. For example, in an application
that reifies large numbers of statements in the same model as those
statements, most of the results from
will be quadlets; this is inefficient and confusing. One choice is
to reify the statements in a different model. Another is
to take advantage of reification styles.
Each model has a reification style, described by constants in
ModelFactory. The default style is called
Standard because it behaves mostly closely to
the RDF standard. There are two other reification styles to choose
Convenient: reification quadlets are not visible in the results of
listStatements)(). Otherwise everything is normal; quadlets that are added to the model contribute to
Minimal: reification quadlets play no role at all in the construction of
ReifiedStatements, which can only be created by the methods discussed earlier. This style is most similar to that of Jena 1.
ModelFactory.createDefaultModel()takes an optional
Styleargument, which defaults to
Stylearguments which are applied to every model they create.
To take a model with hidden reification quads and expose them as
statements, the method
produces a new model which does just that.