[moriarty] r327 committed - added support for getting rdf list values back

0 views
Skip to first unread message

mori...@googlecode.com

unread,
Dec 1, 2011, 3:17:09 PM12/1/11
to moriarty...@googlegroups.com
Revision: 327
Author: mmmmmrob
Date: Thu Dec 1 12:16:52 2011
Log: added support for getting rdf list values back
http://code.google.com/p/moriarty/source/detail?r=327

Modified:
/trunk/simplegraph.class.php

=======================================
--- /trunk/simplegraph.class.php Mon Oct 31 09:24:47 2011
+++ /trunk/simplegraph.class.php Thu Dec 1 12:16:52 2011
@@ -737,6 +737,16 @@
}
return $ret;
}
+
+ /**
+ * Tests whether the graph knows the given resource to be of the given
type
+ * @param string s the subject of the triple, either a URI or a blank
node in the format _:name
+ * @param string t the type to check for, either a URI or a blank node
in the format _:name
+ * @return boolean true if a matching type statement exists, false
otherwise
+ */
+ function resource_is_of_type($s, $t) {
+ return has_resource_triple($s, $this->_ns['rdf'].'type', $t);
+ }

/**
* Tests whether the graph contains the given triple
@@ -1357,6 +1367,18 @@
}
return $array;
}
+
+ function get_list_value($list_head) {
+ $values = array();
+ do {
+ $found = $this->get_subject_property_values($list_head,
$this->_ns['rdf'].'first');
+ if (count($found) != 1) { throw new Exception("${list_head} had more
than 'first' property"); }
+ $values[] = $found[0];
+ $next = $this->get_subject_property_values($list_head,
$this->_ns['rdf'].'next');
+ if (count($next) != 1) { throw new Exception("${list_head} had more
than 'next' property"); }
+ } while ($list_head = $next[0]['value'] != $this->_ns['rdf'].'nil');
+ return $values;
+ }

function get_sequence_values($sequenceUri) {
$triples = $this->get_index();

Reply all
Reply to author
Forward
0 new messages