PageRenderTime 27ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/gulliver/thirdparty/phing/tasks/system/MatchingTask.php

https://bitbucket.org/ferOnti/processmaker
PHP | 361 lines | 118 code | 41 blank | 202 comment | 0 complexity | e2c1189ef4daec256bb728ba0c46fbed MD5 | raw file
  1. <?php
  2. /*
  3. * $Id: MatchingTask.php 3076 2006-12-18 08:52:12Z fabien $
  4. *
  5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. *
  17. * This software consists of voluntary contributions made by many individuals
  18. * and is licensed under the LGPL. For more information please see
  19. * <http://phing.info>.
  20. */
  21. require_once 'phing/TaskPhing.php';
  22. require_once 'phing/types/selectors/SelectorContainer.php';
  23. include_once 'phing/types/FileSet.php';
  24. include_once 'phing/types/PatternSet.php';
  25. include_once 'phing/util/DirectoryScanner.php';
  26. /**
  27. * This is an abstract task that should be used by all those tasks that
  28. * require to include or exclude files based on pattern matching.
  29. *
  30. * This is very closely based on the ANT class of the same name.
  31. *
  32. * @author Hans Lellelid <hans@xmpl.org> (Phing)
  33. * @author Arnout J. Kuiper <ajkuiper@wxs.nl> (Ant)
  34. * @author Stefano Mazzocchi <stefano@apache.org> (Ant)
  35. * @author Sam Ruby <rubys@us.ibm.com> (Ant)
  36. * @author Jon S. Stevens <jon@clearink.com> (Ant
  37. * @author Stefan Bodewig <stefan.bodewig@epost.de> (Ant)
  38. * @author Bruce Atherton <bruce@callenish.com> (Ant)
  39. * @version $Revision: 1.4 $
  40. * @package phing.tasks.system
  41. */
  42. abstract class MatchingTask extends TaskPhing implements SelectorContainer {
  43. /** @var boolean */
  44. protected $useDefaultExcludes = true;
  45. /** @var FileSet */
  46. protected $fileset;
  47. /**
  48. * Create instance; set fileset to new FileSet.
  49. */
  50. public function __construct() {
  51. $this->fileset = new FileSet();
  52. }
  53. /**
  54. * @see ProjectComponent::setProject()
  55. */
  56. public function setProject(Project $project) {
  57. parent::setProject($project);
  58. $this->fileset->setProject($project);
  59. }
  60. /**
  61. * add a name entry on the include list
  62. * @return PatternSetNameEntry
  63. */
  64. public function createInclude() {
  65. return $this->fileset->createInclude();
  66. }
  67. /**
  68. * add a name entry on the include files list
  69. * @return PatternSetNameEntry
  70. */
  71. public function createIncludesFile() {
  72. return $this->fileset->createIncludesFile();
  73. }
  74. /**
  75. * add a name entry on the exclude list
  76. * @return PatternSetNameEntry
  77. */
  78. public function createExclude() {
  79. return $this->fileset->createExclude();
  80. }
  81. /**
  82. * add a name entry on the include files list
  83. * @return PatternSetNameEntry
  84. */
  85. public function createExcludesFile() {
  86. return $this->fileset->createExcludesFile();
  87. }
  88. /**
  89. * add a set of patterns
  90. * @return PatternSet
  91. */
  92. public function createPatternSet() {
  93. return $this->fileset->createPatternSet();
  94. }
  95. /**
  96. * Sets the set of include patterns. Patterns may be separated by a comma
  97. * or a space.
  98. *
  99. * @param string $includes the string containing the include patterns
  100. * @return void
  101. */
  102. public function setIncludes($includes) {
  103. $this->fileset->setIncludes($includes);
  104. }
  105. /**
  106. * Sets the set of exclude patterns. Patterns may be separated by a comma
  107. * or a space.
  108. *
  109. * @param string $excludes the string containing the exclude patterns
  110. */
  111. public function setExcludes($excludes) {
  112. $this->fileset->setExcludes($excludes);
  113. }
  114. /**
  115. * Sets whether default exclusions should be used or not.
  116. *
  117. * @param boolean $useDefaultExcludes "true"|"on"|"yes" when default exclusions
  118. * should be used, "false"|"off"|"no" when they
  119. * shouldn't be used.
  120. */
  121. public function setDefaultexcludes($useDefaultExcludes) {
  122. $this->useDefaultExcludes = (boolean) $useDefaultExcludes;
  123. }
  124. /**
  125. * Returns the directory scanner needed to access the files to process.
  126. * @return DirectoryScanner
  127. */
  128. protected function getDirectoryScanner(PhingFile $baseDir) {
  129. $this->fileset->setDir($baseDir);
  130. $this->fileset->setDefaultexcludes($this->useDefaultExcludes);
  131. return $this->fileset->getDirectoryScanner($this->project);
  132. }
  133. /**
  134. * Sets the name of the file containing the includes patterns.
  135. *
  136. * @param PhingFile $includesfile A string containing the filename to fetch
  137. * the include patterns from.
  138. * @return void
  139. */
  140. public function setIncludesfile(PhingFile $includesfile) {
  141. $this->fileset->setIncludesfile(includesfile);
  142. }
  143. /**
  144. * Sets the name of the file containing the includes patterns.
  145. *
  146. * @param PhingFile $excludesfile A string containing the filename to fetch
  147. * the include patterns from.
  148. * @return void
  149. */
  150. public function setExcludesfile(PhingFile $excludesfile) {
  151. $this->fileset->setExcludesfile($excludesfile);
  152. }
  153. /**
  154. * Sets case sensitivity of the file system
  155. *
  156. * @param boolean $isCaseSensitive "true"|"on"|"yes" if file system is case
  157. * sensitive, "false"|"off"|"no" when not.
  158. * @return void
  159. */
  160. public function setCaseSensitive($isCaseSensitive) {
  161. $this->fileset->setCaseSensitive($isCaseSensitive);
  162. }
  163. /**
  164. * Sets whether or not symbolic links should be followed.
  165. *
  166. * @param boolean $followSymlinks whether or not symbolic links should be followed
  167. * @return void
  168. */
  169. public function setFollowSymlinks($followSymlinks) {
  170. $this->fileset->setFollowSymlinks($followSymlinks);
  171. }
  172. /**
  173. * Indicates whether there are any selectors here.
  174. *
  175. * @return boolean Whether any selectors are in this container
  176. */
  177. public function hasSelectors() {
  178. return $this->fileset->hasSelectors();
  179. }
  180. /**
  181. * Gives the count of the number of selectors in this container
  182. *
  183. * @return int The number of selectors in this container
  184. */
  185. public function selectorCount() {
  186. return $this->fileset->selectorCount();
  187. }
  188. /**
  189. * Returns the set of selectors as an array.
  190. *
  191. * @return array FileSelector[] An array of selectors in this container
  192. */
  193. public function getSelectors(Project $p) {
  194. return $this->fileset->getSelectors($p);
  195. }
  196. /**
  197. * Returns an enumerator for accessing the set of selectors.
  198. *
  199. * @return an enumerator that goes through each of the selectors
  200. */
  201. public function selectorElements() {
  202. return $this->fileset->selectorElements();
  203. }
  204. /**
  205. * Add a new selector into this container.
  206. *
  207. * @param FileSelector $selector the new selector to add
  208. * @return void
  209. */
  210. public function appendSelector(FileSelector $selector) {
  211. $this->fileset->appendSelector($selector);
  212. }
  213. /* Methods below all add specific selectors */
  214. /**
  215. * add a "Select" selector entry on the selector list
  216. * @return SelectSelector
  217. */
  218. public function createSelector() {
  219. return $this->fileset->createSelector();
  220. }
  221. /**
  222. * add an "And" selector entry on the selector list
  223. * @return AndSelector
  224. */
  225. public function createAnd() {
  226. return $this->fileset->createAnd();
  227. }
  228. /**
  229. * add an "Or" selector entry on the selector list
  230. * @return void
  231. */
  232. public function createOr() {
  233. return $this->fileset->createOr();
  234. }
  235. /**
  236. * add a "Not" selector entry on the selector list
  237. * @return NotSelector
  238. */
  239. public function createNot() {
  240. return $this->fileset->createNot();
  241. }
  242. /**
  243. * add a "None" selector entry on the selector list
  244. * @return NoneSelector
  245. */
  246. public function createNone() {
  247. return $this->fileset->createNone();
  248. }
  249. /**
  250. * add a majority selector entry on the selector list
  251. * @return MajoritySelector
  252. */
  253. public function createMajority() {
  254. return $this->fileset->createMajority();
  255. }
  256. /**
  257. * add a selector date entry on the selector list
  258. * @return DateSelector
  259. */
  260. public function createDate() {
  261. return $this->fileset->addDate();
  262. }
  263. /**
  264. * add a selector size entry on the selector list
  265. * @return SizeSelector
  266. */
  267. public function createSize() {
  268. return $this->fileset->createSize();
  269. }
  270. /**
  271. * add a selector filename entry on the selector list
  272. * @return FilenameSelector
  273. */
  274. public function createFilename() {
  275. return $this->fileset->createFilename();
  276. }
  277. /**
  278. * add an extended selector entry on the selector list
  279. * @return ExtendSelector
  280. */
  281. public function createCustom() {
  282. return $this->fileset->createCustom();
  283. }
  284. /**
  285. * add a contains selector entry on the selector list
  286. * @return ContainsSelector
  287. */
  288. public function createContains() {
  289. return $this->fileset->createContains();
  290. }
  291. /**
  292. * add a present selector entry on the selector list
  293. * @return PresentSelector
  294. */
  295. public function createPresent() {
  296. return $this->fileset->createPresent();
  297. }
  298. /**
  299. * add a depth selector entry on the selector list
  300. * @return DepthSelector
  301. */
  302. public function createDepth() {
  303. return $this->fileset->createDepth();
  304. }
  305. /**
  306. * add a depends selector entry on the selector list
  307. * @return DependSelector
  308. */
  309. public function createDepend() {
  310. return $this->fileset->createDepend();
  311. }
  312. /**
  313. * Accessor for the implict fileset.
  314. *
  315. * @return FileSet
  316. */
  317. protected final function getImplicitFileSet() {
  318. return $this->fileset;
  319. }
  320. }