source: Dev/branches/rest-dojo-ui/server/rdfapi/dataset/IteratorAllGraphsDb.php @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 2.2 KB
Line 
1<?php
2//----------------------------------------------------------------------------------
3// Class: IteratorAllGraphsDb
4//----------------------------------------------------------------------------------
5
6
7/**
8* Implementation of a Graph iterator.
9*
10* This Iterator should be used in a for-loop like:
11* for($iterator = $dataset->listGraphs(); $iterator->valid(); $iterator->next())
12* {
13*       $currentResource=$iterator->current();
14* };
15*
16* @version  $Id$
17* @author Daniel Westphal <mail at d-westphal dot de>
18*
19*
20* @package      dataset
21* @access       public
22**/
23class IteratorAllGraphsDb
24{
25        /**
26        * Holds a reference to the associated DB resultSet
27        * @var          $dbResultSets ADODB result
28        * @access       private
29        */
30        var $dbResultSet;
31       
32        /**
33        * Holds a reference to the associated datasetDb
34        * @var          datasetDb
35        * @access       private
36        */
37        var $datasetDb;
38       
39       
40        /**
41        * The current position
42        * @var          integer
43        * @access       private
44        */
45        var $key;
46       
47       
48        /**
49        * The current NamedGraph
50        * @var obejct NamedGraph
51        * @access       private
52        */
53        var $current;
54       
55       
56       
57        /**
58    * Constructor.
59    *
60    *
61    * @param ADODBResultSet
62    * @param DatasetDb
63        * @access       public
64    */
65        function IteratorAllGraphsDb(&$dbResultSet,&$datasetDb)
66        {
67                $this->dbResultSet=& $dbResultSet;
68                $this->datasetDb=& $datasetDb;
69                $this->current = $this->dbResultSet->fields[0];
70        }
71       
72        /**
73    * Resets iterator list to start
74    *
75        * @access public
76    */
77        function rewind()
78        {
79                //not supported
80        }
81       
82        /**
83    * Says if there are additional items left in the list
84    *
85    * @return   boolean
86        * @access       public
87    */
88        function valid()
89        {
90                return (!$this->dbResultSet->EOF);
91        }
92       
93        /**
94    * Moves Iterator to the next item in the list
95    *
96        * @access       public
97    */
98        function next()
99        {
100                $this->dbResultSet->moveNext();
101                $this->current = $this->dbResultSet->fields[0];
102        }
103       
104        /**
105    * Returns the current item
106    *
107    * @return   mixed
108        * @access       public
109    */
110        function &current()
111        {
112                return ($this->datasetDb->getNamedGraph($this->current));
113        }
114       
115       
116        /**
117    * Returns the key of the current item
118    *
119    * @return   integer
120        * @access       public
121    */
122        function key()
123        {
124                return $this->dbResultSet->_currentRow;
125        }
126}
127?>
Note: See TracBrowser for help on using the repository browser.