commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1083469 - /commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java
Date Sun, 20 Mar 2011 15:32:27 GMT
Author: sebb
Date: Sun Mar 20 15:32:26 2011
New Revision: 1083469

URL: http://svn.apache.org/viewvc?rev=1083469&view=rev
Log:
Refactor - process Unix parms in separate method

Modified:
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java?rev=1083469&r1=1083468&r2=1083469&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/parser/MLSxEntryParser.java
Sun Mar 20 15:32:26 2011
@@ -171,51 +171,55 @@ public class MLSxEntryParser extends FTP
                 } // mode
             } // unix.
             else if (!hasUnixMode && "perm".equals(factname)) { // skip if we have
the UNIX.mode
-                //              perm-fact    = "Perm" "=" *pvals
-                //              pvals        = "a" / "c" / "d" / "e" / "f" /
-                //                             "l" / "m" / "p" / "r" / "w"
-                for(char c : valueLowerCase.toCharArray()) {
-                    // TODO these are mostly just guesses at present
-                    switch (c) {
-                        case 'a':     // (file) may APPEnd
-                            file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION,
true);
-                            break;
-                        case 'c':     // (dir) files may be created in the dir
-                            file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION,
true);
-                            break;
-                        case 'd':     // deletable
-                            file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION,
true);
-                            break;
-                        case 'e':     // (dir) can change to this dir
-                            file.setPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION,
true);
-                            break;
-                        case 'f':     // (file) renamable
-                            // ?? file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION,
true);
-                            break;
-                        case 'l':     // (dir) can be listed
-                            file.setPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION,
true);
-                            break;
-                        case 'm':     // (dir) can create directory here
-                            file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION,
true);
-                            break;
-                        case 'p':     // (dir) entries may be deleted
-                            file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION,
true);
-                            break;
-                        case 'r':     // (files) file may be RETRieved
-                            file.setPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION,
true);
-                            break;
-                        case 'w':     // (files) file may be STORed
-                            file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION,
true);
-                            break;
-                        default:
-                            return null; // TODO?
-                    }
-                }
-            }
-        }
+                doUnixPerms(file, valueLowerCase);
+            } // process "perm"
+        } // each fact
         return file;
     }
 
+    //              perm-fact    = "Perm" "=" *pvals
+    //              pvals        = "a" / "c" / "d" / "e" / "f" /
+    //                             "l" / "m" / "p" / "r" / "w"
+    private void doUnixPerms(FTPFile file, String valueLowerCase) {
+        for(char c : valueLowerCase.toCharArray()) {
+            // TODO these are mostly just guesses at present
+            switch (c) {
+                case 'a':     // (file) may APPEnd
+                    file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION, true);
+                    break;
+                case 'c':     // (dir) files may be created in the dir
+                    file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION, true);
+                    break;
+                case 'd':     // deletable
+                    file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION, true);
+                    break;
+                case 'e':     // (dir) can change to this dir
+                    file.setPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION, true);
+                    break;
+                case 'f':     // (file) renamable
+                    // ?? file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION,
true);
+                    break;
+                case 'l':     // (dir) can be listed
+                    file.setPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION, true);
+                    break;
+                case 'm':     // (dir) can create directory here
+                    file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION, true);
+                    break;
+                case 'p':     // (dir) entries may be deleted
+                    file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION, true);
+                    break;
+                case 'r':     // (files) file may be RETRieved
+                    file.setPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION, true);
+                    break;
+                case 'w':     // (files) file may be STORed
+                    file.setPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION, true);
+                    break;
+                default:
+                    // ignore unexpected flag for now.
+            } // switch
+        } // each char
+    }
+
     public static FTPFile parseEntry(String entry) {
         return PARSER.parseFTPEntry(entry);
     }



Mime
View raw message