/** * 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 target nodes that are part of a statement containing the * given source and predicate. * * @param LibRDF_Node $source The source node for which to search * @param LibRDF_Node $arc The predicate node for which to search * @return LibRDF_Iterator An iterator for nodes that matches the criteria * @throws LibRDF_LookupError If no statement with the given source and predicate is found * @access public */ public function getTargets(LibRDF_Node $source, LibRDF_Node $arc) { $targets = librdf_model_get_targets($this->model, $source->getNode(), $arc->getNode()); if ($targets) { return new LibRDF_Iterator($targets, $this); } else { throw new LibRDF_Error("Failed to create iterator"); } }
/** * 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; } }