Source for file IteratorAllGraphsMem.php

Documentation is available at IteratorAllGraphsMem.php

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

Documentation generated on Fri, 1 Jun 2007 16:49:34 +0200 by phpDocumentor 1.3.2