Source for file String.class.php

Documentation is available at String.class.php

  1. <?php
  2.  
  3. require_once(dirname(__FILE__)."/../Objects/SObject.class.php");
  4.  
  5.  
  6. /**
  7. * A simple String data type.
  8. *
  9. * @package harmoni.primitives.collections-text
  10. *
  11. * @copyright Copyright &copy; 2005, Middlebury College
  12. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  13. *
  14. * @version $Id: String.class.php,v 1.6 2007/09/04 20:25:27 adamfranco Exp $
  15. */
  16. class String
  17. extends SObject
  18. {
  19. var $_string;
  20.  
  21. function String($string="") {
  22. $this->_string = (string) $string;
  23. }
  24. /**
  25. * Answer a String whose characters are a description of the receiver.
  26. * Override this method as needed to provide a better representation
  27. *
  28. * @return string
  29. * @access public
  30. * @since 7/11/05
  31. */
  32. function printableString () {
  33. return $this->_string;
  34. }
  35. /**
  36. * Instantiates a new String object with the passed value.
  37. * @param string $value
  38. * @return ref object
  39. * @access public
  40. * @static
  41. */
  42. function withValue($value) {
  43. $string = new String($value);
  44. return $string;
  45. }
  46. /**
  47. * Instantiates a new String object with the passed value.
  48. *
  49. * allowing 'fromString' for string values
  50. * @param string $aString
  51. * @return ref object
  52. * @access public
  53. * @static
  54. */
  55. function fromString($aString) {
  56. $string = new String($aString);
  57. return $string;
  58. }
  59.  
  60. /**
  61. * Answer whether the receiver and the argument are the same.
  62. * If = is redefined in any subclass, consider also redefining the
  63. * message hash.
  64. *
  65. * @param object $anObject
  66. * @return boolean
  67. * @access public
  68. * @since 7/11/05
  69. */
  70. function isEqualTo ( $anObject ) {
  71. if (!method_exists($anObject, 'asString'))
  72. return false;
  73. return strcmp($anObject->asString(), $this->asString())==0?true:false;
  74. }
  75. }

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