Source for file Quad.php

Documentation is available at Quad.php

  1. <?PHP
  2. // ----------------------------------------------------------------------------------
  3. // Class: Quad
  4. // ----------------------------------------------------------------------------------
  5.  
  6.  
  7.  
  8. /**
  9. *
  10. * A Triple in a RDF dataset, consisting of four Jena Nodes: graphName,
  11. * subject, predicate, and object.
  12. *
  13. * <BR><BR>History:<UL>
  14. * <LI>05-03-2005 : First version of this class.</LI>
  15. *
  16. * @version V0.9
  17. * @author Daniel Westphal (http://www.d-westphal.de)
  18. *
  19. * @package dataset
  20. * @access public
  21. ***/
  22. class Quad
  23. {
  24. /**
  25. * Name of the NamedGraphMem
  26. *
  27. * @var Resource
  28. * @access private
  29. */
  30. var $graphName;
  31. /**
  32. * Statement
  33. *
  34. * @var Statement
  35. * @access private
  36. */
  37. var $statement;
  38. /**
  39. * Constructor
  40. * Creates a Quad from four Nodes.
  41. *
  42. * @param Resource
  43. * @param Resource
  44. * @param Resource
  45. * @param Resource
  46. * @access public
  47. */
  48. function Quad($graphName,$subject,$predicate,$object)
  49. {
  50. if (!is_a($graphName, 'Resource'))
  51. {
  52. $errmsg = RDFAPI_ERROR .
  53. '(class: Quad; method: new): Resource expected as graphName.';
  54. trigger_error($errmsg, E_USER_ERROR);
  55. }
  56. $this->statement=new Statement($subject,$predicate,$object);
  57. $this->graphName=$graphName;
  58. }
  59. /**
  60. * Sets the graph name.
  61. *
  62. * @param Resource
  63. * @access public
  64. */
  65. function setGraphName($graphName)
  66. {
  67. $this->graphName=$graphName;
  68. }
  69. /**
  70. * Return the graph name.
  71. *
  72. * @return Resource
  73. * @access public
  74. */
  75. function getGraphName()
  76. {
  77. return $this->graphName;
  78. }
  79. /**
  80. * Return a human-readable (sort of) string "graphname { s p o . }"
  81. * describing the quad.
  82. * @return string
  83. */
  84. function toString()
  85. {
  86. return 'GraphName('.$this->graphName->getLabel().') '.$this->statement->toString();
  87. }
  88. /**
  89. * Return the subject.
  90. *
  91. * @return Resource
  92. * @access public
  93. */
  94. function getSubject()
  95. {
  96. return $this->statement->getSubject();
  97. }
  98. /**
  99. * Return the predicate.
  100. *
  101. * @return Resource
  102. * @access public
  103. */
  104. function getPredicate()
  105. {
  106. return $this->statement->getPredicate();
  107. }
  108. /**
  109. * Return the object.
  110. *
  111. * @return Resource
  112. * @access public
  113. */
  114. function getObject()
  115. {
  116. return $this->statement->getObject();
  117. }
  118. /**
  119. * Return the statement(subject,predicate,object).
  120. *
  121. * @return statement
  122. * @access public
  123. */
  124. function getStatement()
  125. {
  126. return $this->statement;
  127. }
  128. /**
  129. * Checks, if two quads are equal.
  130. *
  131. * @param Quad
  132. * @return boolean
  133. * @access public
  134. */
  135. function equals($quad)
  136. {
  137. return ($this->graphName->equals($quad->getGraphName()) && $this->statement->equals($quad->getStatement()));
  138. }
  139. }
  140. ?>

Documentation generated on Thu, 7 Jul 2005 13:42:38 +0200 by phpDocumentor 1.3.0RC3