commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1407341 - in /commons/proper/net/trunk/src: main/java/examples/nntp/ main/java/examples/ntp/ main/java/org/apache/commons/net/ftp/ main/java/org/apache/commons/net/ftp/parser/ main/java/org/apache/commons/net/imap/ main/java/org/apache/com...
Date Fri, 09 Nov 2012 01:31:02 GMT
Author: ggregory
Date: Fri Nov  9 01:31:00 2012
New Revision: 1407341

URL: http://svn.apache.org/viewvc?rev=1407341&view=rev
Log:
Use Java 5 enhanced loops.

Modified:
    commons/proper/net/trunk/src/main/java/examples/nntp/ExtendedNNTPOps.java
    commons/proper/net/trunk/src/main/java/examples/ntp/NTPClient.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSTrustManager.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/CompositeFileEntryParser.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/Threader.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/pop3/ExtendedPOP3Client.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/Base64.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/TrustManagerUtils.java
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/ListingFunctionalTest.java
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/CompositeFTPParseTestFramework.java
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/tftp/TFTPTest.java

Modified: commons/proper/net/trunk/src/main/java/examples/nntp/ExtendedNNTPOps.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/examples/nntp/ExtendedNNTPOps.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/examples/nntp/ExtendedNNTPOps.java (original)
+++ commons/proper/net/trunk/src/main/java/examples/nntp/ExtendedNNTPOps.java Fri Nov  9 01:31:00
2012
@@ -73,8 +73,9 @@ public class ExtendedNNTPOps {
 
             // LIST ACTIVE
             NewsgroupInfo[] fanGroups = client.listNewsgroups("alt.fan.*");
-            for (int i = 0; i < fanGroups.length; ++i) {
-                System.out.println(fanGroups[i].getNewsgroup());
+            for (NewsgroupInfo fanGroup : fanGroups)
+            {
+                System.out.println(fanGroup.getNewsgroup());
             }
 
         } catch (IOException e) {

Modified: commons/proper/net/trunk/src/main/java/examples/ntp/NTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/examples/ntp/NTPClient.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/examples/ntp/NTPClient.java (original)
+++ commons/proper/net/trunk/src/main/java/examples/ntp/NTPClient.java Fri Nov  9 01:31:00
2012
@@ -159,11 +159,11 @@ public final class NTPClient
         client.setDefaultTimeout(10000);
         try {
             client.open();
-            for (int i = 0; i < args.length; i++)
+            for (String arg : args)
             {
                 System.out.println();
                 try {
-                    InetAddress hostAddr = InetAddress.getByName(args[i]);
+                    InetAddress hostAddr = InetAddress.getByName(arg);
                     System.out.println("> " + hostAddr.getHostName() + "/" + hostAddr.getHostAddress());
                     TimeInfo info = client.getTime(hostAddr);
                     processResponse(info);

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSClient.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSClient.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSClient.java Fri
Nov  9 01:31:00 2012
@@ -516,8 +516,9 @@ public class FTPSClient extends FTPClien
      * @return True - A set point is right / False - A set point is not right
      */
     private boolean checkPROTValue(String prot) {
-        for (int p = 0; p < PROT_COMMAND_VALUE.length; p++) {
-            if (PROT_COMMAND_VALUE[p].equals(prot)) {
+        for (String element : PROT_COMMAND_VALUE)
+        {
+            if (element.equals(prot)) {
                 return true;
             }
         }

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSTrustManager.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSTrustManager.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSTrustManager.java
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSTrustManager.java
Fri Nov  9 01:31:00 2012
@@ -42,9 +42,9 @@ public class FTPSTrustManager implements
 
     public void checkServerTrusted(X509Certificate[] certificates, String authType) throws
CertificateException
     {
-        for (int i = 0; i < certificates.length; ++i)
+        for (X509Certificate certificate : certificates)
         {
-            certificates[i].checkValidity();
+            certificate.checkValidity();
         }
     }
 

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/CompositeFileEntryParser.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/CompositeFileEntryParser.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/CompositeFileEntryParser.java
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/CompositeFileEntryParser.java
Fri Nov  9 01:31:00 2012
@@ -55,10 +55,8 @@ public class CompositeFileEntryParser ex
         }
         else
         {
-            for (int iterParser=0; iterParser < ftpFileEntryParsers.length; iterParser++)
+            for (FTPFileEntryParser ftpFileEntryParser : ftpFileEntryParsers)
             {
-                FTPFileEntryParser ftpFileEntryParser = ftpFileEntryParsers[iterParser];
-
                 FTPFile matched = ftpFileEntryParser.parseFTPEntry(listEntry);
                 if (matched != null)
                 {

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java
Fri Nov  9 01:31:00 2012
@@ -220,12 +220,12 @@ public class AuthenticatingIMAPClient ex
     private String _convertToHexString(byte[] a)
     {
         StringBuilder result = new StringBuilder(a.length*2);
-        for (int i = 0; i < a.length; i++)
+        for (byte element : a)
         {
-            if ( (a[i] & 0x0FF) <= 15 ) {
+            if ( (element & 0x0FF) <= 15 ) {
                 result.append("0");
             }
-            result.append(Integer.toHexString(a[i] & 0x0FF));
+            result.append(Integer.toHexString(element & 0x0FF));
         }
         return result.toString();
     }

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/Threader.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/Threader.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/Threader.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/nntp/Threader.java Fri Nov
 9 01:31:00 2012
@@ -127,8 +127,8 @@ public class Threader {
         ThreadContainer parentRef = null;
         {
             String[] references = threadable.messageThreadReferences();
-            for (int i = 0; i < references.length; ++i) {
-                String refString = references[i];
+            for (String refString : references)
+            {
                 ThreadContainer ref = idTable.get(refString);
 
                 // if this id doesnt have a container, create one

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/pop3/ExtendedPOP3Client.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/pop3/ExtendedPOP3Client.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/pop3/ExtendedPOP3Client.java
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/pop3/ExtendedPOP3Client.java
Fri Nov  9 01:31:00 2012
@@ -111,12 +111,12 @@ public class ExtendedPOP3Client extends 
     private String _convertToHexString(byte[] a)
     {
         StringBuilder result = new StringBuilder(a.length*2);
-        for (int i = 0; i < a.length; i++)
+        for (byte element : a)
         {
-            if ( (a[i] & 0x0FF) <= 15 ) {
+            if ( (element & 0x0FF) <= 15 ) {
                 result.append("0");
             }
-            result.append(Integer.toHexString(a[i] & 0x0FF));
+            result.append(Integer.toHexString(element & 0x0FF));
         }
         return result.toString();
     }

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java
Fri Nov  9 01:31:00 2012
@@ -234,12 +234,12 @@ public class AuthenticatingSMTPClient ex
     private String _convertToHexString(byte[] a)
     {
         StringBuilder result = new StringBuilder(a.length*2);
-        for (int i = 0; i < a.length; i++)
+        for (byte element : a)
         {
-            if ( (a[i] & 0x0FF) <= 15 ) {
+            if ( (element & 0x0FF) <= 15 ) {
                 result.append("0");
             }
-            result.append(Integer.toHexString(a[i] & 0x0FF));
+            result.append(Integer.toHexString(element & 0x0FF));
         }
         return result.toString();
     }

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/Telnet.java Fri Nov
 9 01:31:00 2012
@@ -775,9 +775,9 @@ class Telnet extends SocketClient
         {
             _output_.write(_COMMAND_SB);
             // Note _output_ is buffered, so might as well simplify by writing single bytes
-            for (int ii = 0; ii < subn.length; ii++)
+            for (int element : subn)
             {
-                byte b = (byte) subn[ii];
+                byte b = (byte) element;
                 if (b == (byte) TelnetCommand.IAC) { // cast is necessary because IAC is
outside the signed byte range
                     _output_.write(b); // double any IAC bytes
                 }

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/Base64.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/Base64.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/Base64.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/Base64.java Fri Nov
 9 01:31:00 2012
@@ -623,8 +623,9 @@ public class Base64 {
      * @return <code>true</code> if any byte is a valid character in the Base64
alphabet; false herwise
      */
     private static boolean containsBase64Byte(byte[] arrayOctet) {
-        for (int i = 0; i < arrayOctet.length; i++) {
-            if (isBase64(arrayOctet[i])) {
+        for (byte element : arrayOctet)
+        {
+            if (isBase64(element)) {
                 return true;
             }
         }

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/TrustManagerUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/TrustManagerUtils.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/TrustManagerUtils.java
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/TrustManagerUtils.java
Fri Nov  9 01:31:00 2012
@@ -54,9 +54,9 @@ public final class TrustManagerUtils
             throws CertificateException
         {
             if (checkServerValidity) {
-                for (int i = 0; i < certificates.length; ++i)
+                for (X509Certificate certificate : certificates)
                 {
-                    certificates[i].checkValidity();
+                    certificate.checkValidity();
                 }
             }
         }

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java
(original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java
Fri Nov  9 01:31:00 2012
@@ -110,13 +110,14 @@ public class FTPClientConfigFunctionalTe
         });
 
 
-        for (int i=0; i < files.length; i++) {
+        for (FTPFile file : files)
+        {
             // The directory contains a few additional files at the beginning
             // which aren't in the series we want. The series we want consists
             // of files named sn.dddd. This adjusts the file list to get rid
             // of the uninteresting ones.
-            if (files[i].getName().startsWith("sn")) {
-                sorted.add(files[i]);
+            if (file.getName().startsWith("sn")) {
+                sorted.add(file);
             }
         }
         return sorted;

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/ListingFunctionalTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/ListingFunctionalTest.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/ListingFunctionalTest.java
(original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/ListingFunctionalTest.java
Fri Nov  9 01:31:00 2012
@@ -68,19 +68,17 @@ public class ListingFunctionalTest exten
         Method[] methods = clasz.getDeclaredMethods();
         TestSuite allSuites = new TestSuite("FTP Listing Functional Test Suite");
 
-        for (int i = 0; i < testData.length; i++)
+        for (String[] element : testData)
         {
-            TestSuite suite = new TestSuite(testData[i][VALID_PARSERKEY]+ " @ " +testData[i][HOSTNAME]);
+            TestSuite suite = new TestSuite(element[VALID_PARSERKEY]+ " @ " +element[HOSTNAME]);
 
-            for (int j = 0; j < methods.length; j++)
+            for (Method method : methods)
             {
-                Method method = methods[j];
-
                 if (method.getName().startsWith("test"))
                 {
                     suite.addTest(new ListingFunctionalTest(
                                                             method.getName(),
-                                                            testData[i]));
+                                                            element));
                 }
             }
 

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/CompositeFTPParseTestFramework.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/CompositeFTPParseTestFramework.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/CompositeFTPParseTestFramework.java
(original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/CompositeFTPParseTestFramework.java
Fri Nov  9 01:31:00 2012
@@ -76,12 +76,12 @@ public abstract class CompositeFTPParseT
     {
         String goodsamples[][] = getGoodListings();
 
-        for (int i = 0; i < goodsamples.length; i++)
+        for (String[] goodsample : goodsamples)
         {
             FTPFileEntryParser parser = getParser();
-            for (int j = 0; j < goodsamples[i].length; j++)
+            for (int j = 0; j < goodsample.length; j++)
             {
-                String test = goodsamples[i][j];
+                String test = goodsample[j];
                 FTPFile f = parser.parseFTPEntry(test);
                 assertNotNull("Failed to parse " + test,
                         f);
@@ -99,12 +99,12 @@ public abstract class CompositeFTPParseT
     {
         String badsamples[][] = getBadListings();
 
-        for (int i = 0; i < badsamples.length; i++)
+        for (String[] badsample : badsamples)
         {
             FTPFileEntryParser parser = getParser();
-            for (int j = 0; j < badsamples[i].length; j++)
+            for (int j = 0; j < badsample.length; j++)
             {
-                String test = badsamples[i][j];
+                String test = badsample[j];
                 FTPFile f = parser.parseFTPEntry(test);
                 assertNull("Should have Failed to parse " + test,
                         nullFileOrNullDate(f));

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java
(original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java
Fri Nov  9 01:31:00 2012
@@ -48,10 +48,9 @@ public abstract class FTPParseTestFramew
     {
 
         String[] badsamples = getBadListing();
-        for (int i = 0; i < badsamples.length; i++)
+        for (String test : badsamples)
         {
 
-            String test = badsamples[i];
             FTPFile f = parser.parseFTPEntry(test);
             assertNull("Should have Failed to parse " + test,
                        nullFileOrNullDate(f));
@@ -69,10 +68,9 @@ public abstract class FTPParseTestFramew
     {
 
         String[] goodsamples = getGoodListing();
-        for (int i = 0; i < goodsamples.length; i++)
+        for (String test : goodsamples)
         {
 
-            String test = goodsamples[i];
             FTPFile f = parser.parseFTPEntry(test);
             assertNotNull("Failed to parse " + test,
                           f);

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java
(original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java
Fri Nov  9 01:31:00 2012
@@ -124,16 +124,18 @@ public class VMSFTPEntryParserTest exten
     }
 
     public void assertFileInListing(FTPFile[] listing, String name) {
-        for (int i = 0; i < listing.length; i++) {
-            if (name.equals(listing[i].getName())) {
+        for (FTPFile element : listing)
+        {
+            if (name.equals(element.getName())) {
                 return;
             }
         }
         fail("File " + name + " not found in supplied listing");
     }
     public void assertFileNotInListing(FTPFile[] listing, String name) {
-        for (int i = 0; i < listing.length; i++) {
-            if (name.equals(listing[i].getName())) {
+        for (FTPFile element : listing)
+        {
+            if (name.equals(element.getName())) {
                 fail("Unexpected File " + name + " found in supplied listing");
             }
         }

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/tftp/TFTPTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/tftp/TFTPTest.java?rev=1407341&r1=1407340&r2=1407341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/tftp/TFTPTest.java (original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/tftp/TFTPTest.java Fri Nov
 9 01:31:00 2012
@@ -81,9 +81,9 @@ public class TFTPTest extends TestCase
             {
                 tftpS.shutdown();
             }
-            for (int i = 0; i < files.length; i++)
+            for (File file : files)
             {
-                files[i].delete();
+                file.delete();
             }
         }
         super.tearDown();



Mime
View raw message