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>
* Subject of the statement
* Predicate of the statement
* Object of the statement
* The parameters are instances of classes and not just strings
* @param object node $subj
* @param object node $pred
* @param object node $obj
function factory($subj, $pred, $obj)
$return = $statement->setSubject ($subj);
if (PEAR ::isError ($return)) {
$return = $statement->setPredicate ($pred);
if (PEAR ::isError ($return)) {
$return = $statement->setObject ($obj);
if (PEAR ::isError ($return)) {
* Set the subject of the triple.
if (!is_a($subj, 'RDF_Resource')) {
$errmsg = 'Resource expected as subject, got unexpected: '.
* Returns the subject of the triple.
* Set the predicate of the triple.
if (!is_a($pred, 'RDF_Resource') || is_a($pred, 'RDF_BlankNode')) {
$errmsg = 'Resource expected as predicate, no blank node allowed, got unexpected: '.
* Returns the predicate of the triple.
* Set the object of the triple.
if (!(is_a($obj, 'RDF_Resource') or is_a($obj, 'RDF_Literal'))) {
$errmsg = 'Resource or Literal expected as object, got unexpected: '.
* Returns the object of the triple.
* 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, 'RDF_Statement'))) {
$result = $this->subj->equals ($that->getSubject ());
if (PEAR ::isError ($result)) {
$result = $this->pred->equals ($that->getPredicate ());
if (PEAR ::isError ($result)) {
$result = $this->obj->equals ($that->getObject ());
if (PEAR ::isError ($result)) {
* 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 &$compare_with
// statementsorter function see below
* Returns a new Model_Memory 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, 'RDF_Model_Memory')) {
if (PEAR ::isError ($thisStatement)) {
if (PEAR ::isError ($RDFstatement)) {
if (PEAR ::isError ($RDFtype)) {
if (PEAR ::isError ($RDFsubject)) {
if (PEAR ::isError ($RDFpredicate)) {
if (PEAR ::isError ($RDFobject )) {
if (PEAR ::isError ($statement)) {
$result = $statementModel->add ($statement);
if (PEAR ::isError ($result)) {
if (PEAR ::isError ($statement)) {
$result = $statementModel->add ($statement);
if (PEAR ::isError ($result)) {
if (PEAR ::isError ($statement)) {
$result = $statementModel->add ($statement);
if (PEAR ::isError ($result)) {
if (PEAR ::isError ($statement)) {
$result = $statementModel->add ($statement);
if (PEAR ::isError ($result)) {
* Comparison function for comparing two statements.
* RDF_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
$r = strcmp($x->getLabel (), $y->getLabel ());
$r = strcmp($x->getURI (), $y->getURI ());
// Final resort, compare objects
Documentation generated on Mon, 11 Mar 2019 15:39:30 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|