SMWSparqlResultWrapper Class Reference
[SWMSparql]

Class for accessing SPARQL query results in a unified form. More...

List of all members.

Public Member Functions

 __construct (array $header, array $data, array $comments=array(), $errorCode=self::ERROR_NOERROR)
 Initialise a result set from a result string in SPARQL XML format.
 numRows ()
 Get the number of rows in the result object.
 getErrorCode ()
 Return error code.
 setErrorCode ($errorCode)
 Set the error code of this result set.
 getComments ()
 Return a list of comment strings found in the SPARQL result.
 isBooleanTrue ()
 Check if the result is what one would get for a SPARQL ASK query that returned true.
 getNumericValue ()
 Check if the result is what one would get for a SPARQL SELECT COUNT query, and return the corresponding integer value.
 rewind ()
 Reset iterator to position 0.
 current ()
 Return the current result row.
 next ()
 Return the next result row and advance the internal pointer.
 key ()
 Return the next result row and advance the internal pointer.
 valid ()
 Return true if the internal pointer refers to a valid element.

Public Attributes

const ERROR_NOERROR = 0
 Error code: no errors occurred.
const ERROR_UNREACHABLE = 1
 Error code: service unreachable; result will be empty.
const ERROR_INCOMPLETE = 2
 Error code: results might be incomplete (e.g. due to some resource limit being reached).

Protected Attributes

 $m_header
 $m_data
 $m_comments
 $m_errorCode


Detailed Description

Class for accessing SPARQL query results in a unified form.

The data is structured in tabular form, with each cell containing some SMWExpElement. Rows should always have the same number of columns, but the datatype of the cells in each column may not be uniform throughout the result.

Since:
1.6

Definition at line 21 of file SMW_SparqlResultWrapper.php.


Constructor & Destructor Documentation

SMWSparqlResultWrapper::__construct ( array $  header,
array $  data,
array $  comments = array(),
errorCode = self::ERROR_NOERROR 
)

Initialise a result set from a result string in SPARQL XML format.

Parameters:
$header array mapping SPARQL variable names to column indices
$data array of array of (SMWExpElement or null)
$comments array of string comments if the result contained any
$errorCode integer an error code

Definition at line 65 of file SMW_SparqlResultWrapper.php.


Member Function Documentation

SMWSparqlResultWrapper::numRows (  ) 

Get the number of rows in the result object.

Returns:
interger number of result rows

Definition at line 78 of file SMW_SparqlResultWrapper.php.

SMWSparqlResultWrapper::getErrorCode (  ) 

Return error code.

SMWSparqlResultWrapper::ERROR_NOERROR (0) indicates that no error occurred.

Returns:
integer error code

Definition at line 88 of file SMW_SparqlResultWrapper.php.

SMWSparqlResultWrapper::setErrorCode ( errorCode  ) 

Set the error code of this result set.

This is used for allowing callers to add additional errors discovered only later on. It does not allow removing existing errors, since it will not accept SMWSparqlResultWrapper::ERROR_NOERROR as a parameter.

Parameters:
$errorCode integer error code

Definition at line 100 of file SMW_SparqlResultWrapper.php.

SMWSparqlResultWrapper::getComments (  ) 

Return a list of comment strings found in the SPARQL result.

Comments are used by some RDF stores to provide additional information or warnings that can thus be accessed.

Returns:
array of string

Definition at line 113 of file SMW_SparqlResultWrapper.php.

SMWSparqlResultWrapper::isBooleanTrue (  ) 

Check if the result is what one would get for a SPARQL ASK query that returned true.

Returns false in all other cases (including the case that the results do not look at all like the result of an ASK query).

Returns:
boolean

Definition at line 125 of file SMW_SparqlResultWrapper.php.

SMWSparqlResultWrapper::getNumericValue (  ) 

Check if the result is what one would get for a SPARQL SELECT COUNT query, and return the corresponding integer value.

Returns 0 in all other cases (including the case that the results do not look at all like the result of a SELECT COUNT query).

Returns:
integer

Definition at line 146 of file SMW_SparqlResultWrapper.php.

SMWSparqlResultWrapper::rewind (  ) 

Reset iterator to position 0.

Standard method of Iterator.

Definition at line 161 of file SMW_SparqlResultWrapper.php.

SMWSparqlResultWrapper::current (  ) 

Return the current result row.

Standard method of Iterator.

Returns:
array of (SMWExpElement or null), or false at end of data

Definition at line 170 of file SMW_SparqlResultWrapper.php.

Referenced by valid().

SMWSparqlResultWrapper::next (  ) 

Return the next result row and advance the internal pointer.

Standard method of Iterator.

Returns:
array of (SMWExpElement or null), or false at end of data

Definition at line 180 of file SMW_SparqlResultWrapper.php.

SMWSparqlResultWrapper::key (  ) 

Return the next result row and advance the internal pointer.

Standard method of Iterator.

Returns:
array of (SMWExpElement or null), or false at end of data

Definition at line 190 of file SMW_SparqlResultWrapper.php.

SMWSparqlResultWrapper::valid (  ) 

Return true if the internal pointer refers to a valid element.

Standard method of Iterator.

Returns:
boolean

Definition at line 200 of file SMW_SparqlResultWrapper.php.

References current().


Member Data Documentation

Error code: service unreachable; result will be empty.

Definition at line 26 of file SMW_SparqlResultWrapper.php.

Referenced by SMWSparqlDatabase4Store::doQuery(), and SMWSparqlDatabase::doQuery().

Error code: results might be incomplete (e.g. due to some resource limit being reached).

Definition at line 28 of file SMW_SparqlResultWrapper.php.

Referenced by SMWSparqlDatabase4Store::doQuery(), and SMWSparqlStoreQueryEngine::getQueryResultFromSparqlResult().

SMWSparqlResultWrapper::$m_header [protected]

Definition at line 34 of file SMW_SparqlResultWrapper.php.

SMWSparqlResultWrapper::$m_data [protected]

Definition at line 42 of file SMW_SparqlResultWrapper.php.

SMWSparqlResultWrapper::$m_comments [protected]

Definition at line 49 of file SMW_SparqlResultWrapper.php.

SMWSparqlResultWrapper::$m_errorCode [protected]

Definition at line 55 of file SMW_SparqlResultWrapper.php.


The documentation for this class was generated from the following file:

Generated on Sun Mar 18 07:15:43 2012 for Semantic MediaWiki by  doxygen 1.5.6