commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matys...@arcor.de
Subject Aw: FW: [NET] [PATCH] DefaultFTPFileListParser: ftp servers returning german date format
Date Mon, 08 Dec 2003 07:44:04 GMT

Oops, looks like ezmlm/qmail has stripped the file off.
Here's the patch-file as inline-text:

------------- cut ------------------
--- DefaultFTPFileListParser.java	Mon Dec 08 08:23:36 2003
+++ DefaultFTPFileListParser.java_joerg	Mon Dec 08 08:21:47 2003
@@ -137,6 +137,31 @@
         return start;
     }
 
+      protected int __parseMonth(char[] cToken, int start)
+      {
+         String aasMonths[][] = {
+            // english month names
+            { "jan", "feb", "mar", "apr", "may", "jun", 
+              "jul", "aug", "sep", "oct","nov", "dec" },
+            // german month names
+            {"jan", "feb", "mär", "apr", "mai", "jun", 
+             "jul", "aug", "sep", "okt","nov", "dez" }};
+         
+         for (int iLangIdx = 0; iLangIdx < aasMonths.length; iLangIdx++)
+         {
+            for (int iMonthIdx = 0; iMonthIdx < aasMonths[iLangIdx].length; iMonthIdx++)
+            {
+               if ((aasMonths[iLangIdx][iMonthIdx].charAt(0) == cToken[start]) &&
+                   (aasMonths[iLangIdx][iMonthIdx].charAt(1) == cToken[start+1]) &&
+                   (aasMonths[iLangIdx][iMonthIdx].charAt(2) == cToken[start+2]))
+               {
+                  return(iMonthIdx+1);
+               }
+            }
+         }
+         return(0);
+      }
+
 
     /***
      * Parses an FTP server listing entry (a single line) and returns an
@@ -223,55 +248,33 @@
             }
 
             start = __skipWhitespace(cToken, end);
-            end = __skipNonWhitespaceToLower(cToken, start);
 
-            // Get month
-            switch (cToken[start])
+            if (Character.isDigit(cToken[start]))
             {
-            case 'a':
-                if (cToken[end - 1] == 'r')
-                    month = 3;
-                else
-                    month = 7;
-                break;
-            case 'd':
-                month = 11;
-                break;
-            case 'f':
-                month = 1;
-                break;
-            case 'j':
-                if (cToken[end - 1] == 'l')
-                    month = 6;
-                else if (cToken[start + 1] == 'a')
-                    month = 0;
-                else
-                    month = 5;
-                break;
-            case 'm':
-                if (cToken[end - 1] == 'y')
-                    month = 4;
-                else
-                    month = 2;
-                break;
-            case 'n':
-                month = 10;
-                break;
-            case 'o':
-                month = 9;
-                break;
-            case 's':
-                month = 8;
-                break;
-            default:
-                month = 0;
-                break;
+               /* this is a digit => must be "day moth" order  */
+               
+               // Get day, and store in access
+               end = __skipDigits(cToken, start);
+               access = __charArrayToInt(cToken, start, end);
+
+               // get the month
+               start = __skipWhitespace(cToken, end);
+               end = __skipNonWhitespaceToLower(cToken, start);
+               month =  __parseMonth(cToken, start);
+            }
+            else
+            {
+               /* must be "moth day" order  */
+               
+               // get the month
+               end = __skipNonWhitespaceToLower(cToken, start);
+               month =  __parseMonth(cToken, start);
+
+               // Get day, and store in access
+               start = __skipWhitespace(cToken, end);
+               end = __skipDigits(cToken, start);
+               access = __charArrayToInt(cToken, start, end);
             }
-
-            // Get day, and store in access
-            start = __skipWhitespace(cToken, end);
-            end = __skipDigits(cToken, start);
-            access = __charArrayToInt(cToken, start, end);
 
             start = __skipWhitespace(cToken, end);
             end = __skipDigits(cToken, start);
------------- cut ------------------

Joerg



> 
> 
> -----Original Message-----
> From: Daniel F. Savarese [mailto:dfs@savarese.org]
> Sent: Freitag, 5. Dezember 2003 21:59
> To: commons-dev@jakarta.apache.org
> Cc: J.Matysiak@CENIT.DE
> Subject: Re: [NET] [PATCH] DefaultFTPFileListParser: ftp servers
> returning ger man date format
> 
> 
> 
> In message <09A34CA28770D51191D800D0B7B6D0EF014AA007@ntss30.stgt.cenit.de>,
> J.M
> atysiak@CENIT.DE writes:
> >this is a patch for the DefaultFTPFileListParser.java file which =
> >enables=20
> 
> The patch isn't in the email you sent.  If you forgot to attach it,
> could you resend it to the mailing list?  If you did attach it and
> it was stripped by ezmlm/qmail for some reason, could you resend
> it but include the text inline (and be sure to turn line wrapping off)?
> 
> thanks,
> daniel
> 
> 





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


Mime
View raw message