/** * Get the statement's object. * * @return LibRDF_Node The statement's object * @access public */ public function getObject() { $node = librdf_statement_get_object($this->statement); $object = LibRDF_Node::makeNode(librdf_new_node_from_node($node)); return $object; }
/** * Return the current node or NULL if the iterator is no longer valid. * * @return LibRDF_Statement The current node on the iterator * @access public */ public function current() { if ($this->isvalid and !librdf_iterator_end($this->iterator)) { // the pointer returned is overwritten when the iterator is // advanced or closed, so make a copy of the node $ret = librdf_iterator_get_object($this->iterator); if ($ret) { return LibRDF_Node::makeNode(librdf_new_node_from_node($ret)); } else { throw new LibRDF_Error("Unable to get current node"); } } else { return NULL; } }
/** * Return a single target node that is part of a statement containing the * given source and predicate. * * This function is equivalent to * <code>$model->findStatements($source, $predicate, NULL)->current()->getTarget()</code> * * @param LibRDF_Node $source The source node for which to search * @param LibRDF_Node $arc The predicate node for which to search * @return LibRDF_Node A node that matches the criteria * @throws LibRDF_LookupError If no statement with the given source and predicate is found * @access public */ public function getTarget(LibRDF_Node $source, LibRDF_Node $arc) { $target = librdf_model_get_target($this->model, $source->getNode(), $arc->getNode()); if ($target) { return LibRDF_Node::makeNode($target); } else { throw new LibRDF_LookupError("No such statement"); } }
/** * Return the current tuple of bindings. * * The result is an associative array using the binding names as the * indices. * * @return array The current bindings tuple * @throws LibRDF_Error If unable to get the current bindings tuple * @access public */ public function current() { if ($this->isvalid and !librdf_query_results_finished($this->query_results)) { $retarr = array(); $numbindings = librdf_query_results_get_bindings_count($this->query_results); if ($numbindings < 0) { throw new LibRDF_Error("Unable to get number of bindings in result"); } for ($i = 0; $i < $numbindings; $i++) { $key = librdf_query_results_get_binding_name($this->query_results, $i); $value = librdf_query_results_get_binding_value($this->query_results, $i); if (!$key or !$value) { throw new LibRDF_Error("Failed to get current binding {$i}"); } $retarr[$key] = LibRDF_Node::makeNode(librdf_new_node_from_node($value)); } return $retarr; } else { return NULL; } }