|
From: <cw...@us...> - 2007-06-20 09:13:21
|
Revision: 451
http://rdfapi-php.svn.sourceforge.net/rdfapi-php/?rev=451&view=rev
Author: cweiske
Date: 2007-06-20 02:13:20 -0700 (Wed, 20 Jun 2007)
Log Message:
-----------
- clarify addVar and addVariable meaning by renaming them
- Document QueryTriple better
- Throw correct exception class
Modified Paths:
--------------
trunk/rdfapi-php/api/sparql/Query.php
trunk/rdfapi-php/api/sparql/QueryTriple.php
trunk/rdfapi-php/api/sparql/SparqlEngineDb/FilterGenerator.php
trunk/rdfapi-php/api/sparql/SparqlParser.php
Modified: trunk/rdfapi-php/api/sparql/Query.php
===================================================================
--- trunk/rdfapi-php/api/sparql/Query.php 2007-06-19 17:04:46 UTC (rev 450)
+++ trunk/rdfapi-php/api/sparql/Query.php 2007-06-20 09:13:20 UTC (rev 451)
@@ -272,7 +272,7 @@
* @param String $var
* @return void
*/
- public function addVariable($var){
+ public function addResultVar($var){
$this->resultVars[]= $var;
$this->varLanguages[$var] = self::getLanguageTag($var);
$this->varDatatypes[$var] = $this->getDatatype($var);
@@ -367,7 +367,7 @@
* @param String $var
* @return void
*/
- public function addVar($var){
+ public function addUsedVar($var){
$this->usedVars[$var]=true;
}
Modified: trunk/rdfapi-php/api/sparql/QueryTriple.php
===================================================================
--- trunk/rdfapi-php/api/sparql/QueryTriple.php 2007-06-19 17:04:46 UTC (rev 450)
+++ trunk/rdfapi-php/api/sparql/QueryTriple.php 2007-06-20 09:13:20 UTC (rev 451)
@@ -5,73 +5,88 @@
require_once RDFAPI_INCLUDE_DIR . 'sparql/SparqlEngineDb/SqlGenerator.php';
/**
-* Represents a query triple.
+* Represents a query triple with subject, predicate and object.
*
* @author Tobias Gauss <tob...@we...>
* @version $Id$
*
* @package sparql
*/
-Class QueryTriple extends Object{
+class QueryTriple extends Object
+{
- /**
- * The QueryTriples Subject.
- */
- protected $subject;
+ /**
+ * The QueryTriples Subject.
+ * Can be a BlankNode or Resource, string in
+ * case of a variable
+ * @var Node/string
+ */
+ protected $subject;
- /**
- * The QueryTriples Predicate.
- */
- protected $predicate;
+ /**
+ * The QueryTriples Predicate.
+ * Normally only a Resource, string in
+ * case of a variable
+ * @var Node/string
+ */
+ protected $predicate;
- /**
- * The QueryTriples Object.
- */
- protected $object;
+ /**
+ * The QueryTriples Object.
+ * Can be BlankNode, Resource or Literal, string in
+ * case of a variable
+ * @var Node/string
+ */
+ protected $object;
- /**
- * Constructor
- */
- public function QueryTriple($sub,$pred,$ob)
- {
- $this->subject = $sub;
- $this->predicate = $pred;
- $this->object = $ob;
- }
- /**
- * Returns the Triples Subject.
- *
- * @return Node
- */
- public function getSubject()
- {
- return $this->subject;
- }
+ /**
+ * Constructor
+ *
+ * @param Node $sub Subject
+ * @param Node $pred Predicate
+ * @param Node $ob Object
+ */
+ public function QueryTriple($sub,$pred,$ob)
+ {
+ $this->subject = $sub;
+ $this->predicate = $pred;
+ $this->object = $ob;
+ }
- /**
- * Returns the Triples Predicate.
- *
- * @return Node
- */
- public function getPredicate()
- {
- return $this->predicate;
- }
+ /**
+ * Returns the Triples Subject.
+ *
+ * @return Node
+ */
+ public function getSubject()
+ {
+ return $this->subject;
+ }
- /**
- * Returns the Triples Object.
- *
- * @return Node
- */
- public function getObject()
- {
- return $this->object;
- }
+ /**
+ * Returns the Triples Predicate.
+ *
+ * @return Node
+ */
+ public function getPredicate()
+ {
+ return $this->predicate;
+ }
+ /**
+ * Returns the Triples Object.
+ *
+ * @return Node
+ */
+ public function getObject()
+ {
+ return $this->object;
+ }
+
/**
* Returns an array of all variables in this triple.
*
Modified: trunk/rdfapi-php/api/sparql/SparqlEngineDb/FilterGenerator.php
===================================================================
--- trunk/rdfapi-php/api/sparql/SparqlEngineDb/FilterGenerator.php 2007-06-19 17:04:46 UTC (rev 450)
+++ trunk/rdfapi-php/api/sparql/SparqlEngineDb/FilterGenerator.php 2007-06-20 09:13:20 UTC (rev 451)
@@ -118,8 +118,8 @@
$sql = $this->createFunction($tree);
break;
default:
- var_dump($tree);
- throw new Exception('Unsupported tree type: ' . $tree['type']);
+ //var_dump($tree);
+ throw new SparqlEngineDb_SqlGeneratorException('Unsupported tree type: ' . $tree['type']);
break;
}
Modified: trunk/rdfapi-php/api/sparql/SparqlParser.php
===================================================================
--- trunk/rdfapi-php/api/sparql/SparqlParser.php 2007-06-19 17:04:46 UTC (rev 450)
+++ trunk/rdfapi-php/api/sparql/SparqlParser.php 2007-06-20 09:13:20 UTC (rev 451)
@@ -299,7 +299,7 @@
if ($this->varCheck(current($this->tokens))
| strtolower(current($this->tokens)) == '*'
){
- $this->query->addVariable(current($this->tokens));
+ $this->query->addResultVar(current($this->tokens));
if (!$this->query->getResultForm()) {
$this->query->setResultForm('select');
}
@@ -310,7 +310,7 @@
if ($this->varCheck(current($this->tokens))
| strtolower(current($this->tokens))=='*'
) {
- $this->query->addVariable(current($this->tokens));
+ $this->query->addResultVar(current($this->tokens));
} else {
throw new SparqlParserException(
"Variable or '*' expected.",
@@ -344,7 +344,7 @@
while(strtolower(current($this->tokens))!='from'& strtolower(current($this->tokens))!='where'){
$this->_fastForward();
if($this->varCheck(current($this->tokens))|$this->iriCheck(current($this->tokens))){
- $this->query->addVariable(current($this->tokens));
+ $this->query->addResultVar(current($this->tokens));
if(!$this->query->getResultForm())
$this->query->setResultForm('describe');
}
@@ -444,7 +444,7 @@
protected function varCheck($token)
{
if (isset($token[0]) && ($token{0} == '$' || $token{0} == '?')) {
- $this->query->addVar($token);
+ $this->query->addUsedVar($token);
return true;
}
return false;
@@ -1234,12 +1234,12 @@
}
if ($this->bNodeCheck($node)) {
$node = '?'.$node;
- $this->query->addVar($node);
+ $this->query->addUsedVar($node);
return $node;
}
if ($node == '[') {
$node = '?' . substr($this->query->getBlanknodeLabel(), 1);
- $this->query->addVar($node);
+ $this->query->addUsedVar($node);
$this->_fastForward();
if(current($this->tokens)!=']') {
prev($this->tokens);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|