|
From: <cw...@us...> - 2007-07-05 13:23:37
|
Revision: 468
http://rdfapi-php.svn.sourceforge.net/rdfapi-php/?rev=468&view=rev
Author: cweiske
Date: 2007-07-05 06:23:35 -0700 (Thu, 05 Jul 2007)
Log Message:
-----------
Don't crash if query is incomplete
Modified Paths:
--------------
trunk/rdfapi-php/api/sparql/Query.php
trunk/rdfapi-php/api/sparql/SparqlParser.php
Modified: trunk/rdfapi-php/api/sparql/Query.php
===================================================================
--- trunk/rdfapi-php/api/sparql/Query.php 2007-07-04 12:09:55 UTC (rev 467)
+++ trunk/rdfapi-php/api/sparql/Query.php 2007-07-05 13:23:35 UTC (rev 468)
@@ -55,7 +55,7 @@
* @var string
* @see http://www.w3.org/TR/rdf-sparql-query/#QueryForms
*/
- protected $resultForm;
+ protected $resultForm = null;
/**
* Contains the result part of the SPARQL query.
@@ -63,7 +63,7 @@
*
* @var array
*/
- protected $resultPart;
+ protected $resultPart = array();
/**
* Contains the FROM part of the SPARQL query.
@@ -98,7 +98,7 @@
*
* @var int
*/
- protected $bnodeCounter;
+ protected $bnodeCounter = 0;
/**
* GraphPattern counter.
@@ -106,7 +106,7 @@
*
* @var int
*/
- public $graphPatternCounter;
+ public $graphPatternCounter = 0;
/**
* List of all vars used in the query.
@@ -115,20 +115,20 @@
*
* @var array
*/
- public $usedVars;
+ public $usedVars = array();
/**
* If the query type is CONSTRUCT this variable contains the
* CONSTRUCT graph pattern.
*/
- protected $constructPattern;
+ protected $constructPattern = null;
/**
* TRUE if the query is empty FALSE if not.
*
* @var boolean
*/
- public $isEmpty;
+ public $isEmpty = null;
/**
* Language of variables. NULL if the variable has no
@@ -152,7 +152,7 @@
* Constructor
*/
public function Query(){
- $this->resultForm = false;
+ $this->resultForm = null;
$this->solutionModifier['order by'] = null;
$this->solutionModifier['limit'] = null;
$this->solutionModifier['offset'] = null;
@@ -537,6 +537,24 @@
return false;
}
+
+
+ /**
+ * Checks if the query is complete
+ * (so that querying is possible)
+ *
+ * @return boolean true if the query is complete
+ */
+ public function isComplete()
+ {
+ if ($this->resultForm === null) {
+ return false;
+ }
+ //TODO: maybe check selected vars and construct pattern depending
+ // on the resultform
+ return true;
+ }//public function isIncomplete()
+
}// end class: Query.php
Modified: trunk/rdfapi-php/api/sparql/SparqlParser.php
===================================================================
--- trunk/rdfapi-php/api/sparql/SparqlParser.php 2007-07-04 12:09:55 UTC (rev 467)
+++ trunk/rdfapi-php/api/sparql/SparqlParser.php 2007-07-05 13:23:35 UTC (rev 468)
@@ -32,7 +32,7 @@
* The Querystring
* @var string
*/
- protected $querystring;
+ protected $queryString;
/**
* The tokenized Query
@@ -109,6 +109,13 @@
$this->tokenize($uncommentedQuery);
$this->querystring = $uncommentedQuery;
$this->parseQuery();
+ if (!$this->query->isComplete()) {
+ throw new SparqlParserException(
+ "Query is incomplete.",
+ null,
+ $queryString
+ );
+ }
} else {
throw new SparqlParserException(
"Querystring is empty.",
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|