Source for file Quad.php

Documentation is available at Quad.php

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

Documentation generated on Fri, 13 Jan 2006 07:48:53 +0100 by phpDocumentor 1.3.0RC4