class EasyRdf_Parser in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Parser.php \EasyRdf_Parser
Parent class for the EasyRdf parsers
@package EasyRdf @copyright Copyright (c) 2009-2013 Nicholas J Humfrey @license http://www.opensource.org/licenses/bsd-license.php
Hierarchy
- class \EasyRdf_Parser
Expanded class hierarchy of EasyRdf_Parser
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Parser.php, line 45
View source
class EasyRdf_Parser {
/** Mapping from source to graph bnode identifiers */
private $bnodeMap = array();
/** The current graph to insert triples into */
protected $graph = null;
/** The format of the document currently being parsed */
protected $format = null;
/** The base URI for the document currently being parsed */
protected $baseUri = null;
protected $tripleCount = 0;
/**
* Create a new, unique bnode identifier from a source identifier.
* If the source identifier has previously been seen, the
* same new bnode identifier is returned.
* @ignore
*/
protected function remapBnode($name) {
if (!isset($this->bnodeMap[$name])) {
$this->bnodeMap[$name] = $this->graph
->newBNodeId();
}
return $this->bnodeMap[$name];
}
/**
* Delete the bnode mapping - to be called at the start of a new parse
* @ignore
*/
protected function resetBnodeMap() {
$this->bnodeMap = array();
}
/**
* Check, cleanup parameters and prepare for parsing
* @ignore
*/
protected function checkParseParams($graph, $data, $format, $baseUri) {
if ($graph == null or !is_object($graph) or !$graph instanceof EasyRdf_Graph) {
throw new InvalidArgumentException("\$graph should be an EasyRdf_Graph object and cannot be null");
}
else {
$this->graph = $graph;
}
if ($format == null or $format == '') {
throw new InvalidArgumentException("\$format cannot be null or empty");
}
elseif (is_object($format) and $format instanceof EasyRdf_Format) {
$this->format = $format = $format
->getName();
}
elseif (!is_string($format)) {
throw new InvalidArgumentException("\$format should be a string or an EasyRdf_Format object");
}
else {
$this->format = $format;
}
if ($baseUri) {
if (!is_string($baseUri)) {
throw new InvalidArgumentException("\$baseUri should be a string");
}
else {
$this->baseUri = new EasyRdf_ParsedUri($baseUri);
}
}
else {
$this->baseUri = null;
}
// Prepare for parsing
$this
->resetBnodeMap();
$this->tripleCount = 0;
}
/**
* Sub-classes must follow this protocol
* @ignore
*/
public function parse($graph, $data, $format, $baseUri) {
throw new EasyRdf_Exception("This method should be overridden by sub-classes.");
}
/**
* Add a triple to the current graph, and keep count of the number of triples
* @ignore
*/
protected function addTriple($resource, $property, $value) {
$count = $this->graph
->add($resource, $property, $value);
$this->tripleCount += $count;
return $count;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EasyRdf_Parser:: |
protected | property | The base URI for the document currently being parsed | |
EasyRdf_Parser:: |
private | property | Mapping from source to graph bnode identifiers | |
EasyRdf_Parser:: |
protected | property | The format of the document currently being parsed | |
EasyRdf_Parser:: |
protected | property | The current graph to insert triples into | |
EasyRdf_Parser:: |
protected | property | ||
EasyRdf_Parser:: |
protected | function | Add a triple to the current graph, and keep count of the number of triples @ignore | 1 |
EasyRdf_Parser:: |
protected | function | Check, cleanup parameters and prepare for parsing @ignore | |
EasyRdf_Parser:: |
public | function | Sub-classes must follow this protocol @ignore | 6 |
EasyRdf_Parser:: |
protected | function | Create a new, unique bnode identifier from a source identifier. If the source identifier has previously been seen, the same new bnode identifier is returned. @ignore | |
EasyRdf_Parser:: |
protected | function | Delete the bnode mapping - to be called at the start of a new parse @ignore |