Source for file Resource.php

Documentation is available at Resource.php

  1. <?php
  2.  
  3. // ----------------------------------------------------------------------------------
  4. // Class: Resource
  5. // ----------------------------------------------------------------------------------
  6.  
  7. /**
  8. * An RDF resource.
  9. * Every RDF resource must have a URIref.
  10. * URIrefs are treated as logical constants, i.e. as names which denote something
  11. * (the things are called ''resources'', but no assumptions are made about the nature of resources.)
  12. * Many RDF resources are pieces of vocabulary. They typically have a namespace
  13. * and a local name. In this case, a URI is composed as a
  14. * concatenation of the namespace and the local name.
  15. *
  16. * <BR><BR>History:<UL>
  17. * <LI>11-09-2003 : Fixed bug in equals() <radol@gmx.de></LI>
  18. * <LI>09-30-2002 : Fixed bug in getNamespace() and getLocalName().</LI>
  19. * <LI>09-10-2002 : First version of this class.</LI>
  20. * </UL>
  21. *
  22. * @version V0.9.3
  23. * @author Chris Bizer <chris@bizer.de>
  24. *
  25. * @package model
  26. * @todo nothing
  27. * @access public
  28. *
  29. */
  30. class Resource extends Node {
  31.  
  32. /**
  33. * URIref to the resource
  34. * @var string
  35. * @access private
  36. */
  37. var $uri;
  38. /**
  39. * Constructor
  40. * Takes an URI or a namespace/localname combination
  41. *
  42. * @param string $namespace_or_uri
  43. * @param string $localName
  44. * @access public
  45. */
  46. function Resource($namespace_or_uri , $localName = NULL) {
  47. if ($localName == NULL) {
  48. $this->uri = $namespace_or_uri;
  49. } else {
  50. $this->uri = $namespace_or_uri . $localName;
  51. }
  52. }
  53.  
  54. /**
  55. * Returns the URI of the resource.
  56. * @return string
  57. * @access public
  58. */
  59. function getURI() {
  60. return $this->uri;
  61. }
  62.  
  63. /**
  64. * Returns the label of the resource, which is the URI of the resource.
  65. * @access public
  66. * @return string
  67. */
  68. function getLabel() {
  69. return $this->getURI();
  70. }
  71. /**
  72. * Returns the namespace of the resource. May return null.
  73. * @access public
  74. * @return string
  75. */
  76. function getNamespace() {
  77. // Import Package Utility
  78. include_once(RDFAPI_INCLUDE_DIR.PACKAGE_UTILITY);
  79. return RDFUtil::guessNamespace($this->uri);
  80. }
  81.  
  82. /**
  83. * Returns the local name of the resource.
  84. * @access public
  85. * @return string
  86. */
  87. function getLocalName() {
  88. // Import Package Utility
  89. include_once(RDFAPI_INCLUDE_DIR.PACKAGE_UTILITY);
  90. return RDFUtil::guessName($this->uri);
  91. }
  92. /**
  93. * Dumps resource.
  94. * @access public
  95. * @return string
  96. */
  97. function toString() {
  98. return ''Resource("'' . $this->uri .''")'';
  99. }
  100.  
  101. /**
  102. * Checks if the resource equals another resource.
  103. * Two resources are equal, if they have the same URI
  104. *
  105. * @access public
  106. * @param object resource $that
  107. * @return boolean
  108. */
  109. function equals ($that) {
  110. if ($this == $that) {
  111. return true;
  112. }
  113. if (($that == NULL) or !(is_a($that, ''Resource'')) or (is_a($that, ''BlankNode''))) {
  114. return false;
  115. }
  116. if ($this->getURI() == $that->getURI()) {
  117. return true;
  118. }
  119. return false;
  120. }
  121.  
  122. }
  123.  
  124. ?>

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