Return-Path: Delivered-To: apmail-ant-notifications-archive@locus.apache.org Received: (qmail 4992 invoked from network); 13 Aug 2008 15:55:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Aug 2008 15:55:26 -0000 Received: (qmail 88989 invoked by uid 500); 13 Aug 2008 15:55:26 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 88938 invoked by uid 500); 13 Aug 2008 15:55:25 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 88929 invoked by uid 99); 13 Aug 2008 15:55:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Aug 2008 08:55:25 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Aug 2008 15:54:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id ACE88238899C; Wed, 13 Aug 2008 08:55:05 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r685593 - in /ant/core/trunk: ./ docs/manual/CoreTypes/ src/main/org/apache/tools/ant/types/ src/main/org/apache/tools/ant/types/selectors/ src/resources/org/apache/tools/ant/types/resources/selectors/ src/tests/antunit/types/resources/sele... Date: Wed, 13 Aug 2008 15:55:03 -0000 To: notifications@ant.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080813155505.ACE88238899C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bodewig Date: Wed Aug 13 08:55:01 2008 New Revision: 685593 URL: http://svn.apache.org/viewvc?rev=685593&view=rev Log: Add readable and writable selectors. Addresses PR 45081. Added: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java (with props) ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java (with props) ant/core/trunk/src/tests/antunit/types/resources/selectors/readwrite-test.xml (with props) ant/core/trunk/src/tests/antunit/types/selectors/ ant/core/trunk/src/tests/antunit/types/selectors/readwrite-test.xml (with props) Modified: ant/core/trunk/WHATSNEW ant/core/trunk/docs/manual/CoreTypes/resources.html ant/core/trunk/docs/manual/CoreTypes/selectors.html ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java ant/core/trunk/src/resources/org/apache/tools/ant/types/resources/selectors/antlib.xml Modified: ant/core/trunk/WHATSNEW URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=685593&r1=685592&r2=685593&view=diff ============================================================================== --- ant/core/trunk/WHATSNEW (original) +++ ant/core/trunk/WHATSNEW Wed Aug 13 08:55:01 2008 @@ -252,6 +252,11 @@ not an archive earlier if the file is big. Bugzilla Report 45463. + * New file and resource selectors and have + been added that select file which the current process can read or + write. + Bugzilla Report 45081. + Changes from Ant 1.7.0 TO Ant 1.7.1 ============================================= Modified: ant/core/trunk/docs/manual/CoreTypes/resources.html URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTypes/resources.html?rev=685593&r1=685592&r2=685593&view=diff ============================================================================== --- ant/core/trunk/docs/manual/CoreTypes/resources.html (original) +++ ant/core/trunk/docs/manual/CoreTypes/resources.html Wed Aug 13 08:55:01 2008 @@ -487,6 +487,10 @@ resources whose contents match a particular regular expression.
  • compare - select resources based on comparison to other resources.
  • +
  • readable - + Select files (resources must be files) if they are readable.
  • +
  • writable - + Select files (resources must be files) if they are writable.
  • name

    Modified: ant/core/trunk/docs/manual/CoreTypes/selectors.html URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTypes/selectors.html?rev=685593&r1=685592&r2=685593&view=diff ============================================================================== --- ant/core/trunk/docs/manual/CoreTypes/selectors.html (original) +++ ant/core/trunk/docs/manual/CoreTypes/selectors.html Wed Aug 13 08:55:01 2008 @@ -89,6 +89,10 @@ Use a BSF or JSR 223 scripting language to create your own selector +
  • <readable> - + Select files if they are readable.
  • +
  • <writable> - + Select files if they are writable.
  • @@ -969,6 +973,24 @@ + +

    Readable Selector

    + +

    The <readable> selector selects only files + that are readable. Ant only invokes + java.io.File#canRead so if a file is unreadable + but the Java VM cannot detect this state, this selector will + still select the file.

    + + +

    Writable Selector

    + +

    The <writable> selector selects only files + that are writable. Ant only invokes + java.io.File#canWrite so if a file is unwritable + but the Java VM cannot detect this state, this selector will + still select the file.

    +

    Script Selector

    Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java?rev=685593&r1=685592&r2=685593&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java Wed Aug 13 08:55:01 2008 @@ -45,6 +45,8 @@ import org.apache.tools.ant.types.selectors.DifferentSelector; import org.apache.tools.ant.types.selectors.SelectorContainer; import org.apache.tools.ant.types.selectors.ContainsRegexpSelector; +import org.apache.tools.ant.types.selectors.ReadableSelector; +import org.apache.tools.ant.types.selectors.WritableSelector; import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector; /** @@ -724,6 +726,14 @@ appendSelector(selector); } + public void addReadable(ReadableSelector r) { + appendSelector(r); + } + + public void addWritable(WritableSelector w) { + appendSelector(w); + } + /** * Add an arbitary selector. * @param selector the FileSelector to add. Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java?rev=685593&r1=685592&r2=685593&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/AbstractSelectorContainer.java Wed Aug 13 08:55:01 2008 @@ -276,6 +276,14 @@ appendSelector(selector); } + public void addReadable(ReadableSelector r) { + appendSelector(r); + } + + public void addWritable(WritableSelector w) { + appendSelector(w); + } + /** * add an arbitary selector * @param selector the selector to add Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java?rev=685593&r1=685592&r2=685593&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/BaseSelectorContainer.java Wed Aug 13 08:55:01 2008 @@ -301,6 +301,14 @@ appendSelector(selector); } + public void addReadable(ReadableSelector r) { + appendSelector(r); + } + + public void addWritable(WritableSelector w) { + appendSelector(w); + } + /** * add an arbitary selector * @param selector the selector to add Added: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java?rev=685593&view=auto ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java (added) +++ ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java Wed Aug 13 08:55:01 2008 @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.types.selectors; + +import java.io.File; +import org.apache.tools.ant.types.Resource; +import org.apache.tools.ant.types.resources.FileProvider; +import org.apache.tools.ant.types.resources.selectors.ResourceSelector; + +/** + * A selector that selects readable files. + * + *

    Readable is definied in terms of java.io.File#canRead, this + * means the selector will accept any file that exists and is readable + * by the application.

    + * + * @since Ant 1.8.0 + */ +public class ReadableSelector implements FileSelector, ResourceSelector { + + public boolean isSelected(File basedir, String filename, File file) { + return file != null && file.canRead(); + } + + public boolean isSelected(Resource r) { + if (r instanceof FileProvider) { + return isSelected(null, null, ((FileProvider) r).getFile()); + } + return false; + } +} \ No newline at end of file Propchange: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java ------------------------------------------------------------------------------ svn:eol-style = native Added: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java?rev=685593&view=auto ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java (added) +++ ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java Wed Aug 13 08:55:01 2008 @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.types.selectors; + +import java.io.File; +import org.apache.tools.ant.types.Resource; +import org.apache.tools.ant.types.resources.FileProvider; +import org.apache.tools.ant.types.resources.selectors.ResourceSelector; + +/** + * A selector that selects writable files. + * + *

    Writable is definied in terms of java.io.File#canWrite, this + * means the selector will accept any file that exists and is + * writable by the application.

    + * + * @since Ant 1.8.0 + */ +public class WritableSelector implements FileSelector, ResourceSelector { + + public boolean isSelected(File basedir, String filename, File file) { + return file != null && file.canWrite(); + } + + public boolean isSelected(Resource r) { + if (r instanceof FileProvider) { + return isSelected(null, null, ((FileProvider) r).getFile()); + } + return false; + } +} \ No newline at end of file Propchange: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: ant/core/trunk/src/resources/org/apache/tools/ant/types/resources/selectors/antlib.xml URL: http://svn.apache.org/viewvc/ant/core/trunk/src/resources/org/apache/tools/ant/types/resources/selectors/antlib.xml?rev=685593&r1=685592&r2=685593&view=diff ============================================================================== --- ant/core/trunk/src/resources/org/apache/tools/ant/types/resources/selectors/antlib.xml (original) +++ ant/core/trunk/src/resources/org/apache/tools/ant/types/resources/selectors/antlib.xml Wed Aug 13 08:55:01 2008 @@ -42,8 +42,12 @@ classname="org.apache.tools.ant.types.resources.selectors.Not" /> + + Added: ant/core/trunk/src/tests/antunit/types/resources/selectors/readwrite-test.xml URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/types/resources/selectors/readwrite-test.xml?rev=685593&view=auto ============================================================================== --- ant/core/trunk/src/tests/antunit/types/resources/selectors/readwrite-test.xml (added) +++ ant/core/trunk/src/tests/antunit/types/resources/selectors/readwrite-test.xml Wed Aug 13 08:55:01 2008 @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Propchange: ant/core/trunk/src/tests/antunit/types/resources/selectors/readwrite-test.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: ant/core/trunk/src/tests/antunit/types/selectors/readwrite-test.xml URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/types/selectors/readwrite-test.xml?rev=685593&view=auto ============================================================================== --- ant/core/trunk/src/tests/antunit/types/selectors/readwrite-test.xml (added) +++ ant/core/trunk/src/tests/antunit/types/selectors/readwrite-test.xml Wed Aug 13 08:55:01 2008 @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Propchange: ant/core/trunk/src/tests/antunit/types/selectors/readwrite-test.xml ------------------------------------------------------------------------------ svn:eol-style = native