. */ include_once 'phing/types/DataType.php'; include_once 'phing/Project.php'; include_once 'phing/util/regexp/Regexp.php'; /* * A regular expression datatype. Keeps an instance of the * compiled expression for speed purposes. This compiled * expression is lazily evaluated (it is compiled the first * time it is needed). The syntax is the dependent on which * regular expression type you are using. * * @author Yannick Lecaillez * @version $Revision: 1.6 $ $Date: 2003/12/24 12:38:42 $ * @access public * @see phing.util.regex.RegexMatcher * @package phing.types */ class RegularExpression extends DataType { private $regexp = null; private $ignoreCase = false; function __construct() { $this->regexp = new Regexp(); } function setPattern($pattern) { $this->regexp->setPattern($pattern); } function setReplace($replace) { $this->regexp->setReplace($replace); } function getPattern($p) { if ( $this->isReference() ) { $ref = $this->getRef($p); return $ref->getPattern($p); } return $this->regexp->getPattern(); } function getReplace($p) { if ( $this->isReference() ) { $ref = $this->getRef($p); return $ref->getReplace($p); } return $this->regexp->getReplace(); } function setIgnoreCase($bit) { $this->regexp->setIgnoreCase($bit); } function getIgnoreCase() { return $this->regexp->getIgnoreCase(); } function getRegexp(Project $p) { if ( $this->isReference() ) { $ref = $this->getRef($p); return $ref->getRegexp($p); } return $this->regexp; } function getRef(Project $p) { if ( !$this->checked ) { $stk = array(); array_push($stk, $this); $this->dieOnCircularReference($stk, $p); } $o = $this->ref->getReferencedObject($p); if ( !($o instanceof RegularExpression) ) { throw new BuildException($this->ref->getRefId()." doesn't denote a RegularExpression"); } else { return $o; } } } ?>