Source for file Statement.php
Documentation is available at Statement.php
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
* In this implementation, a statement is not itself a resource.
* If you want to use a a statement as subject or object of other statements,
* you have to reify it first.
* @author Chris Bizer <chris@bizer.de>
* @version $Id: fsource_model__modelStatement.php.html 443 2007-06-01 16:25:38Z cax $
* Subject of the statement
* Predicate of the statement
* Object of the statement
* The parameters to constructor are instances of classes and not just strings
* @param object node $subj
* @param object node $pred
* @param object node $obj
if (!is_a($subj, 'Resource')) {
'(class: Statement; method: new): Resource expected as subject.';
if (!is_a($pred, 'Resource') ||
is_a($pred, 'BlankNode')) {
'(class: Statement; method: new): Resource expected as predicate, no blank node allowed.';
if (!(is_a($obj, 'Resource') or is_a($obj, 'Literal'))) {
'(class: Statement; method: new): Resource or Literal expected as object.';
* Returns the subject of the triple.
* Returns the predicate of the triple.
* Returns the object of the triple.
* Alias for getPredicate()
* Retruns the hash code of the triple.
return md5($this->subj->getLabel() .
$this->pred->getLabel() .
$this->obj->getLabel());
return 'Triple(' .
$this->subj->toString() .
', ' .
$this->pred->toString() .
', ' .
$this->obj->toString() .
')';
* Returns a toString() serialization of the statements's subject.
return $this->subj->toString();
* Returns a toString() serialization of the statements's predicate.
return $this->pred->toString();
* Reurns a toString() serialization of the statements's object.
return $this->obj->toString();
* Returns the URI or bNode identifier of the statements's subject.
return $this->subj->getLabel();
* Returns the URI of the statements's predicate.
return $this->pred->getLabel();
* Reurns the URI, text or bNode identifier of the statements's object.
return $this->obj->getLabel();
* Checks if two statements are equal.
* Two statements are considered to be equal if they have the
* same subject, predicate and object. A statement can only be equal
* to another statement object.
* @param object statement $that
if ($that ==
NULL ||
!(is_a($that, 'Statement'))) {
$this->subj->equals($that->subject()) &&
$this->pred->equals($that->predicate()) &&
$this->obj->equals($that->object());
* Compares two statements and returns integer less than, equal to, or greater than zero.
* Can be used for writing sorting function for models or with the PHP function usort().
* @param object statement &$that
return statementsorter($this, $that);
// statementsorter function see below
* Returns a new MemModel that is the reification of the statement.
* For naming the statement's bNode a Model or bNodeID must be passed to the method.
* @param mixed &$model_or_bNodeID
function & reify(&$model_or_bNodeID) {
if (is_a($model_or_bNodeID, 'MemModel')) {
$statementModel =
new MemModel($model_or_bNodeID->getBaseURI());
$thisStatement =
new BlankNode($model_or_bNodeID);
$thisStatement =
&$model_or_bNodeID;
$statementModel->add(new Statement($thisStatement, $RDFtype, $RDFstatement));
$statementModel->add(new Statement($thisStatement, $RDFobject, $this->Object()));
* Comparison function for comparing two statements.
* statementsorter() is used by the PHP function usort ( array array, callback cmp_function)
* @param object Statement $a
* @param object Statement $b
* @return integer less than, equal to, or greater than zero
function statementsorter($a,$b) {
$r=
strcmp($x->getLabel(),$y->getLabel());
$r=
strcmp($x->getURI(),$y->getURI());
//Final resort, compare objects
Documentation generated on Fri, 1 Jun 2007 16:52:28 +0200 by phpDocumentor 1.3.2