commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1086604 - in /commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp: SMTP.java SMTPCommand.java
Date Tue, 29 Mar 2011 14:42:45 GMT
Author: sebb
Date: Tue Mar 29 14:42:45 2011
New Revision: 1086604

URL: http://svn.apache.org/viewvc?rev=1086604&view=rev
Log:
Use getCommand() rather than direct array access so array can be private

Modified:
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTP.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTPCommand.java

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTP.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTP.java?rev=1086604&r1=1086603&r2=1086604&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTP.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTP.java Tue Mar 29
14:42:45 2011
@@ -152,7 +152,7 @@ public class SMTP extends SocketClient
     private int __sendCommand(int command, String args, boolean includeSpace)
     throws IOException
     {
-        return __sendCommand(SMTPCommand._commands[command], args, includeSpace);
+        return __sendCommand(SMTPCommand.getCommand(command), args, includeSpace);
     }
 
     private void __getReply() throws IOException
@@ -304,7 +304,7 @@ public class SMTP extends SocketClient
      ***/
     public int sendCommand(int command, String args) throws IOException
     {
-        return sendCommand(SMTPCommand._commands[command], args);
+        return sendCommand(SMTPCommand.getCommand(command), args);
     }
 
 

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTPCommand.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTPCommand.java?rev=1086604&r1=1086603&r2=1086604&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTPCommand.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/SMTPCommand.java Tue
Mar 29 14:42:45 2011
@@ -48,6 +48,8 @@ public final class SMTPCommand
     public static final int TURN = 12;
     public static final int QUIT = 13;
 
+    private static final int _NEXT_ = QUIT + 1; // update as necessary when adding new entries
+
     public static final int HELLO = HELO;
     public static final int LOGIN = HELO;
     public static final int MAIL_FROM = MAIL;
@@ -69,12 +71,18 @@ public final class SMTPCommand
     private SMTPCommand()
     {}
 
-    static final String[] _commands = {
+    private static final String[] _commands = {
                                           "HELO", "MAIL FROM:", "RCPT TO:", "DATA", "SEND
FROM:", "SOML FROM:",
                                           "SAML FROM:", "RSET", "VRFY", "EXPN", "HELP", "NOOP",
"TURN", "QUIT"
                                       };
 
 
+    static {
+        if (_commands.length != _NEXT_) {
+            throw new RuntimeException("Error in array definition");
+        }        
+    }
+
     /***
      * Retrieve the SMTP protocol command string corresponding to a specified
      * command code.



Mime
View raw message