Source for file GraphPattern.php

Documentation is available at GraphPattern.php

  1. <?php
  2. // ---------------------------------------------
  3. // class: GraphPattern
  4. // ---------------------------------------------
  5.  
  6. /**
  7. * A graph pattern which consists of triple patterns, optional
  8. * or union graph patterns and filters.
  9. *
  10. @author   Tobias Gauss <tobias.gauss@web.de>
  11. @version     $Id: fsource_sparql__sparqlGraphPattern.php.html 443 2007-06-01 16:25:38Z cax $
  12. *
  13. @package sparql
  14. */
  15.  
  16. class GraphPattern extends Object{
  17.  
  18.     /**
  19.     * Graphname. 0 if its in the default graph.
  20.     */
  21.     protected $graphname;
  22.  
  23.     /**
  24.     * @var array The TriplePattern.
  25.     */
  26.     protected $triplePattern;
  27.  
  28.     /**
  29.     * @var array A List of Constraints.
  30.     */
  31.     protected $constraint = array();
  32.  
  33.     /**
  34.     * @var int Pointer to optional patterns.
  35.     */
  36.     protected $optional;
  37.  
  38.     /**
  39.     * @var int Pointer to union patterns.
  40.     */
  41.     protected $union;
  42.  
  43.     /**
  44.     * @var boolean TRUE if the pattern is open- FALSE if closed.
  45.     */
  46.     public $open;
  47.  
  48.     /**
  49.     * @var boolean TRUE if the GraphPattern is a construct pattern.
  50.     */
  51.     public $isConstructPattern;
  52.  
  53.  
  54.     /**
  55.     * @var int The GraphPatterns id.
  56.     */
  57.     public $patternId;
  58.  
  59.  
  60.     /**
  61.     * Constructor
  62.     */
  63.     public function GraphPattern(){
  64.         $this->open               = true ;
  65.         $this->isConstructPattern = false;
  66.         $this->constraint         = false;
  67.         $this->triplePattern      = false;
  68.     }
  69.  
  70.     /**
  71.     * Returns the graphname.
  72.     *
  73.     * @return String 
  74.     */
  75.     public function getGraphname(){
  76.         return $this->graphname;
  77.     }
  78.  
  79.     /**
  80.     * Returns the triple pattern of the graph pattern.
  81.     *
  82.     * @return Array 
  83.     */
  84.     public function getTriplePattern(){
  85.         return $this->triplePattern;
  86.     }
  87.  
  88.     /**
  89.     * Returns a constraint if there is one false if not.
  90.     *
  91.     * @return Constraint 
  92.     */
  93.     public function getConstraint(){
  94.         return $this->constraint;
  95.     }
  96.  
  97.     /**
  98.     * Returns a pointer to an optional graph pattern.
  99.     *
  100.     * @return integer 
  101.     */
  102.     public function getOptional(){
  103.         return $this->optional;
  104.     }
  105.  
  106.     /**
  107.     * Returns a pointer to a union graph pattern.
  108.     *
  109.     * @return integer 
  110.     */
  111.     public function getUnion(){
  112.         return $this->union;
  113.     }
  114.  
  115.     /**
  116.     * Sets the graphname.
  117.     *
  118.     * @param  String $name 
  119.     * @return void 
  120.     */
  121.     public function setGraphname($name){
  122.         $this->graphname = $name;
  123.     }
  124.     /**
  125.     * Adds a List of QueryTriples to the GraphPattern.
  126.     *
  127.     * @param  array $trpP 
  128.     * @return void 
  129.     */
  130.     public function addTriplePattern($trpP){
  131.         $this->triplePattern = $trpP;
  132.     }
  133.  
  134.     /**
  135.     * Adds a Constraint to the GraphPattern.
  136.     *
  137.     * @param  Constraint $cons 
  138.     * @return void 
  139.     */
  140.     public function addConstraint(&$cons){
  141.         $this->constraint[$cons;
  142.     }
  143.     /**
  144.     * Adds a pointer to an optional graphPattern.
  145.     *
  146.     * @param  integer $pattern 
  147.     * @return void 
  148.     */
  149.     public function addOptional($pattern){
  150.         $this->optional = &$pattern;
  151.     }
  152.  
  153.     /**
  154.     * Adds a pointer to a union graphPattern.
  155.     *
  156.     * @param  integer $pattern 
  157.     * @return void 
  158.     */
  159.     public function addUnion($pattern){
  160.         $this->union = &$pattern;
  161.     }
  162.  
  163.  
  164.     /**
  165.     * Sets the GraphPatterns Id.
  166.     *
  167.     * @param  integer $id 
  168.     * @return void 
  169.     */
  170.     public function setId($id){
  171.         $this->patternId = $id;
  172.     }
  173.  
  174.     /**
  175.     * Returns the GraphPatterns id.
  176.     *
  177.     * @return integer 
  178.     */
  179.     public function getId(){
  180.         return $this->patternId;
  181.     }
  182.  
  183.  
  184.  
  185.     /**
  186.     *   Returns an array of all variables used in this
  187.     *   graph pattern.
  188.     *   All variables are listed only once (unique).
  189.     *
  190.     *   @return array   Array of variable names
  191.     */
  192.     public function getVariables()
  193.     {
  194.         $arVars array();
  195.  
  196.         foreach ($this->triplePattern as $pattern{
  197.             $arVars array_merge($arVars$pattern->getVariables());
  198.         }
  199.  
  200.         return array_unique($arVars);
  201.     }//public function getVariables()
  202.  
  203. }// end class: GraphPattern.php
  204. ?>

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