Source for file HarmoniId.class.php

Documentation is available at HarmoniId.class.php

  1. <?php
  2.  
  3. require_once(OKI2."/osid/shared/Id.php");
  4.  
  5. /**
  6. * Id represents a unique identifier. A String representation of the unique
  7. * identifier is available with getIdString(). To convert from a String
  8. * representation of the identifier to the identifier object,
  9. * org.osid.shared.Id, use getId(String). Id can determine if it is equal to
  10. * another Id.
  11. *
  12. * <p>
  13. * OSID Version: 2.0
  14. * </p>
  15. *
  16. * @package harmoni.osid_v2.shared
  17. *
  18. * @copyright Copyright &copy; 2005, Middlebury College
  19. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  20. *
  21. * @version $Id: HarmoniId.class.php,v 1.13 2007/09/04 20:25:48 adamfranco Exp $
  22. */
  23. class HarmoniId
  24. extends Id
  25. {
  26.  
  27. /**
  28. * @var string $_id The id of this id.
  29. */
  30. var $_id;
  31. /**
  32. * Constructor. Creates a HarmoniId with id = $id or a new unique id if $id is NULL.
  33. * @param string $id The desired id. If NULL, a new unique id is used.
  34. *
  35. */
  36. function HarmoniId ( $id ) {
  37. // ** parameter validation
  38. ArgumentValidator::validate($id,
  39. OrValidatorRule::getRule(
  40. NonzeroLengthStringValidatorRule::getRule(),
  41. IntegerValidatorRule::getRule()),
  42. true);
  43. // ** end of parameter validation
  44. // if (ereg('^#.+$', $id))
  45. $this->_id = $id;
  46. // else
  47. // $this->_id = '#'.md5($id);
  48. }
  49.  
  50. /**
  51. * Return the String representation of this unique Id.
  52. *
  53. * @return string
  54. *
  55. * @throws object SharedException An exception with one of the
  56. * following messages defined in org.osid.shared.SharedException
  57. * may be thrown: {@link }
  58. * org.osid.shared.SharedException#UNKNOWN_TYPE UNKNOWN_TYPE},
  59. * {@link org.osid.shared.SharedException#PERMISSION_DENIED}
  60. * PERMISSION_DENIED}, {@link }
  61. * org.osid.shared.SharedException#CONFIGURATION_ERROR
  62. * CONFIGURATION_ERROR}, {@link }
  63. * org.osid.shared.SharedException#UNIMPLEMENTED UNIMPLEMENTED}
  64. *
  65. * @access public
  66. */
  67. function getIdString () {
  68. return $this->_id;
  69. }
  70. /**
  71. * Answer the string version of this id. Enables transparent Id to string
  72. * translation.
  73. *
  74. * @return string
  75. * @access public
  76. * @since 8/22/07
  77. */
  78. public function __toString () {
  79. return $this->getIdString();
  80. }
  81. /**
  82. * Answer a String whose characters are a description of the receiver.
  83. * Override this method as needed to provide a better representation
  84. *
  85. * @return string
  86. * @access public
  87. * @since 7/11/05
  88. */
  89. function printableString () {
  90. return $this->getIdString();
  91. }
  92.  
  93. /**
  94. * Tests if an unique Id equals this unique Id.
  95. *
  96. * @param object Id $id
  97. *
  98. * @return boolean
  99. *
  100. * @throws object SharedException An exception with one of the
  101. * following messages defined in org.osid.shared.SharedException
  102. * may be thrown: {@link }
  103. * org.osid.shared.SharedException#UNKNOWN_TYPE UNKNOWN_TYPE},
  104. * {@link org.osid.shared.SharedException#PERMISSION_DENIED}
  105. * PERMISSION_DENIED}, {@link }
  106. * org.osid.shared.SharedException#CONFIGURATION_ERROR
  107. * CONFIGURATION_ERROR}, {@link }
  108. * org.osid.shared.SharedException#UNIMPLEMENTED UNIMPLEMENTED},
  109. * {@link org.osid.shared.SharedException#NULL_ARGUMENT}
  110. * NULL_ARGUMENT}
  111. *
  112. * @access public
  113. */
  114. function isEqual ( $id ) {
  115. // Validate the arguments
  116. ArgumentValidator::validate($id, ExtendsValidatorRule::getRule("Id"));
  117. return ($id->getIdString() == $this->_id) ? true : false;
  118. }
  119.  
  120. }
  121.  
  122. ?>

Documentation generated on Wed, 19 Sep 2007 10:24:03 -0400 by phpDocumentor 1.3.0RC3