Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 72968 invoked from network); 2 Dec 2004 11:57:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 2 Dec 2004 11:57:39 -0000 Received: (qmail 30601 invoked by uid 500); 2 Dec 2004 11:57:35 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 30543 invoked by uid 500); 2 Dec 2004 11:57:34 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 30526 invoked by uid 99); 2 Dec 2004 11:57:34 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from gate.corvil.net (HELO corvil.com) (213.94.219.177) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 02 Dec 2004 03:57:33 -0800 Received: from [172.18.1.171] (angel.local.corvil.com [172.18.1.171]) by corvil.com (8.12.9/8.12.5) with ESMTP id iB2BvNwS098564 for ; Thu, 2 Dec 2004 11:57:25 GMT (envelope-from peterreilly@apache.org) Message-ID: <41AF0345.9010809@apache.org> Date: Thu, 02 Dec 2004 11:57:57 +0000 From: Peter Reilly User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ant Developers List Subject: Re: [Patch] style of UpToDate References: <41AEE4A3.2030605@it.fts-vn.com> In-Reply-To: <41AEE4A3.2030605@it.fts-vn.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Kevin Jackson wrote: > Just removed the C++ style private variables cool, but... 1) why place a "final" in the arguments 2) you should only use the "this." in the setter > > Why set dir to null here? Is there a problem with the size of the > object and the GC not collecting it in time? if not it doesn't seem > to be relevant I do not know the code, but the "dir" is use in the sfs.restrict() call, so this may be the reason that it is set to null. > > protected boolean scanDir(File srcDir, String[] files) { > SourceFileScanner sfs = new SourceFileScanner(this); > FileNameMapper mapper = null; > File dir = srcDir; > if (mapperElement == null) { > MergingMapper mm = new MergingMapper(); > mm.setTo(this.targetFile.getAbsolutePath()); > mapper = mm; > dir = null; > } else { > mapper = mapperElement.getImplementation(); > } > return sfs.restrict(files, srcDir, dir, mapper).length == 0; > } > > Kev > >------------------------------------------------------------------------ > >Index: UpToDate.java >=================================================================== >RCS file: /home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/UpToDate.java,v >retrieving revision 1.36 >diff -u -r1.36 UpToDate.java >--- UpToDate.java 9 Mar 2004 16:48:06 -0000 1.36 >+++ UpToDate.java 2 Dec 2004 09:44:05 -0000 >@@ -42,10 +42,10 @@ > > public class UpToDate extends Task implements Condition { > >- private String _property; >- private String _value; >- private File _sourceFile; >- private File _targetFile; >+ private String property; >+ private String value; >+ private File sourceFile; >+ private File targetFile; > private Vector sourceFileSets = new Vector(); > > protected Mapper mapperElement = null; >@@ -56,8 +56,8 @@ > * > * @param property the name of the property to set if Target is up-to-date. > */ >- public void setProperty(String property) { >- _property = property; >+ public void setProperty(final String property) { >+ this.property = property; > } > > /** >@@ -66,15 +66,15 @@ > * > * @param value the value to set the property to if Target is up-to-date > */ >- public void setValue(String value) { >- _value = value; >+ public void setValue(final String value) { >+ this.value = value; > } > > /** > * Returns the value, or "true" if a specific value wasn't provided. > */ > private String getValue() { >- return (_value != null) ? _value : "true"; >+ return (this.value != null) ? this.value : "true"; > } > > /** >@@ -83,8 +83,8 @@ > * > * @param file the file we are checking against. > */ >- public void setTargetFile(File file) { >- _targetFile = file; >+ public void setTargetFile(final File file) { >+ this.targetFile = file; > } > > /** >@@ -93,14 +93,14 @@ > * > * @param file the file we are checking against the target file. > */ >- public void setSrcfile(File file) { >- _sourceFile = file; >+ public void setSrcfile(final File file) { >+ this.sourceFile = file; > } > > /** > * Nested <srcfiles> element. > */ >- public void addSrcfiles(FileSet fs) { >+ public void addSrcfiles(final FileSet fs) { > sourceFileSets.addElement(fs); > } > >@@ -121,32 +121,32 @@ > * see if the target(s) is/are up-to-date. > */ > public boolean eval() { >- if (sourceFileSets.size() == 0 && _sourceFile == null) { >+ if (sourceFileSets.size() == 0 && this.sourceFile == null) { > throw new BuildException("At least one srcfile or a nested " > + " element must be set."); > } > >- if (sourceFileSets.size() > 0 && _sourceFile != null) { >+ if (sourceFileSets.size() > 0 && this.sourceFile != null) { > throw new BuildException("Cannot specify both the srcfile " > + "attribute and a nested " > + "element."); > } > >- if (_targetFile == null && mapperElement == null) { >+ if (this.targetFile == null && mapperElement == null) { > throw new BuildException("The targetfile attribute or a nested " > + "mapper element must be set."); > } > > // if the target file is not there, then it can't be up-to-date >- if (_targetFile != null && !_targetFile.exists()) { >- log("The targetfile \"" + _targetFile.getAbsolutePath() >+ if (this.targetFile != null && !this.targetFile.exists()) { >+ log("The targetfile \"" + this.targetFile.getAbsolutePath() > + "\" does not exist.", Project.MSG_VERBOSE); > return false; > } > > // if the source file isn't there, throw an exception >- if (_sourceFile != null && !_sourceFile.exists()) { >- throw new BuildException(_sourceFile.getAbsolutePath() >+ if (this.sourceFile != null && !this.sourceFile.exists()) { >+ throw new BuildException(this.sourceFile.getAbsolutePath() > + " not found."); > } > >@@ -159,14 +159,14 @@ > ds.getIncludedFiles()); > } > >- if (_sourceFile != null) { >+ if (this.sourceFile != null) { > if (mapperElement == null) { > upToDate = upToDate >- && (_targetFile.lastModified() >= _sourceFile.lastModified()); >+ && (this.targetFile.lastModified() >= this.sourceFile.lastModified()); > } else { > SourceFileScanner sfs = new SourceFileScanner(this); > upToDate = upToDate >- && (sfs.restrict(new String[] {_sourceFile.getAbsolutePath()}, >+ && (sfs.restrict(new String[] {this.sourceFile.getAbsolutePath()}, > null, null, > mapperElement.getImplementation()).length == 0); > } >@@ -180,15 +180,15 @@ > * than (each of) the corresponding source file(s). > */ > public void execute() throws BuildException { >- if (_property == null) { >+ if (this.property == null) { > throw new BuildException("property attribute is required.", > getLocation()); > } > boolean upToDate = eval(); > if (upToDate) { >- this.getProject().setNewProperty(_property, getValue()); >+ this.getProject().setNewProperty(this.property, getValue()); > if (mapperElement == null) { >- log("File \"" + _targetFile.getAbsolutePath() >+ log("File \"" + this.targetFile.getAbsolutePath() > + "\" is up-to-date.", Project.MSG_VERBOSE); > } else { > log("All target files are up-to-date.", >@@ -203,7 +203,7 @@ > File dir = srcDir; > if (mapperElement == null) { > MergingMapper mm = new MergingMapper(); >- mm.setTo(_targetFile.getAbsolutePath()); >+ mm.setTo(this.targetFile.getAbsolutePath()); > mapper = mm; > dir = null; > } else { > > > >------------------------------------------------------------------------ > >--------------------------------------------------------------------- >To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org >For additional commands, e-mail: dev-help@ant.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org