ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: svn commit: r579266 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh: ScpFromMessage.java ScpFromMessageBySftp.java ScpToMessage.java ScpToMessageBySftp.java
Date Wed, 26 Sep 2007 11:41:08 GMT
On 9/26/07, Jan.Materne@rzf.fin-nrw.de <Jan.Materne@rzf.fin-nrw.de> wrote:
> What about pulling the HUNDRED_KILOBYTES constant to AbstractSshMessage and make it protected?
Or public.

> Or using a utility class holding these constants?
This has some history, It is my fourth time trying to remove the
magic numbers. Each of the other times, I used a magic numbers class,
or classes, but had a problem in that I found it too easy to make mistakes
and the code was not easy to read. This time, I decided to do a file at
at time, use //CheckStyle:*** OFF at places where I could not figure
a good name (for example 3, 4, 0x3f, etc) and only do a small number
for each commit
so that other people could see if the changes were correct.
Any silliness can be refactored later.

Peter

>
> Jan
>
> >-----Urspr√ľngliche Nachricht-----
> >Von: peterreilly@apache.org [mailto:peterreilly@apache.org]
> >Gesendet: Dienstag, 25. September 2007 16:39
> >An: ant-cvs@apache.org
> >Betreff: svn commit: r579266 - in
> >/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional
> >/ssh: ScpFromMessage.java ScpFromMessageBySftp.java
> >ScpToMessage.java ScpToMessageBySftp.java
> >
> >Author: peterreilly
> >Date: Tue Sep 25 07:38:40 2007
> >New Revision: 579266
> >
> >URL: http://svn.apache.org/viewvc?rev=579266&view=rev
> >Log:
> >magic number
> >
> >Modified:
> >
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpFromMessage.java
> >
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpFromMessageBySftp.java
> >
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpToMessage.java
> >
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpToMessageBySftp.java
> >
> >Modified:
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpFromMessage.java
> >URL:
> >http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache
> >/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java?rev=579266
> >&r1=579265&r2=579266&view=diff
> >===============================================================
> >===============
> >---
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpFromMessage.java (original)
> >+++
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpFromMessage.java Tue Sep 25 07:38:40 2007
> >@@ -34,6 +34,7 @@
> >  */
> > public class ScpFromMessage extends AbstractSshMessage {
> >
> >+    private static final int HUNDRED_KILOBYTES = 102400;
> >     private static final byte LINE_FEED = 0x0a;
> >     private static final int BUFFER_SIZE = 1024;
> >
> >@@ -207,7 +208,7 @@
> >         long startTime = System.currentTimeMillis();
> >
> >         // only track progress for files larger than 100kb in
> >verbose mode
> >-        boolean trackProgress = getVerbose() && filesize > 102400;
> >+        boolean trackProgress = getVerbose() && filesize >
> >HUNDRED_KILOBYTES;
> >         // since filesize keeps on decreasing we have to store the
> >         // initial filesize
> >         long initFilesize = filesize;
> >
> >Modified:
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpFromMessageBySftp.java
> >URL:
> >http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache
> >/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java?rev=
> >579266&r1=579265&r2=579266&view=diff
> >===============================================================
> >===============
> >---
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpFromMessageBySftp.java (original)
> >+++
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpFromMessageBySftp.java Tue Sep 25 07:38:40 2007
> >@@ -33,6 +33,8 @@
> >  */
> > public class ScpFromMessageBySftp extends ScpFromMessage {
> >
> >+    private static final int HUNDRED_KILOBYTES = 102400;
> >+
> >     private String remoteFile;
> >     private File localFile;
> >     private boolean isRecursive = false;
> >@@ -154,7 +156,7 @@
> >         long totalLength = le.getAttrs().getSize();
> >
> >         SftpProgressMonitor monitor = null;
> >-        boolean trackProgress = getVerbose() && totalLength > 102400;
> >+        boolean trackProgress = getVerbose() && totalLength >
> >HUNDRED_KILOBYTES;
> >         if (trackProgress) {
> >             monitor = getProgressMonitor();
> >         }
> >
> >Modified:
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpToMessage.java
> >URL:
> >http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache
> >/tools/ant/taskdefs/optional/ssh/ScpToMessage.java?rev=579266&r
> >1=579265&r2=579266&view=diff
> >===============================================================
> >===============
> >---
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpToMessage.java (original)
> >+++
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpToMessage.java Tue Sep 25 07:38:40 2007
> >@@ -34,6 +34,7 @@
> >  */
> > public class ScpToMessage extends AbstractSshMessage {
> >
> >+    private static final int HUNDRED_KILOBYTES = 102400;
> >     private static final int BUFFER_SIZE = 1024;
> >
> >     private File localFile;
> >@@ -234,7 +235,7 @@
> >         long totalLength = 0;
> >
> >         // only track progress for files larger than 100kb in
> >verbose mode
> >-        boolean trackProgress = getVerbose() && filesize > 102400;
> >+        boolean trackProgress = getVerbose() && filesize >
> >HUNDRED_KILOBYTES;
> >         // since filesize keeps on decreasing we have to store the
> >         // initial filesize
> >         long initFilesize = filesize;
> >
> >Modified:
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpToMessageBySftp.java
> >URL:
> >http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache
> >/tools/ant/taskdefs/optional/ssh/ScpToMessageBySftp.java?rev=57
> >9266&r1=579265&r2=579266&view=diff
> >===============================================================
> >===============
> >---
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpToMessageBySftp.java (original)
> >+++
> >ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/
> >ssh/ScpToMessageBySftp.java Tue Sep 25 07:38:40 2007
> >@@ -34,6 +34,8 @@
> >  */
> > public class ScpToMessageBySftp extends
> >ScpToMessage/*AbstractSshMessage*/ {
> >
> >+    private static final int HUNDRED_KILOBYTES = 102400;
> >+
> >     private File localFile;
> >     private String remotePath;
> >     private List directoryList;
> >@@ -205,7 +207,7 @@
> >         long totalLength = filesize;
> >
> >         // only track progress for files larger than 100kb in
> >verbose mode
> >-        boolean trackProgress = getVerbose() && filesize > 102400;
> >+        boolean trackProgress = getVerbose() && filesize >
> >HUNDRED_KILOBYTES;
> >
> >         SftpProgressMonitor monitor = null;
> >         if (trackProgress) {
> >
> >
> >
> >---------------------------------------------------------------------
> >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
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message