summaryrefslogtreecommitdiff
path: root/buildscripts/phing/classes/phing/types/selectors
diff options
context:
space:
mode:
Diffstat (limited to 'buildscripts/phing/classes/phing/types/selectors')
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/AndSelector.php67
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/BaseExtendSelector.php62
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/BaseSelector.php84
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/BaseSelectorContainer.php270
-rwxr-xr-xbuildscripts/phing/classes/phing/types/selectors/ContainsRegexpSelector.php164
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/ContainsSelector.php151
-rwxr-xr-xbuildscripts/phing/classes/phing/types/selectors/DateSelector.php214
-rwxr-xr-xbuildscripts/phing/classes/phing/types/selectors/DependSelector.php151
-rwxr-xr-xbuildscripts/phing/classes/phing/types/selectors/DepthSelector.php158
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/ExtendFileSelector.php43
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/ExtendSelector.php124
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/FileSelector.php47
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/FilenameSelector.php157
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/MajoritySelector.php92
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/NoneSelector.php71
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/NotSelector.php59
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/OrSelector.php72
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/PresentSelector.php154
-rwxr-xr-xbuildscripts/phing/classes/phing/types/selectors/SelectSelector.php124
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/SelectorContainer.php141
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/SelectorScanner.php55
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/SelectorUtils.php200
-rw-r--r--buildscripts/phing/classes/phing/types/selectors/SizeSelector.php228
-rwxr-xr-xbuildscripts/phing/classes/phing/types/selectors/TypeSelector.php120
24 files changed, 3008 insertions, 0 deletions
diff --git a/buildscripts/phing/classes/phing/types/selectors/AndSelector.php b/buildscripts/phing/classes/phing/types/selectors/AndSelector.php
new file mode 100644
index 00000000..1a27829d
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/AndSelector.php
@@ -0,0 +1,67 @@
+<?php
+/*
+ * $Id: f36556afb9487cce2e56d5c174e3ce4c43ef968f $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/selectors/BaseSelectorContainer.php';
+
+/**
+ * This selector has a collection of other selectors, all of which have to
+ * select a file in order for this selector to select it.
+ *
+ * @author Hans Lellelid, hans@xmpl.org (Phing)
+ * @author <a href="mailto:bruce@callenish.com">Bruce Atherton</a> (Ant)
+ * @package phing.types.selectors
+ */
+class AndSelector extends BaseSelectorContainer {
+
+ public function toString() {
+ $buf = "";
+ if ($this->hasSelectors()) {
+ $buf .= "{andselect: ";
+ $buf .= parent::toString();
+ $buf .= "}";
+ }
+ return $buf;
+ }
+
+ /**
+ * Returns true (the file is selected) only if all other selectors
+ * agree that the file should be selected.
+ *
+ * @param basedir the base directory the scan is being done from
+ * @param filename the name of the file to check
+ * @param file a PhingFile object for the filename that the selector
+ * can use
+ * @return whether the file should be selected or not
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+ $this->validate();
+ $selectors = $this->selectorElements();
+ for($i=0,$size=count($selectors); $i < $size; $i++) {
+ $result = $selectors[$i]->isSelected($basedir, $filename, $file);
+ if (!$result) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/BaseExtendSelector.php b/buildscripts/phing/classes/phing/types/selectors/BaseExtendSelector.php
new file mode 100644
index 00000000..d8ae0444
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/BaseExtendSelector.php
@@ -0,0 +1,62 @@
+<?php
+
+/*
+ * $Id: 0c36c2b00f8ab8d20025b9ad38043c762b6fc7f9 $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/selectors/ExtendFileSelector.php';
+require_once 'phing/types/selectors/BaseSelector.php';
+include_once 'phing/types/Parameter.php';
+
+/**
+ * Convenience base class for all selectors accessed through ExtendSelector.
+ * It provides support for gathering the parameters together as well as for
+ * assigning an error message and throwing a build exception if an error is
+ * detected.
+ *
+ * @author Hans Lellelid, hans@xmpl.org (Phing)
+ * @author Bruce Atherton, bruce@callenish.com (Ant)
+ * @package phing.types.selectors
+ */
+abstract class BaseExtendSelector extends BaseSelector implements ExtendFileSelector {
+
+ /** The passed in parameter array. */
+ protected $parameters = null;
+
+ /**
+ * Set all the Parameters for this custom selector, collected by
+ * the ExtendSelector class.
+ *
+ * @param parameters the complete set of parameters for this selector
+ */
+ public function setParameters($parameters) {
+ $this->parameters = $parameters;
+ }
+
+ /**
+ * Allows access to the parameters gathered and set within the
+ * &lt;custom&gt; tag.
+ *
+ * @return the set of parameters defined for this selector
+ */
+ protected function getParameters() {
+ return $this->parameters;
+ }
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/BaseSelector.php b/buildscripts/phing/classes/phing/types/selectors/BaseSelector.php
new file mode 100644
index 00000000..c463fa33
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/BaseSelector.php
@@ -0,0 +1,84 @@
+<?php
+/*
+ * $Id: e1f8e20eb87ea465d29ba3add6fada790642bcf8 $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/selectors/FileSelector.php';
+
+/**
+ * A convenience base class that you can subclass Selectors from. It
+ * provides some helpful common behaviour. Note that there is no need
+ * for Selectors to inherit from this class, it is only necessary that
+ * they implement FileSelector.
+ *
+ * @author <a href="mailto:bruce@callenish.com">Bruce Atherton</a>
+ * @package phing.types.selectors
+ */
+abstract class BaseSelector extends DataType implements FileSelector {
+
+ private $errmsg = null;
+
+ /**
+ * Allows all selectors to indicate a setup error. Note that only
+ * the first error message is recorded.
+ *
+ * @param msg The error message any BuildException should throw.
+ */
+ public function setError($msg) {
+ if ($this->errmsg === null) {
+ $this->errmsg = $msg;
+ }
+ }
+
+ /**
+ * Returns any error messages that have been set.
+ *
+ * @return the error condition
+ */
+ public function getError() {
+ return $this->errmsg;
+ }
+
+
+ /**
+ * <p>Subclasses can override this method to provide checking of their
+ * state. So long as they call validate() from isSelected(), this will
+ * be called automatically (unless they override validate()).</p>
+ * <p>Implementations should check for incorrect settings and call
+ * setError() as necessary.</p>
+ */
+ public function verifySettings() {
+ }
+
+ /**
+ * Subclasses can use this to throw the requisite exception
+ * in isSelected() in the case of an error condition.
+ */
+ public function validate() {
+ if ($this->getError() === null) {
+ $this->verifySettings();
+ }
+ if ($this->getError() !== null) {
+ throw new BuildException($this->errmsg);
+ }
+ }
+
+}
+
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/BaseSelectorContainer.php b/buildscripts/phing/classes/phing/types/selectors/BaseSelectorContainer.php
new file mode 100644
index 00000000..3b2a10b1
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/BaseSelectorContainer.php
@@ -0,0 +1,270 @@
+<?php
+
+/*
+ * $Id: 9dd90d3e78d751562859bbe5179db148ee5b025c $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/selectors/SelectorContainer.php';
+require_once 'phing/types/selectors/BaseSelector.php';
+
+/**
+ * This is the base class for selectors that can contain other selectors.
+ *
+ * @author <a href="mailto:bruce@callenish.com">Bruce Atherton</a> (Ant)
+ * @package phing.types.selectors
+ */
+abstract class BaseSelectorContainer extends BaseSelector implements SelectorContainer {
+
+ private $selectorsList = array();
+
+ /**
+ * Indicates whether there are any selectors here.
+ */
+ public function hasSelectors() {
+ return !(empty($this->selectorsList));
+ }
+
+ /**
+ * Gives the count of the number of selectors in this container
+ */
+ public function selectorCount() {
+ return count($this->selectorsList);
+ }
+
+ /**
+ * Returns a copy of the selectors as an array.
+ */
+ public function getSelectors(Project $p) {
+ $result = array();
+ for($i=0,$size=count($this->selectorsList); $i < $size; $i++) {
+ $result[] = clone $this->selectorsList[$i];
+ }
+ return $result;
+ }
+
+ /**
+ * Returns an array for accessing the set of selectors (not a copy).
+ */
+ public function selectorElements() {
+ return $this->selectorsList;
+ }
+
+ /**
+ * Convert the Selectors within this container to a string. This will
+ * just be a helper class for the subclasses that put their own name
+ * around the contents listed here.
+ *
+ * @return comma separated list of Selectors contained in this one
+ */
+ public function toString() {
+ $buf = "";
+ $arr = $this->selectorElements();
+ for($i=0,$size=count($arr); $i < $size; $i++) {
+ $buf .= $arr[$i]->toString() . (isset($arr[$i+1]) ? ', ' : '');
+ }
+ return $buf;
+ }
+
+ /**
+ * Add a new selector into this container.
+ *
+ * @param selector the new selector to add
+ * @return the selector that was added
+ */
+ public function appendSelector(FileSelector $selector) {
+ $this->selectorsList[] = $selector;
+ }
+
+ /**
+ * <p>This implementation validates the container by calling
+ * verifySettings() and then validates each contained selector
+ * provided that the selector implements the validate interface.
+ * </p>
+ * <p>Ordinarily, this will validate all the elements of a selector
+ * container even if the isSelected() method of some elements is
+ * never called. This has two effects:</p>
+ * <ul>
+ * <li>Validation will often occur twice.
+ * <li>Since it is not required that selectors derive from
+ * BaseSelector, there could be selectors in the container whose
+ * error conditions are not detected if their isSelected() call
+ * is never made.
+ * </ul>
+ */
+ public function validate() {
+ $this->verifySettings();
+ $errmsg = $this->getError();
+ if ($errmsg !== null) {
+ throw new BuildException($errmsg);
+ }
+ foreach($this->selectorsList as $o) {
+ if ($o instanceof BaseSelector) {
+ $o->validate();
+ }
+ }
+ }
+
+ /* Methods below all add specific selectors */
+
+ /**
+ * add a "Select" selector entry on the selector list
+ */
+ public function createSelector() {
+ $o = new SelectSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add an "And" selector entry on the selector list
+ */
+ public function createAnd() {
+ $o = new AndSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add an "Or" selector entry on the selector list
+ */
+ public function createOr() {
+ $o = new OrSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add a "Not" selector entry on the selector list
+ */
+ public function createNot() {
+ $o = new NotSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add a "None" selector entry on the selector list
+ */
+ public function createNone() {
+ $o = new NoneSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add a majority selector entry on the selector list
+ */
+ public function createMajority() {
+ $o = new MajoritySelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add a selector date entry on the selector list
+ */
+ public function createDate() {
+ $o = new DateSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add a selector size entry on the selector list
+ */
+ public function createSize() {
+ $o = new SizeSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add a selector filename entry on the selector list
+ */
+ public function createFilename() {
+ $o = new FilenameSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add an extended selector entry on the selector list
+ */
+ public function createCustom() {
+ $o = new ExtendSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add a contains selector entry on the selector list
+ */
+ public function createContains() {
+ $o = new ContainsSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add a contains selector entry on the selector list
+ */
+ public function createContainsRegexp() {
+ $o = new ContainsRegexpSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add a present selector entry on the selector list
+ */
+ public function createPresent() {
+ $o = new PresentSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add a depth selector entry on the selector list
+ */
+ public function createDepth() {
+ $o = new DepthSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add a depends selector entry on the selector list
+ */
+ public function createDepend() {
+ $o = new DependSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+ /**
+ * add a type selector entry on the selector list
+ */
+ public function createType() {
+ $o = new TypeSelector();
+ $this->appendSelector($o);
+ return $o;
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/ContainsRegexpSelector.php b/buildscripts/phing/classes/phing/types/selectors/ContainsRegexpSelector.php
new file mode 100755
index 00000000..5b45bac8
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/ContainsRegexpSelector.php
@@ -0,0 +1,164 @@
+<?php
+
+/*
+ * $Id: 2a891d7cc3fb1b710b72d51e6a8cf2d0b553f91a $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/selectors/BaseExtendSelector.php';
+include_once 'phing/types/RegularExpression.php';
+
+/**
+ * Selector that filters files based on whether they contain a
+ * particular string using regexp.
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @version $Id$
+ * @package phing.types.selectors
+ */
+class ContainsRegexpSelector extends BaseExtendSelector {
+
+ /** @var string The expression set from XML. */
+ private $userProvidedExpression;
+
+ /** @var Regexp */
+ private $myExpression;
+
+ private $casesensitive = true;
+
+ /** @var RegularExpression */
+ private $myRegExp;
+
+ const EXPRESSION_KEY = "expression";
+
+ const CASE_KEY = "casesensitive";
+
+ public function toString() {
+ $buf = "{containsregexpselector expression: ";
+ $buf .= $this->userProvidedExpression;
+ $buf .= " casesensitive: ";
+ if ($this->casesensitive) {
+ $buf .= "true";
+ } else {
+ $buf .= "false";
+ }
+ $buf .= "}";
+ return $buf;
+ }
+
+ /**
+ * The expression to match on within a file.
+ *
+ * @param string $exp the string that a file must contain to be selected.
+ */
+ public function setExpression($exp) {
+ $this->userProvidedExpression = $exp;
+ }
+
+ /**
+ * Whether to ignore case in the regex match.
+ *
+ * @param boolean $casesensitive whether to pay attention to case sensitivity
+ */
+ public function setCasesensitive($casesensitive) {
+ $this->casesensitive = $casesensitive;
+ }
+
+ /**
+ * When using this as a custom selector, this method will be called.
+ * It translates each parameter into the appropriate setXXX() call.
+ *
+ * @param array $parameters the complete set of parameters for this selector
+ */
+ public function setParameters($parameters) {
+ parent::setParameters($parameters);
+ if ($parameters !== null) {
+ for ($i=0,$size=count($parameters); $i < $size; $i++) {
+ $paramname = $parameters[$i]->getName();
+ switch(strtolower($paramname)) {
+ case self::EXPRESSION_KEY:
+ $this->setExpression($parameters[$i]->getValue());
+ break;
+ case self::CASE_KEY:
+ $this->setCasesensitive($parameters[$i]->getValue());
+ break;
+ default:
+ $this->setError("Invalid parameter " . $paramname);
+ }
+ } // for each param
+ } // if params
+ }
+
+ /**
+ * Checks to make sure all settings are kosher. In this case, it
+ * means that the pattern attribute has been set.
+ *
+ */
+ public function verifySettings() {
+ if ($this->userProvidedExpression === null) {
+ $this->setError("The expression attribute is required");
+ }
+ }
+
+ /**
+ * The heart of the matter. This is where the selector gets to decide
+ * on the inclusion of a file in a particular fileset.
+ *
+ * @param basedir the base directory the scan is being done from
+ * @param filename is the name of the file to check
+ * @param file a PhingFile object the selector can use
+ * @return whether the file should be selected or not
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+
+ $this->validate();
+
+ if ($file->isDirectory()) {
+ return true;
+ }
+
+ if ($this->myRegExp === null) {
+ $this->myRegExp = new RegularExpression();
+ $this->myRegExp->setPattern($this->userProvidedExpression);
+ if (!$this->casesensitive) {
+ $this->myRegExp->setIgnoreCase(true);
+ }
+ $this->myExpression = $this->myRegExp->getRegexp($this->getProject());
+ }
+
+ $in = null;
+ try {
+ $in = new BufferedReader(new FileReader($file));
+ $teststr = $in->readLine();
+ while ($teststr !== null) {
+ if ($this->myExpression->matches($teststr)) {
+ return true;
+ }
+ $teststr = $in->readLine();
+ }
+ return false;
+ } catch (IOException $ioe) {
+ if ($in) $in->close();
+ throw new BuildException("Could not read file " . $filename);
+ }
+ $in->close();
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/ContainsSelector.php b/buildscripts/phing/classes/phing/types/selectors/ContainsSelector.php
new file mode 100644
index 00000000..5e270583
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/ContainsSelector.php
@@ -0,0 +1,151 @@
+<?php
+
+/*
+ * $Id: ab2c641c048573b0a9976b7cb92138b8ceda511f $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+include_once 'phing/types/selectors/BaseExtendSelector.php';
+
+/**
+ * Selector that filters files based on whether they contain a
+ * particular string.
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @package phing.types.selectors
+ */
+class ContainsSelector extends BaseExtendSelector {
+
+ private $contains = null;
+ private $casesensitive = true;
+ const CONTAINS_KEY = "text";
+ const CASE_KEY = "casesensitive";
+
+ public function toString() {
+ $buf = "{containsselector text: ";
+ $buf .= $this->contains;
+ $buf .= " casesensitive: ";
+ if ($this->casesensitive) {
+ $buf .= "true";
+ } else {
+ $buf .= "false";
+ }
+ $buf .= "}";
+ return $buf;
+ }
+
+ /**
+ * The string to search for within a file.
+ *
+ * @param string $contains the string that a file must contain to be selected.
+ */
+ public function setText($contains) {
+ $this->contains = $contains;
+ }
+
+ /**
+ * Whether to ignore case in the string being searched.
+ *
+ * @param boolean $casesensitive whether to pay attention to case sensitivity
+ */
+ public function setCasesensitive($casesensitive) {
+ $this->casesensitive = $casesensitive;
+ }
+
+ /**
+ * When using this as a custom selector, this method will be called.
+ * It translates each parameter into the appropriate setXXX() call.
+ *
+ * @param array $parameters the complete set of parameters for this selector
+ */
+ public function setParameters($parameters) {
+ parent::setParameters($parameters);
+ if ($parameters !== null) {
+ for ($i=0,$size=count($parameters); $i < $size; $i++) {
+ $paramname = $parameters[$i]->getName();
+ switch(strtolower($paramname)) {
+ case self::CONTAINS_KEY:
+ $this->setText($parameters[$i]->getValue());
+ break;
+ case self::CASE_KEY:
+ $this->setCasesensitive($parameters[$i]->getValue());
+ break;
+ default:
+ $this->setError("Invalid parameter " . $paramname);
+ }
+ } // for each param
+ } // if params
+ }
+
+ /**
+ * Checks to make sure all settings are kosher. In this case, it
+ * means that the pattern attribute has been set.
+ *
+ */
+ public function verifySettings() {
+ if ($this->contains === null) {
+ $this->setError("The text attribute is required");
+ }
+ }
+
+ /**
+ * The heart of the matter. This is where the selector gets to decide
+ * on the inclusion of a file in a particular fileset.
+ *
+ * @param basedir the base directory the scan is being done from
+ * @param filename is the name of the file to check
+ * @param file a PhingFile object the selector can use
+ * @return whether the file should be selected or not
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+
+ $this->validate();
+
+ if ($file->isDirectory()) {
+ return true;
+ }
+
+ $userstr = $this->contains;
+ if (!$this->casesensitive) {
+ $userstr = strtolower($this->contains);
+ }
+
+ $in = null;
+ try {
+ $in = new BufferedReader(new FileReader($file));
+ $teststr = $in->readLine();
+ while ($teststr !== null) {
+ if (!$this->casesensitive) {
+ $teststr = strtolower($teststr);
+ }
+ if (strpos($teststr, $userstr) !== false) {
+ return true;
+ }
+ $teststr = $in->readLine();
+ }
+ return false;
+ } catch (IOException $ioe) {
+ if ($in) $in->close();
+ throw new BuildException("Could not read file " . $filename);
+ }
+ $in->close();
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/DateSelector.php b/buildscripts/phing/classes/phing/types/selectors/DateSelector.php
new file mode 100755
index 00000000..0f8c28a8
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/DateSelector.php
@@ -0,0 +1,214 @@
+<?php
+
+/*
+ * $Id: f05cee91082616c66b2e109157b1d2f2298a66f8 $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/selectors/BaseExtendSelector.php';
+
+/**
+ * Selector that chooses files based on their last modified date. Ant uses
+ * millisecond precision (thanks to Java); PHP is forced to use only seconds
+ * precision.
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @version $Id: f05cee91082616c66b2e109157b1d2f2298a66f8 $
+ * @package phing.types.selectors
+ */
+class DateSelector extends BaseExtendSelector {
+
+ private $seconds = -1; // millis in Ant, but PHP doesn't support that level of precision
+ private $dateTime = null;
+ private $includeDirs = false;
+ private $granularity = 0;
+ private $cmp = 2;
+ const MILLIS_KEY = "millis";
+ const DATETIME_KEY = "datetime";
+ const CHECKDIRS_KEY = "checkdirs";
+ const GRANULARITY_KEY = "granularity";
+ const WHEN_KEY = "when";
+ private static $timeComparisons = array("before", "after", "equal");
+
+ public function __construct() {
+ //if (Os.isFamily("dos")) {
+ // granularity = 2000;
+ //}
+ }
+
+ public function toString() {
+ $buf = "{dateselector date: ";
+ $buf .= $this->dateTime;
+ $buf .= " compare: ";
+ if ($this->cmp === 0) {
+ $buf .= "before";
+ } elseif ($this->cmp === 1) {
+ $buf .= "after";
+ } else {
+ $buf .= "equal";
+ }
+ $buf .= " granularity: ";
+ $buf .= $this->granularity;
+ $buf .= "}";
+ return $buf;
+ }
+
+ /**
+ * For users that prefer to express time in seconds since 1970
+ *
+ * @param int $seconds the time to compare file's last modified date to,
+ * expressed in milliseconds
+ */
+ public function setSeconds($seconds) {
+ $this->seconds = (int) $seconds;
+ }
+
+ /**
+ * Returns the seconds value the selector is set for.
+ */
+ public function getSeconds() {
+ return $this->seconds;
+ }
+
+ /**
+ * Sets the date. The user must supply it in MM/DD/YYYY HH:MM AM_PM
+ * format
+ *
+ * @param string $dateTime a string in MM/DD/YYYY HH:MM AM_PM format
+ */
+ public function setDatetime($dateTime) {
+ $dt = strtotime($dateTime);
+ if ($dt == -1) {
+ $this->setError("Date of " . $dateTime
+ . " Cannot be parsed correctly. It should be in"
+ . " a format parsable by PHP's strtotime() function.");
+ } else {
+ $this->dateTime = $dateTime;
+ $this->setSeconds($dt);
+ }
+ }
+
+ /**
+ * Should we be checking dates on directories?
+ *
+ * @param boolean $includeDirs whether to check the timestamp on directories
+ */
+ public function setCheckdirs($includeDirs) {
+ $this->includeDirs = (boolean) $includeDirs;
+ }
+
+ /**
+ * Sets the number of milliseconds leeway we will give before we consider
+ * a file not to have matched a date.
+ * @param int $granularity
+ */
+ public function setGranularity($granularity) {
+ $this->granularity = (int) $granularity;
+ }
+
+ /**
+ * Sets the type of comparison to be done on the file's last modified
+ * date.
+ *
+ * @param string $cmp The comparison to perform
+ */
+ public function setWhen($cmp) {
+ $idx = array_search($cmp, self::$timeComparisons, true);
+ if ($idx === null) {
+ $this->setError("Invalid value for ".WHEN_KEY.": ".$cmp);
+ } else {
+ $this->cmp = $idx;
+ }
+ }
+
+ /**
+ * When using this as a custom selector, this method will be called.
+ * It translates each parameter into the appropriate setXXX() call.
+ *
+ * @param array $parameters the complete set of parameters for this selector
+ */
+ public function setParameters($parameters) {
+ parent::setParameters($parameters);
+ if ($parameters !== null) {
+ for ($i=0,$size=count($parameters); $i < $size; $i++) {
+ $paramname = $parameters[$i]->getName();
+ switch(strtolower($paramname)) {
+ case self::MILLIS_KEY:
+ $this->setMillis($parameters[$i]->getValue());
+ break;
+ case self::DATETIME_KEY:
+ $this->setDatetime($parameters[$i]->getValue());
+ break;
+ case self::CHECKDIRS_KEY:
+ $this->setCheckdirs($parameters[$i]->getValue());
+ break;
+ case self::GRANULARITY_KEY:
+ $this->setGranularity($parameters[$i]->getValue());
+ break;
+ case self::WHEN_KEY:
+ $this->setWhen($parameters[$i]->getValue());
+ break;
+ default:
+ $this->setError("Invalid parameter " . $paramname);
+ } // switch
+ }
+ }
+ }
+
+ /**
+ * This is a consistency check to ensure the selector's required
+ * values have been set.
+ */
+ public function verifySettings() {
+ if ($this->dateTime === null && $this->seconds < 0) {
+ $this->setError("You must provide a datetime or the number of "
+ . "seconds.");
+ } elseif ($this->seconds < 0) {
+ $this->setError("Date of " . $this->dateTime
+ . " results in negative seconds"
+ . " value relative to epoch (January 1, 1970, 00:00:00 GMT).");
+ }
+ }
+
+ /**
+ * The heart of the matter. This is where the selector gets to decide
+ * on the inclusion of a file in a particular fileset.
+ *
+ * @param PhingFile $basedir the base directory the scan is being done from
+ * @param string $filename is the name of the file to check
+ * @param PhingFile $file is a PhingFile object the selector can use
+ * @return boolean Whether the file should be selected or not
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+ $this->validate();
+ if ($file->isDirectory() && ($this->includeDirs === false)) {
+ return true;
+ }
+ if ($this->cmp === 0) {
+ return (($file->lastModified() - $this->granularity) < $this->seconds);
+ } elseif ($this->cmp === 1) {
+ return (($file->lastModified() - $this->granularity) > $this->seconds);
+ } else {
+ return (abs($file->lastModified() - $this->seconds) <= $this->granularity);
+ }
+ }
+
+}
+
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/DependSelector.php b/buildscripts/phing/classes/phing/types/selectors/DependSelector.php
new file mode 100755
index 00000000..3b869199
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/DependSelector.php
@@ -0,0 +1,151 @@
+<?php
+
+/*
+ * $Id: eac9e808c89c2a8f414f86afc589eda4f218dd6e $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/selectors/BaseSelector.php';
+
+/**
+ * Selector that filters files based on whether they are newer than
+ * a matching file in another directory tree. It can contain a mapper
+ * element, so isn't available as an ExtendSelector (since those
+ * parameters can't hold other elements).
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @version $Id$
+ * @package phing.types.selectors
+ */
+class DependSelector extends BaseSelector {
+
+ private $targetdir = null;
+ private $mapperElement = null;
+ private $map = null;
+ private $granularity = 0;
+
+ public function __construct() {
+ // not yet supported:
+ //if (Os.isFamily("dos")) {
+ // $this->granularity = 2000;
+ //}
+ }
+
+ public function toString() {
+ $buf = "{dependselector targetdir: ";
+ if ($this->targetdir === null) {
+ $buf .= "NOT YET SET";
+ } else {
+ $buf .= $this->targetdir->getName();
+ }
+ $buf .= " granularity: ";
+ $buf .= $this->granularity;
+ if ($this->map !== null) {
+ $buf .= " mapper: ";
+ $buf .= $this->map->toString();
+ } elseif ($this->mapperElement !== null) {
+ $buf .= " mapper: ";
+ $buf .= $this->mapperElement->toString();
+ }
+ $buf .= "}";
+ return $buf;
+ }
+
+ /**
+ * The name of the file or directory which is checked for out-of-date
+ * files.
+ *
+ * @param targetdir the directory to scan looking for files.
+ */
+ public function setTargetdir(PhingFile $targetdir) {
+ $this->targetdir = $targetdir;
+ }
+
+ /**
+ * Sets the number of milliseconds leeway we will give before we consider
+ * a file out of date.
+ */
+ public function setGranularity($granularity) {
+ $this->granularity = (int) granularity;
+ }
+
+ /**
+ * Defines the FileNameMapper to use (nested mapper element).
+ * @throws BuildException
+ */
+ public function createMapper() {
+ if ($this->mapperElement !== null) {
+ throw new BuildException("Cannot define more than one mapper");
+ }
+ $this->mapperElement = new Mapper($this->project);
+ return $this->mapperElement;
+ }
+
+
+ /**
+ * Checks to make sure all settings are kosher. In this case, it
+ * means that the dest attribute has been set and we have a mapper.
+ */
+ public function verifySettings() {
+ if ($this->targetdir === null) {
+ $this->setError("The targetdir attribute is required.");
+ }
+ if ($this->mapperElement === null) {
+ $this->map = new IdentityMapper();
+ } else {
+ $this->map = $this->mapperElement->getImplementation();
+ }
+ if ($this->map === null) {
+ $this->setError("Could not set <mapper> element.");
+ }
+ }
+
+ /**
+ * The heart of the matter. This is where the selector gets to decide
+ * on the inclusion of a file in a particular fileset.
+ *
+ * @param basedir the base directory the scan is being done from
+ * @param filename is the name of the file to check
+ * @param file is a PhingFile object the selector can use
+ * @return whether the file should be selected or not
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+
+ $this->validate();
+
+ // Determine file whose out-of-dateness is to be checked
+ $destfiles = $this->map->main($filename);
+
+ // If filename does not match the To attribute of the mapper
+ // then filter it out of the files we are considering
+ if ($destfiles === null) {
+ return false;
+ }
+ // Sanity check
+ if (count($destfiles) !== 1 || $destfiles[0] === null) {
+ throw new BuildException("Invalid destination file results for " . $this->targetdir . " with filename " . $filename);
+ }
+ $destname = $destfiles[0];
+ $destfile = new PhingFile($this->targetdir, $destname);
+
+ return SelectorUtils::isOutOfDate($file, $destfile, $this->granularity);
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/DepthSelector.php b/buildscripts/phing/classes/phing/types/selectors/DepthSelector.php
new file mode 100755
index 00000000..0ad6c8eb
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/DepthSelector.php
@@ -0,0 +1,158 @@
+<?php
+/*
+ * $Id: 9c244177a7f95995cd30c67c9fee47c1e977e4e2 $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/selectors/BaseExtendSelector.php';
+
+/**
+ * Selector that filters files based on the how deep in the directory
+ * tree they are.
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @version $Id$
+ * @package phing.types.selectors
+ */
+class DepthSelector extends BaseExtendSelector {
+
+ public $min = -1;
+ public $max = -1;
+ const MIN_KEY = "min";
+ const MAX_KEY = "max";
+
+ public function toString() {
+ $buf = "{depthselector min: ";
+ $buf .= $this->min;
+ $buf .= " max: ";
+ $buf .= $this->max;
+ $buf .= "}";
+ return $buf;
+ }
+
+ /**
+ * The minimum depth below the basedir before a file is selected.
+ *
+ * @param min minimum directory levels below basedir to go
+ */
+ public function setMin($min) {
+ $this->min = (int) $min;
+ }
+
+ /**
+ * The minimum depth below the basedir before a file is selected.
+ *
+ * @param min maximum directory levels below basedir to go
+ */
+ public function setMax($max) {
+ $this->max = (int) $max;
+ }
+
+ /**
+ * When using this as a custom selector, this method will be called.
+ * It translates each parameter into the appropriate setXXX() call.
+ *
+ * @param parameters the complete set of parameters for this selector
+ */
+ public function setParameters($parameters) {
+ parent::setParameters($parameters);
+ if ($parameters !== null) {
+ for ($i = 0, $size=count($parameters); $i < $size; $i++) {
+ $paramname = $parameters[$i]->getName();
+ switch(strtolower($paramname)) {
+ case self::MIN_KEY:
+ $this->setMin($parameters[$i]->getValue());
+ break;
+ case self::MAX_KEY:
+ $this->setMax($parameters[$i]->getValue());
+ break;
+
+ default:
+ $this->setError("Invalud parameter " . $paramname);
+ } // switch
+ }
+ }
+ }
+
+ /**
+ * Checks to make sure all settings are kosher. In this case, it
+ * means that the max depth is not lower than the min depth.
+ */
+ public function verifySettings() {
+ if ($this->min < 0 && $this->max < 0) {
+ $this->setError("You must set at least one of the min or the " .
+ "max levels.");
+ }
+ if ($this->max < $this->min && $this->max > -1) {
+ $this->setError("The maximum depth is lower than the minimum.");
+ }
+ }
+
+ /**
+ * The heart of the matter. This is where the selector gets to decide
+ * on the inclusion of a file in a particular fileset. Most of the work
+ * for this selector is offloaded into SelectorUtils, a static class
+ * that provides the same services for both FilenameSelector and
+ * DirectoryScanner.
+ *
+ * @param basedir the base directory the scan is being done from
+ * @param filename is the name of the file to check
+ * @param file is a PhingFile object the selector can use
+ * @return whether the file should be selected or not
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+
+ $this->validate();
+
+ $depth = -1;
+ // If you felt daring, you could cache the basedir absolute path
+ $abs_base = $basedir->getAbsolutePath();
+ $abs_file = $file->getAbsolutePath();
+
+ $tok_base = explode(DIRECTORY_SEPARATOR, $abs_base);
+ $tok_file = explode(DIRECTORY_SEPARATOR, $abs_file);
+
+ for($i=0,$size=count($tok_file); $i < $size; $i++) {
+ $filetoken = $tok_file[$i];
+ if (isset($tok_base[$i])) {
+ $basetoken = $tok_base[$i];
+ // Sanity check. Ditch it if you want faster performance
+ if ($basetoken !== $filetoken) {
+ throw new BuildException("File " . $filename .
+ " does not appear within " . $abs_base . "directory");
+ }
+ } else { // no more basepath tokens
+ $depth++;
+ if ($this->max > -1 && $depth > $this->max) {
+ return false;
+ }
+ }
+ }
+ if (isset($tok_base[$i + 1])) {
+ throw new BuildException("File " . $filename .
+ " is outside of " . $abs_base . "directory tree");
+ }
+ if ($this->min > -1 && $depth < $this->min) {
+ return false;
+ }
+ return true;
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/ExtendFileSelector.php b/buildscripts/phing/classes/phing/types/selectors/ExtendFileSelector.php
new file mode 100644
index 00000000..8394387c
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/ExtendFileSelector.php
@@ -0,0 +1,43 @@
+<?php
+
+/*
+ * $Id: dc3c5cb2a3043b7a3f7600591ce825b6563ec0ce $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/Parameterizable.php';
+require_once 'phing/types/selectors/FileSelector.php';
+
+/**
+ * This is the interface to be used by all custom selectors, those that are
+ * called through the &lt;custom&gt; tag. It is the amalgamation of two
+ * interfaces, the FileSelector and the Paramterizable interface. Note that
+ * you will almost certainly want the default behaviour for handling
+ * Parameters, so you probably want to use the BaseExtendSelector class
+ * as the base class for your custom selector rather than implementing
+ * this interface from scratch.
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @package phing.types.selectors
+ */
+interface ExtendFileSelector extends Parameterizable, FileSelector {
+ // No further methods necessary. This is just an amalgamation of two other
+ // interfaces.
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/ExtendSelector.php b/buildscripts/phing/classes/phing/types/selectors/ExtendSelector.php
new file mode 100644
index 00000000..1204ef12
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/ExtendSelector.php
@@ -0,0 +1,124 @@
+<?php
+
+/*
+ * $Id: 1683a0a93b4bb5486f3cffbe40e8260f886c6258 $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+include_once 'phing/util/StringHelper.php';
+
+/**
+ * Selector that selects files by forwarding the request on to other classes.
+ *
+ * TODO - Consider adding Path (phing.types.Path) support to this class
+ * and to the Mappers class. See Ant versions for implimentation details.
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @package phing.types.selectors
+ */
+class ExtendSelector extends BaseSelector {
+
+ private $classname;
+ private $dynselector;
+ private $parameters = array();
+
+ /**
+ * Sets the classname of the custom selector.
+ *
+ * @param classname is the class which implements this selector
+ */
+ public function setClassname($classname) {
+ $this->classname = $classname;
+ }
+
+ /**
+ * Instantiates the identified custom selector class.
+ */
+ public function selectorCreate() {
+ if ($this->classname !== null && $this->classname !== "") {
+ try {
+ // assume it's fully qualified, import it
+ $cls = Phing::import($this->classname);
+
+ // make sure class exists
+ if (class_exists($cls)) {
+ $this->dynselector = new $cls();
+ } else {
+ $this->setError("Selector " . $this->classname . " not initialized, no such class");
+ }
+ } catch (Exception $e) {
+ $this->setError("Selector " . $this->classname . " not initialized, could not create class: " . $e->getMessage());
+ }
+ } else {
+ $this->setError("There is no classname specified");
+ }
+ }
+
+ /**
+ * Create new parameters to pass to custom selector.
+ *
+ * @param p The new Parameter object
+ */
+ public function addParam(Parameter $p) {
+ $this->parameters[] = $p;
+ }
+
+ /**
+ * These are errors specific to ExtendSelector only. If there are
+ * errors in the custom selector, it should throw a BuildException
+ * when isSelected() is called.
+ */
+ public function verifySettings() {
+ // Creation is done here rather than in isSelected() because some
+ // containers may do a validation pass before running isSelected(),
+ // but we need to check for the existence of the created class.
+ if ($this->dynselector === null) {
+ $this->selectorCreate();
+ }
+
+ if (empty($this->classname)) {
+ $this->setError("The classname attribute is required");
+ } elseif ($this->dynselector === null) {
+ $this->setError("Internal Error: The custom selector was not created");
+ } elseif ( !($this->dynselector instanceof ExtendFileSelector) && (count($this->parameters) > 0)) {
+ $this->setError("Cannot set parameters on custom selector that does not "
+ . "implement ExtendFileSelector.");
+ }
+ }
+
+
+ /**
+ * Allows the custom selector to choose whether to select a file. This
+ * is also where the Parameters are passed to the custom selector.
+ *
+ * @throws BuildException
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+
+ $this->validate();
+
+ if (count($this->parameters) > 0 && $this->dynselector instanceof ExtendFileSelector) {
+ // We know that dynselector must be non-null if no error message
+ $this->dynselector->setParameters($this->parameters);
+ }
+ return $this->dynselector->isSelected($basedir, $filename, $file);
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/FileSelector.php b/buildscripts/phing/classes/phing/types/selectors/FileSelector.php
new file mode 100644
index 00000000..3c014d61
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/FileSelector.php
@@ -0,0 +1,47 @@
+<?php
+
+/*
+ * $Id: 26b8712469a798faf79d1c877aad89d64880f061 $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+/**
+ * This is the interface to be used by all selectors.
+ *
+ * @author Hans Lellelid, hans@xmpl.org (Phing)
+ * @author Bruce Atherton, bruce@callenish.com (Ant)
+ * @package phing.types.selectors
+ */
+interface FileSelector {
+
+ /**
+ * Method that each selector will implement to create their
+ * selection behaviour. If there is a problem with the setup
+ * of a selector, it can throw a BuildException to indicate
+ * the problem.
+ *
+ * @param basedir A PhingFile object for the base directory
+ * @param filename The name of the file to check
+ * @param file A PhingFile object for this filename
+ * @return whether the file should be selected or not
+ * @throws BuildException if the selector was not configured correctly
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file);
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/FilenameSelector.php b/buildscripts/phing/classes/phing/types/selectors/FilenameSelector.php
new file mode 100644
index 00000000..04abbe2e
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/FilenameSelector.php
@@ -0,0 +1,157 @@
+<?php
+
+/*
+ * $Id: d0a6af11eeda50b911bad3717528a9ea72291185 $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+
+include_once 'phing/types/selectors/BaseExtendSelector.php';
+
+/**
+ * Selector that filters files based on the filename.
+ *
+ * @author Hans Lellelid, hans@xmpl.org (Phing)
+ * @author Bruce Atherton, bruce@callenish.com (Ant)
+ * @package phing.types.selectors
+ */
+class FilenameSelector extends BaseExtendSelector {
+
+ private $pattern = null;
+ private $casesensitive = true;
+ private $negated = false;
+ const NAME_KEY = "name";
+ const CASE_KEY = "casesensitive";
+ const NEGATE_KEY = "negate";
+
+ public function toString() {
+ $buf = "{filenameselector name: ";
+ $buf .= $this->pattern;
+ $buf .= " negate: ";
+ if ($this->negated) {
+ $buf .= "true";
+ } else {
+ $buf .= "false";
+ }
+ $buf .= " casesensitive: ";
+ if ($this->casesensitive) {
+ $buf .= "true";
+ } else {
+ $buf .= "false";
+ }
+ $buf .= "}";
+ return $buf;
+ }
+
+ /**
+ * The name of the file, or the pattern for the name, that
+ * should be used for selection.
+ *
+ * @param pattern the file pattern that any filename must match
+ * against in order to be selected.
+ */
+ public function setName($pattern) {
+ $pattern = str_replace('\\', DIRECTORY_SEPARATOR, $pattern);
+ $pattern = str_replace('/', DIRECTORY_SEPARATOR, $pattern);
+
+ if (StringHelper::endsWith(DIRECTORY_SEPARATOR, $pattern)) {
+ $pattern .= "**";
+ }
+ $this->pattern = $pattern;
+ }
+
+ /**
+ * Whether to ignore case when checking filenames.
+ *
+ * @param casesensitive whether to pay attention to case sensitivity
+ */
+ public function setCasesensitive($casesensitive) {
+ $this->casesensitive = $casesensitive;
+ }
+
+ /**
+ * You can optionally reverse the selection of this selector,
+ * thereby emulating an &lt;exclude&gt; tag, by setting the attribute
+ * negate to true. This is identical to surrounding the selector
+ * with &lt;not&gt;&lt;/not&gt;.
+ *
+ * @param negated whether to negate this selection
+ */
+ public function setNegate($negated) {
+ $this->negated = $negated;
+ }
+
+ /**
+ * When using this as a custom selector, this method will be called.
+ * It translates each parameter into the appropriate setXXX() call.
+ *
+ * @param array $parameters the complete set of parameters for this selector
+ */
+ public function setParameters($parameters) {
+ parent::setParameters($parameters);
+ if ($parameters !== null) {
+ for ($i=0, $len=count($parameters); $i < $len; $i++) {
+ $paramname = $parameters[$i]->getName();
+ switch(strtolower($paramname)) {
+ case self::NAME_KEY:
+ $this->setName($parameters[$i]->getValue());
+ break;
+ case self::CASE_KEY:
+ $this->setCasesensitive($parameters[$i]->getValue());
+ break;
+ case self::NEGATE_KEY:
+ $this->setNegate($parameters[$i]->getValue());
+ break;
+ default:
+ $this->setError("Invalid parameter " . $paramname);
+ }
+ } // for each param
+ } // if params
+ }
+
+ /**
+ * Checks to make sure all settings are kosher. In this case, it
+ * means that the name attribute has been set.
+ *
+ */
+ public function verifySettings() {
+ if ($this->pattern === null) {
+ $this->setError("The name attribute is required");
+ }
+ }
+
+ /**
+ * The heart of the matter. This is where the selector gets to decide
+ * on the inclusion of a file in a particular fileset. Most of the work
+ * for this selector is offloaded into SelectorUtils, a static class
+ * that provides the same services for both FilenameSelector and
+ * DirectoryScanner.
+ *
+ * @param basedir the base directory the scan is being done from
+ * @param filename is the name of the file to check
+ * @param file is a PhingFile object the selector can use
+ * @return whether the file should be selected or not
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+ $this->validate();
+ return (SelectorUtils::matchPath($this->pattern, $filename, $this->casesensitive)
+ === !($this->negated));
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/MajoritySelector.php b/buildscripts/phing/classes/phing/types/selectors/MajoritySelector.php
new file mode 100644
index 00000000..5ad2629e
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/MajoritySelector.php
@@ -0,0 +1,92 @@
+<?php
+
+/*
+ * $Id: 9071d88eb880abe5a299f7c5db707d4439ccaa6c $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+
+/**
+ * This selector is here just to shake up your thinking a bit. Don't get
+ * too caught up in boolean, there are other ways you can evaluate a
+ * collection of selectors. This one takes a vote of the selectors it
+ * contains, and majority wins. You could also have an "all-but-one"
+ * selector, a "weighted-average" selector, and so on. These are left
+ * as exercises for the reader (as are the usecases where this would
+ * be necessary).
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @package phing.types.selectors
+ */
+class MajoritySelector extends BaseSelectorContainer {
+
+ private $allowtie = true;
+
+ public function toString() {
+ $buf = "";
+ if ($this->hasSelectors()) {
+ $buf .= "{majorityselect: ";
+ $buf .= parent::toString();
+ $buf .= "}";
+ }
+ return $buf;
+ }
+
+ public function setAllowtie($tiebreaker) {
+ $this->allowtie = $tiebreaker;
+ }
+
+ /**
+ * Returns true (the file is selected) if most of the other selectors
+ * agree. In case of a tie, go by the allowtie setting. That defaults
+ * to true, meaning in case of a tie, the file is selected.
+ *
+ * @param basedir the base directory the scan is being done from
+ * @param filename is the name of the file to check
+ * @param file is a PhingFile object for the filename that the selector
+ * can use
+ * @return whether the file should be selected or not
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+
+ $this->validate();
+
+ $yesvotes = 0;
+ $novotes = 0;
+
+ $selectors = $this->selectorElements();
+ for($i=0,$size=count($selectors); $i < $size; $i++) {
+ $result = $selectors[$i]->isSelected($basedir,$filename,$file);
+ if ($result) {
+ $yesvotes = $yesvotes + 1;
+ } else {
+ $novotes = $novotes + 1;
+ }
+ }
+ if ($yesvotes > $novotes) {
+ return true;
+ }
+ else if ($novotes > $yesvotes) {
+ return false;
+ }
+ // At this point, we know we have a tie.
+ return $this->allowtie;
+ }
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/NoneSelector.php b/buildscripts/phing/classes/phing/types/selectors/NoneSelector.php
new file mode 100644
index 00000000..f8941208
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/NoneSelector.php
@@ -0,0 +1,71 @@
+<?php
+/*
+ * $Id: a085187a008c4d8e8ba25fd6f1315b3dee92ec27 $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/selectors/BaseSelectorContainer.php';
+
+/**
+ * This selector has a collection of other selectors. All of those selectors
+ * must refuse to select a file before the file is considered selected by
+ * this selector.
+ *
+ * @author Hans Lellelid <hans@xmpl.org>
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @package phing.types.selectors
+ */
+class NoneSelector extends BaseSelectorContainer {
+
+ public function toString() {
+ $buf = "";
+ if ($this->hasSelectors()) {
+ $buf .= "{noneselect: ";
+ $buf .= parent::toString();
+ $buf .= "}";
+ }
+ return $buf;
+ }
+
+ /**
+ * Returns true (the file is selected) only if all other selectors
+ * agree that the file should not be selected.
+ *
+ * @param basedir the base directory the scan is being done from
+ * @param filename is the name of the file to check
+ * @param file is a java.io.File object for the filename that the selector
+ * can use
+ * @return whether the file should be selected or not
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+
+ $this->validate();
+
+ $selectors = $this->selectorElements();
+
+ for($i=0,$size=count($selectors); $i < $size; $i++) {
+ $result = $selectors[$i]->isSelected($basedir, $filename, $file);
+ if ($result) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/NotSelector.php b/buildscripts/phing/classes/phing/types/selectors/NotSelector.php
new file mode 100644
index 00000000..08e70a5a
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/NotSelector.php
@@ -0,0 +1,59 @@
+<?php
+
+/*
+ * $Id: 8dcce9d2d304b7a8d4be0ef5b5111b582846840d $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/selectors/NoneSelector.php';
+
+/**
+ * This selector has one other selectors whose meaning it inverts. It
+ * actually relies on NoneSelector for its implementation of the
+ * isSelected() method, but it adds a check to ensure there is only one
+ * other selector contained within.
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @package phing.types.selectors
+ */
+class NotSelector extends NoneSelector {
+
+ public function toString() {
+ $buf = "";
+ if ($this->hasSelectors()) {
+ $buf .= "{notselect: ";
+ $buf .= parent::toString();
+ $buf .= "}";
+ }
+ return $buf;
+ }
+
+ /**
+ * Makes sure that there is only one entry, sets an error message if
+ * not.
+ */
+ public function verifySettings() {
+ if ($this->selectorCount() != 1) {
+ $this->setError("One and only one selector is allowed within the " .
+ "<not> tag");
+ }
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/OrSelector.php b/buildscripts/phing/classes/phing/types/selectors/OrSelector.php
new file mode 100644
index 00000000..56e6df1e
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/OrSelector.php
@@ -0,0 +1,72 @@
+<?php
+/*
+ * $Id: bfed3cc534a3e1ab8789f0ed4a6e64419979e21a $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/selectors/BaseSelectorContainer.php';
+
+/**
+ * This selector has a collection of other selectors, any of which have to
+ * select a file in order for this selector to select it.
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @package phing.types.selectors
+ */
+class OrSelector extends BaseSelectorContainer {
+
+ public function toString() {
+ $buf = "";
+ if ($this->hasSelectors()) {
+ $buf .= "{orselect: ";
+ $buf .= parent::toString();
+ $buf .= "}";
+ }
+ return $buf;
+ }
+
+ /**
+ * Returns true (the file is selected) if any of the other selectors
+ * agree that the file should be selected.
+ *
+ * @param basedir the base directory the scan is being done from
+ * @param filename the name of the file to check
+ * @param file a PhingFile object for the filename that the selector
+ * can use
+ * @return boolean Whether the file should be selected or not
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+
+ $this->validate();
+
+ $selectors = $this->selectorElements();
+
+ // First, check that all elements are correctly configured
+
+ for($i=0,$size=count($selectors); $i < $size; $i++) {
+ $result = $selectors[$i]->isSelected($basedir, $filename, $file);
+ if ($result) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/PresentSelector.php b/buildscripts/phing/classes/phing/types/selectors/PresentSelector.php
new file mode 100644
index 00000000..462d3927
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/PresentSelector.php
@@ -0,0 +1,154 @@
+<?php
+
+/*
+ * $Id: db4c8bc8217483d4150b2d9e62d2ef5129038b4e $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+/**
+ * Selector that filters files based on whether they appear in another
+ * directory tree. It can contain a mapper element, so isn't available
+ * as an ExtendSelector (since those parameters can't hold other
+ * elements).
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @package phing.types.selectors
+ */
+class PresentSelector extends BaseSelector {
+
+ private $targetdir = null;
+ private $mapperElement = null;
+ private $map = null;
+ private $destmustexist = true;
+ private static $filePresence = array("srconly", "both");
+
+ public function toString() {
+ $buf = "{presentselector targetdir: ";
+ if ($this->targetdir === null) {
+ $buf .= "NOT YET SET";
+ } else {
+ $buf .= $this->targetdir->getName();
+ }
+ $buf .= " present: ";
+ if ($this->destmustexist) {
+ $buf .= "both";
+ } else {
+ $buf .= "srconly";
+ }
+ if ($this->map !== null) {
+ $buf .= $this->map->toString();
+ } elseif ($this->mapperElement !== null) {
+ $buf .= $this->mapperElement->toString();
+ }
+ $buf .= "}";
+ return $buf;
+ }
+
+ /**
+ * The name of the file or directory which is checked for matching
+ * files.
+ *
+ * @param targetdir the directory to scan looking for matching files.
+ */
+ public function setTargetdir(PhingFile $targetdir) {
+ $this->targetdir = $targetdir;
+ }
+
+ /**
+ * Defines the FileNameMapper to use (nested mapper element).
+ * @throws BuildException
+ */
+ public function createMapper() {
+ if ($this->mapperElement !== null) {
+ throw new BuildException("Cannot define more than one mapper");
+ }
+ $this->mapperElement = new Mapper($this->getProject());
+ return $this->mapperElement;
+ }
+
+
+ /**
+ * This sets whether to select a file if its dest file is present.
+ * It could be a <code>negate</code> boolean, but by doing things
+ * this way, we get some documentation on how the system works.
+ * A user looking at the documentation should clearly understand
+ * that the ONLY files whose presence is being tested are those
+ * that already exist in the source directory, hence the lack of
+ * a <code>destonly</code> option.
+ *
+ * @param string $fp An attribute set to either <code>srconly</code> or
+ * <code>both</code>.
+ */
+ public function setPresent($fp) {
+ $idx = array_search($fp, self::$filePresence, true);
+ if ( $idx === 0 ) {
+ $this->destmustexist = false;
+ }
+ }
+
+ /**
+ * Checks to make sure all settings are kosher. In this case, it
+ * means that the targetdir attribute has been set and we have a mapper.
+ */
+ public function verifySettings() {
+ if ($this->targetdir === null) {
+ $this->setError("The targetdir attribute is required.");
+ }
+ if ($this->mapperElement === null) {
+ $this->map = new IdentityMapper();
+ } else {
+ $this->map = $this->mapperElement->getImplementation();
+ }
+ if ($this->map === null) {
+ $this->setError("Could not set <mapper> element.");
+ }
+ }
+
+ /**
+ * The heart of the matter. This is where the selector gets to decide
+ * on the inclusion of a file in a particular fileset.
+ *
+ * @param basedir the base directory the scan is being done from
+ * @param filename is the name of the file to check
+ * @param file is a PhingFile object the selector can use
+ * @return whether the file should be selected or not
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+
+ $this->validate();
+
+ // Determine file whose existence is to be checked
+ $destfiles = $this->map->main($filename);
+ // If filename does not match the To attribute of the mapper
+ // then filter it out of the files we are considering
+ if ($destfiles === null) {
+ return false;
+ }
+ // Sanity check
+ if (count($destfiles) !== 1 || $destfiles[0] === null) {
+ throw new BuildException("Invalid destination file results for "
+ . $this->targetdir . " with filename " . $filename);
+ }
+ $destname = $destfiles[0];
+ $destfile = new PhingFile($this->targetdir, $destname);
+ return $destfile->exists() === $this->destmustexist;
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/SelectSelector.php b/buildscripts/phing/classes/phing/types/selectors/SelectSelector.php
new file mode 100755
index 00000000..0db73e5d
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/SelectSelector.php
@@ -0,0 +1,124 @@
+<?php
+
+/*
+ * $Id: aa3a5cceea362713959333bda113e0ca5428a530 $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/selectors/AndSelector.php';
+
+/**
+ * This selector just holds one other selector and forwards all
+ * requests to it. It exists so that there is a single selector
+ * type that can exist outside of any targets, as an element of
+ * project. It overrides all of the reference stuff so that it
+ * works as expected. Note that this is the only selector you
+ * can reference.
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @version $Id$
+ * @package phing.types.selectors
+ */
+class SelectSelector extends AndSelector {
+
+ public function toString() {
+ $buf = "";
+ if ($this->hasSelectors()) {
+ $buf .= "{select: ";
+ $buf .= parent::toString();
+ $buf .= "}";
+ }
+ return $buf;
+ }
+
+ /**
+ * Performs the check for circular references and returns the
+ * referenced Selector.
+ */
+ private function getRef() {
+ $o = $this->getCheckedRef(get_class($this), "SelectSelector");
+ return $o;
+ }
+
+ /**
+ * Indicates whether there are any selectors here.
+ */
+ public function hasSelectors() {
+ if ($this->isReference()) {
+ return $this->getRef()->hasSelectors();
+ }
+ return parent::hasSelectors();
+ }
+
+ /**
+ * Gives the count of the number of selectors in this container
+ */
+ public function selectorCount() {
+ if ($this->isReference()) {
+ return $this->getRef()->selectorCount();
+ }
+ return parent::selectorCount();
+ }
+
+ /**
+ * Returns the set of selectors as an array.
+ */
+ public function getSelectors(Project $p) {
+ if ($this->isReference()) {
+ return $this->getRef()->getSelectors($p);
+ }
+ return parent::getSelectors($p);
+ }
+
+ /**
+ * Returns an enumerator for accessing the set of selectors.
+ */
+ public function selectorElements() {
+ if ($this->isReference()) {
+ return $this->getRef()->selectorElements();
+ }
+ return parent::selectorElements();
+ }
+
+ /**
+ * Add a new selector into this container.
+ *
+ * @param selector the new selector to add
+ * @return the selector that was added
+ */
+ public function appendSelector(FileSelector $selector) {
+ if ($this->isReference()) {
+ throw $this->noChildrenAllowed();
+ }
+ parent::appendSelector($selector);
+ }
+
+ /**
+ * Makes sure that there is only one entry, sets an error message if
+ * not.
+ */
+ public function verifySettings() {
+ if ($this->selectorCount() != 1) {
+ $this->setError("One and only one selector is allowed within the "
+ . "<selector> tag");
+ }
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/SelectorContainer.php b/buildscripts/phing/classes/phing/types/selectors/SelectorContainer.php
new file mode 100644
index 00000000..0ee42237
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/SelectorContainer.php
@@ -0,0 +1,141 @@
+<?php
+
+/*
+ * $Id: 6fedde4695e4838f435f336b7936190b16429706 $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+
+/**
+ * This is the interface for selectors that can contain other selectors.
+ *
+ * @author <a href="mailto:bruce@callenish.com">Bruce Atherton</a>
+ * @package phing.types.selectors
+ */
+interface SelectorContainer {
+
+ /**
+ * Indicates whether there are any selectors here.
+ *
+ * @return whether any selectors are in this container
+ */
+ public function hasSelectors();
+
+ /**
+ * Gives the count of the number of selectors in this container
+ *
+ * @return the number of selectors in this container
+ */
+ public function selectorCount();
+
+ /**
+ * Returns a *copy* of the set of selectors as an array.
+ *
+ * @return an array of selectors in this container
+ */
+ public function getSelectors(Project $p);
+
+ /**
+ * Returns an array for accessing the set of selectors.
+ *
+ * @return an enumerator that goes through each of the selectors
+ */
+ public function selectorElements();
+
+ /**
+ * Add a new selector into this container.
+ *
+ * @param selector the new selector to add
+ * @return the selector that was added
+ */
+ public function appendSelector(FileSelector $selector);
+
+ /* Methods below all add specific selectors */
+
+ /**
+ * add a "Select" selector entry on the selector list
+ */
+ public function createSelector();
+
+ /**
+ * add an "And" selector entry on the selector list
+ */
+ public function createAnd();
+
+ /**
+ * add an "Or" selector entry on the selector list
+ */
+ public function createOr();
+
+ /**
+ * add a "Not" selector entry on the selector list
+ */
+ public function createNot();
+
+ /**
+ * add a "None" selector entry on the selector list
+ */
+ public function createNone();
+
+ /**
+ * add a majority selector entry on the selector list
+ */
+ public function createMajority();
+
+ /**
+ * add a selector date entry on the selector list
+ */
+ public function createDate();
+
+ /**
+ * add a selector size entry on the selector list
+ */
+ public function createSize();
+
+ /**
+ * add a selector filename entry on the selector list
+ */
+ public function createFilename();
+
+ /**
+ * add an extended selector entry on the selector list
+ */
+ public function createCustom();
+
+ /**
+ * add a contains selector entry on the selector list
+ */
+ public function createContains();
+
+ /**
+ * add a present selector entry on the selector list
+ */
+ public function createPresent();
+
+ /**
+ * add a depth selector entry on the selector list
+ */
+ public function createDepth();
+
+ /**
+ * add a depends selector entry on the selector list
+ */
+ public function createDepend();
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/SelectorScanner.php b/buildscripts/phing/classes/phing/types/selectors/SelectorScanner.php
new file mode 100644
index 00000000..91fc3f4c
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/SelectorScanner.php
@@ -0,0 +1,55 @@
+<?php
+
+/*
+ * $Id: 3c28c4c2e4c41cf4507870e472ed9f278e2d9c9f $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+
+/**
+ * An interface used to describe the actions required by any type of
+ * directory scanner that supports Selecters.
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @package phing.types.selectors
+ */
+interface SelectorScanner {
+
+ /**
+ * Sets the selectors the scanner should use.
+ *
+ * @param selectors the list of selectors
+ */
+ public function setSelectors($selectors);
+
+ /**
+ * Directories which were selected out of a scan.
+ *
+ * @param selectors list selector objects
+ */
+ public function getDeselectedDirectories();
+
+ /**
+ * Files which were selected out of a scan.
+ *
+ * @param selectors list selector objects
+ */
+ public function getDeselectedFiles();
+
+}
diff --git a/buildscripts/phing/classes/phing/types/selectors/SelectorUtils.php b/buildscripts/phing/classes/phing/types/selectors/SelectorUtils.php
new file mode 100644
index 00000000..2d7e5068
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/SelectorUtils.php
@@ -0,0 +1,200 @@
+<?php
+
+/*
+ * $Id: 4a682bbe8751f6e09a725af7cfdf2bd17ab00645 $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+include_once 'phing/util/StringHelper.php';
+
+/**
+ * <p>This is a utility class used by selectors and DirectoryScanner. The
+ * functionality more properly belongs just to selectors, but unfortunately
+ * DirectoryScanner exposed these as protected methods. Thus we have to
+ * support any subclasses of DirectoryScanner that may access these methods.
+ * </p>
+ * <p>This is a Singleton.</p>
+ *
+ * @author Hans Lellelid, hans@xmpl.org (Phing)
+ * @author Arnout J. Kuiper, ajkuiper@wxs.nl (Ant)
+ * @author Magesh Umasankar
+ * @author Bruce Atherton, bruce@callenish.com (Ant)
+ * @package phing.types.selectors
+ */
+class SelectorUtils {
+
+ private static $instance;
+
+ /**
+ * Retrieves the instance of the Singleton.
+ */
+ public static function getInstance() {
+ if (!isset(self::$instance)) {
+ self::$instance = new SelectorUtils();
+ }
+ return self::$instance;
+ }
+
+ /**
+ * Tests whether or not a given path matches the start of a given
+ * pattern up to the first "**".
+ * <p>
+ * This is not a general purpose test and should only be used if you
+ * can live with false positives. For example, <code>pattern=**\a</code>
+ * and <code>str=b</code> will yield <code>true</code>.
+ *
+ * @param pattern The pattern to match against. Must not be
+ * <code>null</code>.
+ * @param str The path to match, as a String. Must not be
+ * <code>null</code>.
+ * @param isCaseSensitive Whether or not matching should be performed
+ * case sensitively.
+ *
+ * @return whether or not a given path matches the start of a given
+ * pattern up to the first "**".
+ */
+ public static function matchPatternStart($pattern, $str, $isCaseSensitive = true) {
+
+ // When str starts with a DIRECTORY_SEPARATOR, pattern has to start with a
+ // DIRECTORY_SEPARATOR.
+ // When pattern starts with a DIRECTORY_SEPARATOR, str has to start with a
+ // DIRECTORY_SEPARATOR.
+ if (StringHelper::startsWith(DIRECTORY_SEPARATOR, $str) !==
+ StringHelper::startsWith(DIRECTORY_SEPARATOR, $pattern)) {
+ return false;
+ }
+
+ $patDirs = explode(DIRECTORY_SEPARATOR, $pattern);
+ $strDirs = explode(DIRECTORY_SEPARATOR, $str);
+
+ $patIdxStart = 0;
+ $patIdxEnd = count($patDirs)-1;
+ $strIdxStart = 0;
+ $strIdxEnd = count($strDirs)-1;
+
+ // up to first '**'
+ while ($patIdxStart <= $patIdxEnd && $strIdxStart <= $strIdxEnd) {
+ $patDir = $patDirs[$patIdxStart];
+ if ($patDir == "**") {
+ break;
+ }
+ if (!self::match($patDir, $strDirs[$strIdxStart], $isCaseSensitive)) {
+ return false;
+ }
+ $patIdxStart++;
+ $strIdxStart++;
+ }
+
+ if ($strIdxStart > $strIdxEnd) {
+ // String is exhausted
+ return true;
+ } elseif ($patIdxStart > $patIdxEnd) {
+ // String not exhausted, but pattern is. Failure.
+ return false;
+ } else {
+ // pattern now holds ** while string is not exhausted
+ // this will generate false positives but we can live with that.
+ return true;
+ }
+ }
+
+ /**
+ * Tests whether or not a given path matches a given pattern.
+ *
+ * @param pattern The pattern to match against. Must not be
+ * <code>null</code>.
+ * @param str The path to match, as a String. Must not be
+ * <code>null</code>.
+ * @param isCaseSensitive Whether or not matching should be performed
+ * case sensitively.
+ *
+ * @return <code>true</code> if the pattern matches against the string,
+ * or <code>false</code> otherwise.
+ */
+ public static function matchPath($pattern, $str, $isCaseSensitive = true) {
+
+ $rePattern = preg_quote($pattern, '/');
+ $dirSep = preg_quote(DIRECTORY_SEPARATOR, '/');
+ $trailingDirSep = '(('.$dirSep.')?|('.$dirSep.').+)';
+ $patternReplacements = array(
+ $dirSep.'\*\*'.$dirSep => $dirSep.'.*'.$trailingDirSep,
+ $dirSep.'\*\*' => $trailingDirSep,
+ '\*\*'.$dirSep => '.*'.$trailingDirSep,
+ '\*\*' => '.*',
+ '\*' => '[^'.$dirSep.']*',
+ '\?' => '[^'.$dirSep.']'
+ );
+ $rePattern = str_replace(array_keys($patternReplacements), array_values($patternReplacements), $rePattern);
+ $rePattern = '/^'.$rePattern.'$/'.($isCaseSensitive ? '' : 'i');
+ return (bool) preg_match($rePattern, $str);
+ }
+
+ /**
+ * Tests whether or not a string matches against a pattern.
+ * The pattern may contain two special characters:<br>
+ * '*' means zero or more characters<br>
+ * '?' means one and only one character
+ *
+ * @param pattern The pattern to match against.
+ * Must not be <code>null</code>.
+ * @param str The string which must be matched against the pattern.
+ * Must not be <code>null</code>.
+ * @param isCaseSensitive Whether or not matching should be performed
+ * case sensitively.
+ *
+ *
+ * @return <code>true</code> if the string matches against the pattern,
+ * or <code>false</code> otherwise.
+ */
+ public static function match($pattern, $str, $isCaseSensitive = true) {
+
+ $rePattern = preg_quote($pattern, '/');
+ $rePattern = str_replace(array("\*", "\?"), array('.*', '.'), $rePattern);
+ $rePattern = '/^'.$rePattern.'$/'.($isCaseSensitive ? '' : 'i');
+ return (bool) preg_match($rePattern, $str);
+ }
+
+ /**
+ * Returns dependency information on these two files. If src has been
+ * modified later than target, it returns true. If target doesn't exist,
+ * it likewise returns true. Otherwise, target is newer than src and
+ * is not out of date, thus the method returns false. It also returns
+ * false if the src file doesn't even exist, since how could the
+ * target then be out of date.
+ *
+ * @param PhingFile $src the original file
+ * @param PhingFile $target the file being compared against
+ * @param int $granularity the amount in seconds of slack we will give in
+ * determining out of dateness
+ * @return whether the target is out of date
+ */
+ public static function isOutOfDate(PhingFile $src, PhingFile $target, $granularity) {
+ if (!$src->exists()) {
+ return false;
+ }
+ if (!$target->exists()) {
+ return true;
+ }
+ if (($src->lastModified() - $granularity) > $target->lastModified()) {
+ return true;
+ }
+ return false;
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/SizeSelector.php b/buildscripts/phing/classes/phing/types/selectors/SizeSelector.php
new file mode 100644
index 00000000..3aaf8a92
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/SizeSelector.php
@@ -0,0 +1,228 @@
+<?php
+
+/*
+ * $Id: 4969c98a4e03305a23770e2afd5da641999f6174 $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+
+/**
+ * Selector that filters files based on their size.
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Bruce Atherton <bruce@callenish.com> (Ant)
+ * @package phing.types.selectors
+ */
+class SizeSelector extends BaseExtendSelector {
+
+ private $size = -1;
+ private $multiplier = 1;
+ private $sizelimit = -1;
+ private $cmp = 2;
+ const SIZE_KEY = "value";
+ const UNITS_KEY = "units";
+ const WHEN_KEY = "when";
+
+ private static $sizeComparisons = array("less", "more", "equal");
+ private static $byteUnits = array("K", "k", "kilo", "KILO",
+ "Ki", "KI", "ki", "kibi", "KIBI",
+ "M", "m", "mega", "MEGA",
+ "Mi", "MI", "mi", "mebi", "MEBI",
+ "G", "g", "giga", "GIGA",
+ "Gi", "GI", "gi", "gibi", "GIBI",
+ "T", "t", "tera", "TERA",
+ /* You wish! */ "Ti", "TI", "ti", "tebi", "TEBI"
+ );
+
+ public function toString() {
+ $buf = "{sizeselector value: ";
+ $buf .= $this->sizelimit;
+ $buf .= "compare: ";
+ if ($this->cmp === 0) {
+ $buf .= "less";
+ } elseif ($this->cmp === 1) {
+ $buf .= "more";
+ } else {
+ $buf .= "equal";
+ }
+ $buf .= "}";
+ return $buf;
+ }
+
+ /**
+ * A size selector needs to know what size to base its selecting on.
+ * This will be further modified by the multiplier to get an
+ * actual size limit.
+ *
+ * @param size the size to select against expressed in units
+ */
+ public function setValue($size) {
+ $this->size = $size;
+ if (($this->multiplier !== 0) && ($this->size > -1)) {
+ $this->sizelimit = $size * $this->multiplier;
+ }
+ }
+
+ /**
+ * Sets the units to use for the comparison. This is a little
+ * complicated because common usage has created standards that
+ * play havoc with capitalization rules. Thus, some people will
+ * use "K" for indicating 1000's, when the SI standard calls for
+ * "k". Others have tried to introduce "K" as a multiple of 1024,
+ * but that falls down when you reach "M", since "m" is already
+ * defined as 0.001.
+ * <p>
+ * To get around this complexity, a number of standards bodies
+ * have proposed the 2^10 standard, and at least one has adopted
+ * it. But we are still left with a populace that isn't clear on
+ * how capitalization should work.
+ * <p>
+ * We therefore ignore capitalization as much as possible.
+ * Completely mixed case is not possible, but all upper and lower
+ * forms are accepted for all long and short forms. Since we have
+ * no need to work with the 0.001 case, this practice works here.
+ * <p>
+ * This function translates all the long and short forms that a
+ * unit prefix can occur in and translates them into a single
+ * multiplier.
+ *
+ * @param $units The units to compare the size to.
+ * @return void
+ */
+ public function setUnits($units) {
+ $i = array_search($units, self::$byteUnits, true);
+ if ($i === false) $i = -1; // make it java-like
+
+ $this->multiplier = 0;
+ if (($i > -1) && ($i < 4)) {
+ $this->multiplier = 1000;
+ } elseif (($i > 3) && ($i < 9)) {
+ $this->multiplier = 1024;
+ } elseif (($i > 8) && ($i < 13)) {
+ $this->multiplier = 1000000;
+ } elseif (($i > 12) && ($i < 18)) {
+ $this->multiplier = 1048576;
+ } elseif (($i > 17) && ($i < 22)) {
+ $this->multiplier = 1000000000;
+ } elseif (($i > 21) && ($i < 27)) {
+ $this->multiplier = 1073741824;
+ } elseif (($i > 26) && ($i < 31)) {
+ $this->multiplier = 1000000000000;
+ } elseif (($i > 30) && ($i < 36)) {
+ $this->multiplier = 1099511627776;
+ }
+ if (($this->multiplier > 0) && ($this->size > -1)) {
+ $this->sizelimit = $this->size * $this->multiplier;
+ }
+ }
+
+ /**
+ * This specifies when the file should be selected, whether it be
+ * when the file matches a particular size, when it is smaller,
+ * or whether it is larger.
+ *
+ * @param cmp The comparison to perform, an EnumeratedAttribute
+ */
+ public function setWhen($cmp) {
+ $c = array_search($cmp, self::$sizeComparisons, true);
+ if ($c !== false) {
+ $this->cmp = $c;
+ }
+ }
+
+ /**
+ * When using this as a custom selector, this method will be called.
+ * It translates each parameter into the appropriate setXXX() call.
+ *
+ * @param parameters the complete set of parameters for this selector
+ */
+ public function setParameters($parameters) {
+ parent::setParameters($parameters);
+ if ($parameters !== null) {
+ for ($i = 0, $size=count($parameters); $i < $size; $i++) {
+ $paramname = $parameters[$i]->getName();
+ switch(strtolower($paramname)) {
+ case self::SIZE_KEY:
+ try {
+ $this->setValue($parameters[$i]->getValue());
+ } catch (Exception $nfe) {
+ $this->setError("Invalid size setting "
+ . $parameters[$i]->getValue());
+ }
+ break;
+ case self::UNITS_KEY:
+ $this->setUnits($parameters[$i]->getValue());
+ break;
+ case self::WHEN_KEY:
+ $this->setWhen($parameters[$i]->getValue());
+ break;
+ default:
+ $this->setError("Invalid parameter " . $paramname);
+ }
+ }
+ }
+ }
+
+ /**
+ * <p>Checks to make sure all settings are kosher. In this case, it
+ * means that the size attribute has been set (to a positive value),
+ * that the multiplier has a valid setting, and that the size limit
+ * is valid. Since the latter is a calculated value, this can only
+ * fail due to a programming error.
+ * </p>
+ * <p>If a problem is detected, the setError() method is called.
+ * </p>
+ */
+ public function verifySettings() {
+ if ($this->size < 0) {
+ $this->setError("The value attribute is required, and must be positive");
+ } elseif ($this->multiplier < 1) {
+ $this->setError("Invalid Units supplied, must be K,Ki,M,Mi,G,Gi,T,or Ti");
+ } elseif ($this->sizelimit < 0) {
+ $this->setError("Internal error: Code is not setting sizelimit correctly");
+ }
+ }
+
+ /**
+ * The heart of the matter. This is where the selector gets to decide
+ * on the inclusion of a file in a particular fileset.
+ *
+ * @param basedir A PhingFile object for the base directory
+ * @param filename The name of the file to check
+ * @param file A PhingFile object for this filename
+ * @return whether the file should be selected or not
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+
+ $this->validate();
+
+ // Directory size never selected for
+ if ($file->isDirectory()) {
+ return true;
+ }
+ if ($this->cmp === 0) {
+ return ($file->length() < $this->sizelimit);
+ } elseif ($this->cmp === 1) {
+ return ($file->length() > $this->sizelimit);
+ } else {
+ return ($file->length() === $this->sizelimit);
+ }
+ }
+
+}
+
diff --git a/buildscripts/phing/classes/phing/types/selectors/TypeSelector.php b/buildscripts/phing/classes/phing/types/selectors/TypeSelector.php
new file mode 100755
index 00000000..6ff024e8
--- /dev/null
+++ b/buildscripts/phing/classes/phing/types/selectors/TypeSelector.php
@@ -0,0 +1,120 @@
+<?php
+
+/*
+ * $Id: 95c34bb6a364dc0131e9e9c5c124d5074b4a2a21 $
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the LGPL. For more information please see
+ * <http://phing.info>.
+ */
+
+require_once 'phing/types/selectors/BaseExtendSelector.php';
+
+/**
+ * Selector that selects a certain kind of file: directory or regular file.
+ *
+ * @author Hans Lellelid <hans@xmpl.org> (Phing)
+ * @author Jeff Turner <jefft@apache.org> (Ant)
+ * @version $Id: 95c34bb6a364dc0131e9e9c5c124d5074b4a2a21 $
+ * @package phing.types.selectors
+ */
+class TypeSelector extends BaseExtendSelector {
+
+ private $type;
+
+ /** Key to used for parameterized custom selector */
+ const TYPE_KEY = "type";
+
+ /** Valid types */
+ private static $types = array('file', 'dir', 'link');
+
+ /**
+ * @return string A string describing this object
+ */
+ public function toString() {
+ $buf = "{typeselector type: " . $this->type . "}";
+ return $buf;
+ }
+
+ /**
+ * Set the type of file to require.
+ * @param string $type The type of file - 'file' or 'dir'
+ */
+ public function setType($type) {
+ $this->type = $type;
+ }
+
+ /**
+ * When using this as a custom selector, this method will be called.
+ * It translates each parameter into the appropriate setXXX() call.
+ *
+ * @param array $parameters the complete set of parameters for this selector
+ */
+ public function setParameters($parameters) {
+ parent::setParameters($parameters);
+ if ($parameters !== null) {
+ for ($i = 0, $size=count($parameters); $i < $size; $i++) {
+ $paramname = $parameters[$i]->getName();
+ if (self::TYPE_KEY == strtolower($paramname)) {
+ $this->setType($parameters[$i]->getValue());
+ } else {
+ $this->setError("Invalid parameter " . $paramname);
+ }
+ }
+ }
+ }
+
+ /**
+ * Checks to make sure all settings are kosher. In this case, it
+ * means that the pattern attribute has been set.
+ *
+ */
+ public function verifySettings() {
+ if ($this->type === null) {
+ $this->setError("The type attribute is required");
+ } elseif (!in_array($this->type, self::$types, true)) {
+ $this->setError("Invalid type specified; must be one of (" . implode(self::$types) . ")");
+ }
+ }
+
+ /**
+ * The heart of the matter. This is where the selector gets to decide
+ * on the inclusion of a file in a particular fileset.
+ *
+ * @param PhingFile $basedir the base directory the scan is being done from
+ * @param string $filename is the name of the file to check
+ * @param PhingFile $file is a PhingFile object the selector can use
+ * @return boolean Whether the file should be selected or not
+ */
+ public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {
+ // throw BuildException on error
+ $this->validate();
+
+ if ($file->isLink()) {
+ if ($this->type == 'link')
+ return true;
+
+ $this->log($file->getAbsolutePath() . " is a link, proceeding with " . $file->getCanonicalPath() . " instead.", Project::MSG_DEBUG);
+ $file = new PhingFile($file->getCanonicalPath());
+ }
+
+ if ($file->isDirectory()) {
+ return $this->type === 'dir';
+ } else {
+ return $this->type === 'file';
+ }
+ }
+
+}