Source for file RegexStringParser.class.php

Documentation is available at RegexStringParser.class.php

  1. <?php
  2. /**
  3. * @since 5/24/05
  4. * @package harmoni.primitives.chronology.string_parsers
  5. *
  6. * @copyright Copyright &copy; 2005, Middlebury College
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  8. *
  9. * @version $Id: RegexStringParser.class.php,v 1.2 2006/06/26 12:55:08 adamfranco Exp $
  10. *
  11. * @link http://harmoni.sourceforge.net/
  12. * @author Adam Franco <adam AT adamfranco DOT com> <afranco AT middlebury DOT edu>
  13. */
  14. require_once(dirname(__FILE__)."/StringParser.class.php");
  15.  
  16. /**
  17. * RegexStringParser is an abstract class that implements a common canHandle()
  18. * method for decendents as well as defines a 'getRegex()' class method which must
  19. * be set by decendent classes.
  20. *
  21. * @since 5/24/05
  22. * @package harmoni.primitives.chronology.string_parsers
  23. *
  24. * @copyright Copyright &copy; 2005, Middlebury College
  25. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  26. *
  27. * @version $Id: RegexStringParser.class.php,v 1.2 2006/06/26 12:55:08 adamfranco Exp $
  28. *
  29. * @link http://harmoni.sourceforge.net/
  30. * @author Adam Franco <adam AT adamfranco DOT com> <afranco AT middlebury DOT edu>
  31. */
  32. class RegexStringParser
  33. extends StringParser
  34. {
  35.  
  36. /*******************************************************
  37. * Instance Methods
  38. *********************************************************/
  39.  
  40. /**
  41. * Answer True if this parser can handle the format of the string passed.
  42. *
  43. * @return boolean
  44. * @access public
  45. * @since 5/24/05
  46. */
  47. function canHandle () {
  48. return preg_match($this->getRegex(), $this->input);
  49. }
  50. /**
  51. * Return the regular expression used by this parser
  52. *
  53. * @return string
  54. * @access protected
  55. * @since 5/24/05
  56. */
  57. function getRegex () {
  58. die(__CLASS__.'::'.__FUNCTION__.'() was not overridden by a child class.');
  59. }
  60. }
  61.  
  62. ?>

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