[moriarty] r328 committed - replaced list handling with code that allows mixed uri and literal val...

0 views
Skip to first unread message

mori...@googlecode.com

unread,
Dec 1, 2011, 5:41:36 PM12/1/11
to moriarty...@googlegroups.com
Revision: 328
Author: mmmmmrob
Date: Thu Dec 1 14:40:47 2011
Log: replaced list handling with code that allows mixed uri and
literal values in return
http://code.google.com/p/moriarty/source/detail?r=328

Modified:
/trunk/simplegraph.class.php

=======================================
--- /trunk/simplegraph.class.php Thu Dec 1 12:16:52 2011
+++ /trunk/simplegraph.class.php Thu Dec 1 14:40:47 2011
@@ -1359,24 +1359,18 @@
}
}

- function get_list_values($listUri) {
- $array = array();
- while(!empty($listUri) AND $listUri != RDF_NIL){
- $array[]=$this->get_first_resource($listUri, RDF_FIRST);
- $listUri = $this->get_first_resource($listUri, RDF_REST);
- }
- return $array;
- }
-
- function get_list_value($list_head) {
+ function get_list_values($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"); }
+ $found = $this->get_subject_property_values($list_head, RDF_FIRST);
+ $found_count = count($found);
+ if ($found_count != 1) { throw new Exception("${list_head} had
${found_count} 'first' properties"); }
$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');
+ $next = $this->get_subject_property_values($list_head, RDF_REST);
+ $nextCount = count($next);
+ if ($nextCount != 1) { throw new Exception("${list_head} had
${nextCount} 'rest' properties"); }
+ $list_head = $next[0]['value'];
+ } while ($list_head != RDF_NIL);
return $values;
}

Reply all
Reply to author
Forward
0 new messages