Source for file IteratorAllGraphsMem.php

Documentation is available at IteratorAllGraphsMem.php

  1. <?php
  2. /**
  3. * ----------------------------------------------------------------------------------
  4. * Class: IteratorAllGraphsMem
  5. * ----------------------------------------------------------------------------------
  6. *
  7. * @package dataset
  8. */
  9.  
  10.  
  11. /**
  12. * Implementation of a Graph iterator.
  13. *
  14. * This Iterator should be used in a for-loop like:
  15. * for($iterator = $dataset->listGraphs(); $iterator->valid(); $iterator->next())
  16. * {
  17. * $currentResource=$it->current();
  18. * };
  19. *
  20. * <BR><BR>History:
  21. * <LI>05-03-2005 : First version of this class.</LI>
  22. *
  23. * @version V0.9.3
  24. * @author Daniel Westphal <mail at d-westphal dot de>
  25. *
  26. *
  27. * @package dataset
  28. * @access public
  29. ***/
  30. class IteratorAllGraphsMem
  31. {
  32. /**
  33. * Holds a reference to the associated RDF dataset
  34. * @var object dataset
  35. * @access private
  36. */
  37. var $associatedGraphSet;
  38. /**
  39. * The current position
  40. * @var integer
  41. * @access private
  42. */
  43. var $key;
  44. /**
  45. * If the current resource is valid
  46. * @var boolean
  47. * @access private
  48. */
  49. var $valid;
  50. /**
  51. * The current NamedGraph
  52. * @var obejct NamedGraph
  53. * @access private
  54. */
  55. var $current;
  56. /**
  57. * Constructor.
  58. *
  59. *
  60. * @param dataset
  61. * @access public
  62. */
  63. function IteratorAllGraphsMem(&$namedGraphSet)
  64. {
  65. $this->associatedGraphSet=&$namedGraphSet;
  66. $this->rewind();
  67. }
  68. /**
  69. * Resets iterator list to start
  70. *
  71. * @access public
  72. */
  73. function rewind()
  74. {
  75. $this->key = -1;
  76. $this->next();
  77. }
  78. /**
  79. * Says if there are additional items left in the list
  80. *
  81. * @return boolean
  82. * @access public
  83. */
  84. function valid()
  85. {
  86. return $this->valid;
  87. }
  88. /**
  89. * Moves Iterator to the next item in the list
  90. *
  91. * @access public
  92. */
  93. function next()
  94. {
  95. $this->current = &$this->associatedGraphSet->getGraphWithOffset(++$this->key);
  96. $this->valid=($this->current!=NULL);
  97. }
  98. /**
  99. * Returns the current item
  100. *
  101. * @return mixed
  102. * @access public
  103. */
  104. function &current()
  105. {
  106. return $this->current;
  107. }
  108. /**
  109. * Returns the key of the current item
  110. *
  111. * @return integer
  112. * @access public
  113. */
  114. function key()
  115. {
  116. return $this->key;
  117. }
  118. }
  119. ?>

Documentation generated on Fri, 13 Jan 2006 07:48:26 +0100 by phpDocumentor 1.3.0RC4