PageRenderTime 49ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/rdfapi-php/api/resModel/ResModel.php

https://github.com/koja13/DSi2.0
PHP | 876 lines | 309 code | 82 blank | 485 comment | 25 complexity | 1d7dfdf0c2c0a1acd5e9622cb4967a86 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. // ----------------------------------------------------------------------------------
  3. // Class: ResModel
  4. // ----------------------------------------------------------------------------------
  5. /**
  6. * A ResModel provides an resource centric view on an underlying RDF model.
  7. * ResModels show information not as statements but as resources with
  8. * properties, similar to Jena models. ResModels may create Resources [URI
  9. * nodes and bnodes]. Creating a Resource does not make the Resource visible to
  10. * the model; Resources are only "in" Models if Statements about them are added
  11. * to the Model. Similarly the only way to "remove" a Resource from a Model is
  12. * to remove all the Statements that mention it.
  13. *
  14. * When a Resource or Literal is created by a Model, the Model is free to re-use an existing
  15. * Resource or Literal object with the correct values, or it may create a fresh one.
  16. *
  17. * @version $Id: ResModel.php 562 2008-02-29 15:30:18Z cax $
  18. * @author Daniel Westphal <mail at d-westphal dot de>
  19. *
  20. *
  21. * @package resModel
  22. * @access public
  23. **/
  24. class ResModel
  25. {
  26. /**
  27. * Holds a reference to the assoiated memmodel/dbmodel/infmodel
  28. * @var ResResource
  29. * @access private
  30. */
  31. var $model;
  32. /**
  33. * Constructor
  34. * You have to supply a memmodel/dbmodel/infmodel to save the statements.
  35. *
  36. * @param object model $model
  37. * @access public
  38. */
  39. function ResModel(& $model)
  40. {
  41. if (!is_a($model,'Model'))
  42. trigger_error(RDFAPI_ERROR . '(class: ResourceLayer; method: ResourceLayer):
  43. $model has to be object of class Model', E_USER_ERROR);
  44. $this->model =& $model;
  45. }
  46. /**
  47. * Create a new resource associated with this model.
  48. * If the uri string isn't set, this creates a bnode.
  49. * Otherwise it creates a URI node.
  50. * A URI resource is .equals() to any other URI Resource with the same URI
  51. * (even in a different model - be warned).
  52. *
  53. * This method may return an existing Resource with the correct URI and model,
  54. * or it may construct a fresh one, as it sees fit.
  55. *
  56. * Operations on the result Resource may change this model.
  57. *
  58. * @param string $uri
  59. * @return object ResResource
  60. * @access public
  61. */
  62. function createResource($uri = null)
  63. {
  64. $resResource = new ResResource($uri);
  65. //associate the resource with this model, and get a unique identifier
  66. //if it is bnode.
  67. $resResource->setAssociatedModel($this);
  68. return $resResource;
  69. }
  70. /**
  71. * Create a new Property associated with this model.
  72. * This method may return an existing property with the correct URI and model,
  73. * or it may construct a fresh one, as it sees fit.
  74. *
  75. * Subsequent operations on the returned property may modify this model.
  76. *
  77. *
  78. * @param string $uri
  79. * @return object ResProperty
  80. * @access public
  81. */
  82. function createProperty($uri = null)
  83. {
  84. $resProperty = new ResProperty($uri);
  85. $resProperty->setAssociatedModel($this);
  86. return $resProperty;
  87. }
  88. /**
  89. * Create an untyped literal from a String value with a specified language.
  90. *
  91. * If you want to type this literal, you have to set a datatype before
  92. * adding it to the model.
  93. *
  94. *
  95. * @param string $label
  96. * @param string $languageTag
  97. * @return object ResLiteral
  98. * @access public
  99. */
  100. function createLiteral($label,$languageTag = null)
  101. {
  102. $resLiteral = new ResLiteral($label,$languageTag);
  103. $resLiteral->setAssociatedModel($this);
  104. return $resLiteral;
  105. }
  106. /**
  107. * General method to search for triples.
  108. * NULL input for any parameter will match anything.
  109. * Example: $result = $m->find( NULL, NULL, $node );
  110. * Finds all Statements with $node as object.
  111. * Returns an array of statements with ResResources.
  112. *
  113. * @param object ResResource $subject
  114. * @param object ResResource $predicate
  115. * @param object ResResource $object
  116. * @return array
  117. * @access public
  118. * @throws PhpError
  119. */
  120. function find($subject,$predicate, $object)
  121. {
  122. $result=array();
  123. //convert ResResources to Resources and Blanknodes
  124. $resmodel=$this->model->find( $this->_resNode2Node($subject),
  125. $this->_resNode2Node($predicate),
  126. $this->_resNode2Node($object)
  127. );
  128. //convert Resources, Blanknodes to ResResources
  129. foreach ($resmodel->triples as $statement)
  130. {
  131. $result[]=new Statement($this->_node2ResNode($statement->getSubject()),
  132. $this->_node2ResNode($statement->getPredicate(),true),
  133. $this->_node2ResNode($statement->getObject())
  134. );
  135. };
  136. return $result;
  137. }
  138. /**
  139. * Searches for triples and returns the first matching statement.
  140. * NULL input for any parameter will match anything.
  141. * Example: $result = $m->findFirstMatchingStatement( NULL, NULL, $node );
  142. * Returns the first statement with ResResources of the Model where the object equals $node.
  143. * Returns an NULL if nothing is found.
  144. * You can define an offset to search.
  145. *
  146. * @param object Node $subject
  147. * @param object Node $predicate
  148. * @param object Node $object
  149. * @param integer $offset
  150. * @return object Statement
  151. * @access public
  152. */
  153. function findFirstMatchingStatement($subject,$predicate,$object,$offset = 0)
  154. {
  155. $statement = $this->model->findFirstMatchingStatement( $this->_resNode2Node($subject),
  156. $this->_resNode2Node($predicate),
  157. $this->_resNode2Node($object),
  158. $offset
  159. );
  160. if ($statement!==null)
  161. {
  162. return new Statement( $this->_node2ResNode($statement->getSubject()),
  163. $this->_node2ResNode($statement->getPredicate(),true),
  164. $this->_node2ResNode($statement->getObject())
  165. );
  166. } else
  167. {
  168. return null;
  169. }
  170. }
  171. /**
  172. * Adds a new triple to the Model without checking if the statement is already in the Model.
  173. * So if you want a duplicate free Model use the addWithoutDuplicates() function (which is slower then add())
  174. * Expects a statements with ResResources(ResLiterals)
  175. *
  176. * @param object Statement $statement
  177. * @access public
  178. * @throws PhpError
  179. */
  180. function add($statement)
  181. {
  182. return $this->model->add(new Statement( $this->_resNode2Node($statement->getSubject()),
  183. $this->_resNode2Node($statement->getPredicate()),
  184. $this->_resNode2Node($statement->getObject()))
  185. );
  186. }
  187. /**
  188. * Checks if a new statement is already in the Model and adds the statement, if it is not in the Model.
  189. * addWithoutDuplicates() is significantly slower then add().
  190. * Retruns TRUE if the statement is added.
  191. * FALSE otherwise.
  192. * Expects a statements with ResResources(ResLiterals)
  193. *
  194. * @param object Statement $statement
  195. * @return boolean
  196. * @access public
  197. * @throws PhpError
  198. */
  199. function addWithoutDuplicates($statement)
  200. {
  201. return $this->model->addWithoutDuplicates(new Statement($this->_resNode2Node($statement->getSubject()),
  202. $this->_resNode2Node($statement->getPredicate()),
  203. $this->_resNode2Node($statement->getObject()))
  204. );
  205. }
  206. /**
  207. * Tests if the Model contains the given statement.
  208. * TRUE if the statement belongs to the model;
  209. * FALSE otherwise.
  210. * Expects a statement of ResResources(ResLiterals)
  211. *
  212. * @param object Statement $statement
  213. * @return boolean
  214. * @access public
  215. */
  216. function contains(& $statement)
  217. {
  218. return $this->model->contains(new Statement($this->_resNode2Node($statement->getSubject()),
  219. $this->_resNode2Node($statement->getPredicate()),
  220. $this->_resNode2Node($statement->getObject()))
  221. );
  222. }
  223. /**
  224. * Determine if all of the statements in a model are also contained in this model.
  225. * True if all of the statements in $model are also contained in this model and false otherwise.
  226. *
  227. * @param object Model &$model
  228. * @return boolean
  229. * @access public
  230. */
  231. function containsAll(& $model)
  232. {
  233. if (is_a($model,'ResModel'))
  234. return $this->model->containsAll($model->getModel());
  235. return $this->model->containsAll($model);
  236. }
  237. /**
  238. * Determine if any of the statements in a model are also contained in this model.
  239. * True if any of the statements in $model are also contained in this model and false otherwise.
  240. *
  241. * @param object Model &$model
  242. * @return boolean
  243. * @access public
  244. */
  245. function containsAny(& $model)
  246. {
  247. if (is_a($model,'ResModel'))
  248. return $this->model->containsAny($model->getModel());
  249. return $this->model->containsAny($model);
  250. }
  251. /**
  252. * Determine if the node (ResResource / ResLiteral) $node appears in any statement of this model.
  253. *
  254. * @param object Node &$node
  255. * @return boolean
  256. * @access public
  257. */
  258. function containsResource(& $node)
  259. {
  260. if ($this->findFirstMatchingStatement($node,null,null) === null)
  261. if ($this->findFirstMatchingStatement(null,$node,null) === null)
  262. if ($this->findFirstMatchingStatement(null,null,$node) === null)
  263. return false;
  264. return true;
  265. }
  266. /**
  267. * Create a literal from a String value with the $dtype Datatype
  268. * An existing literal of the right value may be returned, or a fresh one created.
  269. *
  270. * @param string $value
  271. * @param string $dtype
  272. * @return object ResLiteral
  273. * @access public
  274. */
  275. function createTypedLiteral($value,$dtype)
  276. {
  277. $resLiteral = new ResLiteral($value);
  278. $resLiteral->setDatatype($dtype);
  279. $resLiteral->setAssociatedModel($this);
  280. return $resLiteral;
  281. }
  282. /**
  283. * Checks if two models are equal.
  284. * Two models are equal if and only if the two RDF graphs they represent are isomorphic.
  285. *
  286. * Warning: This method doesn't work correct with models where the same blank node has different
  287. * identifiers in the two models. We will correct this in a future version.
  288. *
  289. * @access public
  290. * @param object model &$that
  291. * @throws phpErrpr
  292. * @return boolean
  293. */
  294. function equals(& $that)
  295. {
  296. if (is_a($that,'ResModel'))
  297. return $this->model->equals($that->getModel());
  298. return $this->model->equals($that);
  299. }
  300. /**
  301. * Returns a new model that is the subtraction of another model from this model.
  302. *
  303. * @param object Model $model
  304. * @return object MemModel
  305. * @access public
  306. * @throws phpErrpr
  307. */
  308. function subtract($model)
  309. {
  310. if (is_a($model,'ResModel'))
  311. return $this->model->subtract($model->getModel());
  312. return $this->model->subtract($model);
  313. }
  314. /**
  315. * Answer a statement find(s, p, null) with ResResources(ResLiterals) from this model.
  316. * If none exist, return null; if several exist, pick one arbitrarily.
  317. *
  318. * @param object ResResource $subject
  319. * @param object ResResource $property
  320. * @return object Statement
  321. * @access public
  322. * @throws phpErrpr
  323. */
  324. function getProperty($subject,$property)
  325. {
  326. $statement= $this->model->findFirstMatchingStatement( $this->_resNode2Node($subject),
  327. $this->_resNode2Node($property),
  328. null
  329. );
  330. if ($statement === null)
  331. return null;
  332. return new Statement($this->_node2ResNode($statement->getSubject()),
  333. $this->_node2ResNode($statement->getPredicate(),true),
  334. $this->_node2ResNode($statement->getObject())
  335. );
  336. }
  337. /**
  338. * Checks if MemModel is empty
  339. *
  340. * @return boolean
  341. * @access public
  342. */
  343. function isEmpty()
  344. {
  345. return $this->model->isEmpty();
  346. }
  347. /**
  348. * Returns a ResIterator with all objects in a model.
  349. *
  350. * @return object ResIterator
  351. * @access public
  352. * @throws phpErrpr
  353. */
  354. function listObjects()
  355. {
  356. return $this->listObjectsOfProperty(null);
  357. }
  358. /**
  359. * Returns a ResIterator with all objects with a given property and property value.
  360. *
  361. * @param object ResResource $property
  362. * @param object ResResource $value
  363. * @return object ResIterator
  364. * @access public
  365. */
  366. function listObjectsOfProperty($property, $value = null)
  367. {
  368. return new ResIterator(null,$property,$value,'o',$this);
  369. }
  370. /**
  371. * Returns a ResIterator with all subjects in a model.
  372. *
  373. * @return object ResIterator
  374. * @access public
  375. * @throws phpErrpr
  376. */
  377. function listSubjects()
  378. {
  379. return $this->listSubjectsWithProperty(null);
  380. }
  381. /**
  382. * Returns a ResIterator with all subjects with a given property and property value.
  383. *
  384. * @param object ResResource $property
  385. * @param object ResResource $value
  386. * @return object ResIterator
  387. * @access public
  388. * @throws phpErrpr
  389. */
  390. function listSubjectsWithProperty($property,$value = null)
  391. {
  392. return new ResIterator(null,$property,$value,'s',$this);
  393. }
  394. /**
  395. * Removes the statement of ResResources(ResTriples) from the MemModel.
  396. * TRUE if the statement is removed.
  397. * FALSE otherwise.
  398. *
  399. * @param object Statement $statement
  400. * @return boolean
  401. * @access public
  402. * @throws PhpError
  403. */
  404. function remove($statement)
  405. {
  406. return $this->model->remove(new Statement( $this->_resNode2Node($statement->getSubject()),
  407. $this->_resNode2Node($statement->getPredicate()),
  408. $this->_resNode2Node($statement->getObject())
  409. ));
  410. }
  411. /**
  412. * Number of statements in the MemModel
  413. *
  414. * @return integer
  415. * @access public
  416. */
  417. function size()
  418. {
  419. return $this->model->size();
  420. }
  421. /**
  422. * Returns a new Model that is the set-union of the model with another model.
  423. * Duplicate statements are removed. If you want to allow duplicates, use addModel() which is much faster.
  424. *
  425. * The result of taking the set-union of two or more RDF graphs (i.e. sets of triples)
  426. * is another graph, which we will call the merge of the graphs.
  427. * Each of the original graphs is a subgraph of the merged graph. Notice that when forming
  428. * a merged graph, two occurrences of a given uriref or literal as nodes in two different
  429. * graphs become a single node in the union graph (since by definition they are the same
  430. * uriref or literal) but blank nodes are not 'merged' in this way; and arcs are of course
  431. * never merged. In particular, this means that every blank node in a merged graph can be
  432. * identified as coming from one particular graph in the original set of graphs.
  433. *
  434. * Notice that one does not, in general, obtain the merge of a set of graphs by concatenating
  435. * their corresponding N-triples documents and constructing the graph described by the merged
  436. * document, since if some of the documents use the same node identifiers, the merged document
  437. * will describe a graph in which some of the blank nodes have been 'accidentally' merged.
  438. * To merge Ntriples documents it is necessary to check if the same nodeID is used in two or
  439. * more documents, and to replace it with a distinct nodeID in each of them, before merging the
  440. * documents. (Not implemented yet !!!!!!!!!!!)
  441. *
  442. * @param object Model $model
  443. * @return object MemModel
  444. * @access public
  445. * @throws phpErrpr
  446. *
  447. */
  448. function & unite(& $model)
  449. {
  450. if (is_a($model,'ResModel'))
  451. return $this->model->unite($model->getModel());
  452. return $this->model->unite($model);
  453. }
  454. /**
  455. * Adds another model to this MemModel.
  456. * Duplicate statements are not removed.
  457. * If you don't want duplicates, use unite().
  458. * If any statement of the model to be added to this model contains a blankNode
  459. * with an identifier already existing in this model, a new blankNode is generated.
  460. *
  461. * @param object Model $model
  462. * @access public
  463. * @throws phpErrpr
  464. *
  465. */
  466. function addModel(&$model)
  467. {
  468. if (is_a($model,'ResModel'))
  469. return $this->model->addModel($model->getModel());
  470. return $this->model->addModel($model);
  471. }
  472. /**
  473. * Create a new RDF Container from type rdf:Alt
  474. * This method may return an existing container with the correct URI and model,
  475. * or it may construct a fresh one, as it sees fit.
  476. *
  477. * Subsequent operations on the returned Container may modify this model.
  478. *
  479. *
  480. * @param string $uri
  481. * @return object ResProperty
  482. * @access public
  483. */
  484. function createAlt($uri = null)
  485. {
  486. $resAlt = new ResAlt($uri);
  487. $resAlt->setAssociatedModel($this);
  488. return $resAlt;
  489. }
  490. /**
  491. * Create a new RDF Container from type rdf:Bag
  492. * This method may return an existing container with the correct URI and model,
  493. * or it may construct a fresh one, as it sees fit.
  494. *
  495. * Subsequent operations on the returned Container may modify this model.
  496. *
  497. *
  498. * @param string $uri
  499. * @return object ResProperty
  500. * @access public
  501. */
  502. function createBag($uri = null)
  503. {
  504. $resBag = new ResBag($uri);
  505. $resBag->setAssociatedModel($this);
  506. return $resBag;
  507. }
  508. /**
  509. * Create a new RDF Container from type rdf:Seq
  510. * This method may return an existing container with the correct URI and model,
  511. * or it may construct a fresh one, as it sees fit.
  512. *
  513. * Subsequent operations on the returned Container may modify this model.
  514. *
  515. *
  516. * @param string $uri
  517. * @return object ResProperty
  518. * @access public
  519. */
  520. function createSeq($uri = null)
  521. {
  522. $resSeq = new ResSeq($uri);
  523. $resSeq->setAssociatedModel($this);
  524. return $resSeq;
  525. }
  526. /**
  527. * Create a new RDF Collection from type rdf:List
  528. * This method may return an existing container with the correct URI and model,
  529. * or it may construct a fresh one, as it sees fit.
  530. *
  531. * Subsequent operations on the returned Container may modify this model.
  532. *
  533. *
  534. * @param string $uri
  535. * @return object ResProperty
  536. * @access public
  537. */
  538. function createList($uri = null)
  539. {
  540. $resList = new ResList($uri);
  541. $resList->setAssociatedModel($this);
  542. return $resList;
  543. }
  544. /**
  545. * Returns a reference to the underlying model (Mem/DB/InfModel) that contains the statements
  546. *
  547. *
  548. * @return object Model
  549. * @access public
  550. */
  551. function & getModel()
  552. {
  553. return $this->model;
  554. }
  555. /**
  556. * Internal method, that returns a resource URI that is unique for the Model.
  557. * URIs are generated using the base_uri of the Model, the prefix and a unique number.
  558. * If no prefix is defined, the bNode prefix, defined in constants.php, is used.
  559. *
  560. * @param string $prefix
  561. * @return string
  562. * @access private
  563. */
  564. function getUniqueResourceURI($bnodePrefix)
  565. {
  566. return $this->model->getUniqueResourceURI($bnodePrefix);
  567. }
  568. /**
  569. * Load a model from a file containing RDF, N3 or N-Triples.
  570. * This function recognizes the suffix of the filename (.n3 or .rdf) and
  571. * calls a suitable parser, if no $type is given as string ("rdf" "n3" "nt");
  572. * If the model is not empty, the contents of the file is added to this DbModel.
  573. *
  574. * @param string $filename
  575. * @param string $type
  576. * @param boolean $stream
  577. * @access public
  578. */
  579. function load($filename, $type = NULL, $stream=false)
  580. {
  581. $this->model->load($filename, $type, $stream);
  582. }
  583. /**
  584. * Return current baseURI.
  585. *
  586. * @return string
  587. * @access public
  588. */
  589. function getBaseURI()
  590. {
  591. return $this->model->getBaseURI();
  592. }
  593. /**
  594. * Saves the RDF,N3 or N-Triple serialization of the MemModel to a file.
  595. * You can decide to which format the model should be serialized by using a
  596. * corresponding suffix-string as $type parameter. If no $type parameter
  597. * is placed this method will serialize the model to XML/RDF format.
  598. * Returns FALSE if the MemModel couldn't be saved to the file.
  599. *
  600. * @access public
  601. * @param string $filename
  602. * @param string $type
  603. * @throws PhpError
  604. * @return boolean
  605. */
  606. function saveAs($filename, $type ='rdf')
  607. {
  608. return $this->model->saveAs($filename, $type ='rdf');
  609. }
  610. /**
  611. * Writes the RDF serialization of the MemModel as HTML table.
  612. *
  613. * @access public
  614. */
  615. function writeAsHTMLTable()
  616. {
  617. $this->model->writeAsHtmlTable();
  618. }
  619. /**
  620. * Returns a new model containing all the statements which are in both this model and another.
  621. *
  622. * @param object Model $model
  623. * @return object MemModel
  624. * @access public
  625. * @throws phpErrpr
  626. */
  627. function & intersect(& $model)
  628. {
  629. if (is_a($model,'ResModel'))
  630. return $this->model->intersect($model->getModel());
  631. return $this->model->intersect($model);
  632. }
  633. /**
  634. * converts a Resource,Blanknode,Literal into a ResResource, ResProperty, or ResLiteral
  635. *
  636. * @param object Node $node
  637. * @param boolean $isProperty
  638. * @return object ResResource / ResProperty / ResLiteral
  639. * @access private
  640. * @throws phpErrpr
  641. */
  642. function _node2ResNode($node, $isProperty = false)
  643. {
  644. if (is_a($node,'Literal'))
  645. {
  646. $return= new ResLiteral($node->getLabel(),$node->getLanguage());
  647. $return->setDatatype($node->getDatatype());
  648. $return->setAssociatedModel($this);
  649. return $return;
  650. }
  651. if (is_a($node,'Resource'))
  652. {
  653. if ($isProperty)
  654. {
  655. $res= new ResProperty($node->getLabel());
  656. } else
  657. {
  658. $res= new ResResource($node->getLabel());
  659. }
  660. $res->setAssociatedModel($this);
  661. if (is_a($node,'Blanknode'))
  662. $res->setIsAnon(true);
  663. return $res;
  664. }
  665. }
  666. /**
  667. * converts a ResResource, ResProperty, or ResLiteral into a Resource, Blanknode, or Literal
  668. *
  669. * @param object ResNode $resNode
  670. * @return object Node
  671. * @access private
  672. * @throws phpErrpr
  673. */
  674. function _resNode2Node($resNode)
  675. {
  676. if (is_a($resNode,'ResResource'))
  677. {
  678. if ($resNode->getIsAnon())
  679. {
  680. $return=new BlankNode($resNode->getURI());
  681. } else
  682. {
  683. $return=new Resource($resNode->getURI());
  684. }
  685. return $return;
  686. }
  687. if (is_a($resNode,'ResLiteral'))
  688. {
  689. $literal=new Literal($resNode->getLabel(),$resNode->getLanguage());
  690. if ($resNode->getDatatype() != null)
  691. $literal->setDatatype($resNode->getDatatype());
  692. return $literal;
  693. }
  694. }
  695. /**
  696. * Set a base URI for the MemModel.
  697. * Affects creating of new resources and serialization syntax.
  698. * If the URI doesn't end with # : or /, then a # is added to the URI.
  699. * @param string $uri
  700. * @access public
  701. */
  702. function setBaseURI($uri)
  703. {
  704. $this->model->setBaseURI($uri);
  705. }
  706. /**
  707. * Writes the RDF serialization of the MemModel as HTML table.
  708. *
  709. * @access public
  710. * @return string
  711. */
  712. function writeRdfToString()
  713. {
  714. return $this->model->writeRdfToString();
  715. }
  716. /**
  717. * Perform an RDQL query on this MemModel.
  718. * This method returns an associative array of variable bindings.
  719. * The values of the query variables can either be RAP's objects (instances of Node)
  720. * if $returnNodes set to TRUE, or their string serialization.
  721. *
  722. * @access public
  723. * @param string $queryString
  724. * @param boolean $returnNodes
  725. * @return array [][?VARNAME] = object Node (if $returnNodes = TRUE)
  726. * OR array [][?VARNAME] = string
  727. *
  728. */
  729. function & rdqlQuery($queryString, $returnNodes = TRUE)
  730. {
  731. $ret = $this->model->rdqlQuery($queryString, $returnNodes);
  732. return $ret;
  733. }
  734. /**
  735. * Perform an RDQL query on this MemModel.
  736. * This method returns an RdqlResultIterator of variable bindings.
  737. * The values of the query variables can either be RAP's objects (instances of Node)
  738. * if $returnNodes set to TRUE, or their string serialization.
  739. *
  740. * @access public
  741. * @param string $queryString
  742. * @param boolean $returnNodes
  743. * @return object RdqlResultIterator = with values as object Node (if $returnNodes = TRUE)
  744. * OR object RdqlResultIterator = with values as strings if (if $returnNodes = FALSE)
  745. *
  746. */
  747. function rdqlQueryAsIterator($queryString, $returnNodes = TRUE)
  748. {
  749. return $this->model->rdqlQueryAsIterator($queryString, $returnNodes);
  750. }
  751. /**
  752. * Returns the models namespaces.
  753. *
  754. * @author Tobias Gauß <tobias.gauss@web.de>
  755. * @access public
  756. * @return Array
  757. */
  758. function getParsedNamespaces(){
  759. return $this->model->getParsedNamespaces();
  760. }
  761. /**
  762. * Adds the namespaces to the model. This method is called by
  763. * the parser. !!!! addParsedNamespaces() not overwrites manual
  764. * added namespaces in the model !!!!
  765. *
  766. * @author Tobias Gauß <tobias.gauss@web.de>
  767. * @access public
  768. * @param Array $newNs
  769. */
  770. function addParsedNamespaces($newNs){
  771. $this->model->addParsedNamespaces($newNs);
  772. }
  773. /**
  774. * Adds a namespace and prefix to the model.
  775. *
  776. * @author Tobias Gauß <tobias.gauss@web.de>
  777. * @access public
  778. * @param String $prefix, String $nmsp
  779. */
  780. function addNamespace($prefix, $namespace){
  781. $this->model->addNamespace($prefix, $namespace);
  782. }
  783. /**
  784. * removes a single namespace from the model
  785. *
  786. * @author Tobias Gauß <tobias.gauss@web.de>
  787. * @access public
  788. * @param String $nmsp
  789. */
  790. function removeNamespace($nmsp){
  791. return $this->model->removeNamespace($nmsp);
  792. }
  793. }
  794. ?>