commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r903861 - /commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/tftp/TFTPRequestPacket.java
Date Wed, 27 Jan 2010 22:06:36 GMT
Author: sebb
Date: Wed Jan 27 22:06:36 2010
New Revision: 903861

URL: http://svn.apache.org/viewvc?rev=903861&view=rev
Log:
make private & final where possible

Modified:
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/tftp/TFTPRequestPacket.java

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/tftp/TFTPRequestPacket.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/tftp/TFTPRequestPacket.java?rev=903861&r1=903860&r2=903861&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/tftp/TFTPRequestPacket.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/tftp/TFTPRequestPacket.java
Wed Jan 27 22:06:36 2010
@@ -61,17 +61,17 @@
      * transfer mode constants.  This is convenient for creating the TFTP
      * request packets.
      ***/
-    static final byte[] _modeBytes[] = {
+    private static final byte[] _modeBytes[] = {
                                            { (byte)'n', (byte)'e', (byte)'t', (byte)'a',
(byte)'s', (byte)'c',
                                              (byte)'i', (byte)'i', 0 },
                                            { (byte)'o', (byte)'c', (byte)'t', (byte)'e',
(byte)'t', 0 }
                                        };
 
     /*** The transfer mode of the request. ***/
-    int _mode;
+    private int _mode;
 
     /*** The filename of the request. ***/
-    String _filename;
+    private final String _filename;
 
     /***
      * Creates a request packet of a given type to be sent to a host at a
@@ -110,20 +110,15 @@
     {
         super(type, datagram.getAddress(), datagram.getPort());
 
-        byte[] data;
-        int index, length;
-        String mode;
-        StringBuffer buffer;
-
-        data = datagram.getData();
+        byte[] data = datagram.getData();
 
         if (getType() != data[1])
             throw new TFTPPacketException("TFTP operator code does not match type.");
 
-        buffer = new StringBuffer();
+        StringBuilder buffer = new StringBuilder();
 
-        index = 2;
-        length = datagram.getLength();
+        int index = 2;
+        int length = datagram.getLength();
 
         while (index < length && data[index] != 0)
         {
@@ -144,21 +139,24 @@
             ++index;
         }
 
-        mode = buffer.toString().toLowerCase(java.util.Locale.ENGLISH);
+        String modeString = buffer.toString().toLowerCase(java.util.Locale.ENGLISH);
         length = _modeStrings.length;
 
+        int mode = 0;
         for (index = 0; index < length; index++)
         {
-            if (mode.equals(_modeStrings[index]))
+            if (modeString.equals(_modeStrings[index]))
             {
-                _mode = index;
+                mode = index;
                 break;
             }
         }
 
+        _mode = mode;
+
         if (index >= length)
         {
-            throw new TFTPPacketException("Unrecognized TFTP transfer mode: " + mode);
+            throw new TFTPPacketException("Unrecognized TFTP transfer mode: " + modeString);
             // May just want to default to binary mode instead of throwing
             // exception.
             //_mode = TFTP.OCTET_MODE;



Mime
View raw message