View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.net.ftp;
19  
20  import java.text.DateFormatSymbols;
21  import java.util.Collection;
22  import java.util.Locale;
23  import java.util.Map;
24  import java.util.StringTokenizer;
25  import java.util.TreeMap;
26  
27  /**
28   * <p>
29   * This class implements an alternate means of configuring the
30   * {@link  org.apache.commons.net.ftp.FTPClient  FTPClient} object and
31   * also subordinate objects which it uses.  Any class implementing the
32   * {@link  org.apache.commons.net.ftp.Configurable  Configurable }
33   * interface can be configured by this object.
34   * </p><p>
35   * In particular this class was designed primarily to support configuration
36   * of FTP servers which express file timestamps in formats and languages
37   * other than those for the US locale, which although it is the most common
38   * is not universal.  Unfortunately, nothing in the FTP spec allows this to
39   * be determined in an automated way, so manual configuration such as this
40   * is necessary.
41   * </p><p>
42   * This functionality was designed to allow existing clients to work exactly
43   * as before without requiring use of this component.  This component should
44   * only need to be explicitly invoked by the user of this package for problem
45   * cases that previous implementations could not solve.
46   * </p>
47   * <h3>Examples of use of FTPClientConfig</h3>
48   * Use cases:
49   * You are trying to access a server that
50   * <ul>
51   * <li>lists files with timestamps that use month names in languages other
52   * than English</li>
53   * <li>lists files with timestamps that use date formats other
54   * than the American English "standard" <code>MM dd yyyy</code></li>
55   * <li>is in different timezone and you need accurate timestamps for
56   * dependency checking as in Ant</li>
57   * </ul>
58   * <p>
59   * Unpaged (whole list) access on a UNIX server that uses French month names
60   * but uses the "standard" <code>MMM d yyyy</code> date formatting
61   * <pre>
62   *    FTPClient f=FTPClient();
63   *    FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
64   *    conf.setServerLanguageCode("fr");
65   *    f.configure(conf);
66   *    f.connect(server);
67   *    f.login(username, password);
68   *    FTPFile[] files = listFiles(directory);
69   * </pre>
70   * <p>
71   * Paged access on a UNIX server that uses Danish month names
72   * and "European" date formatting in Denmark's time zone, when you
73   * are in some other time zone.
74   * <pre>
75   *    FTPClient f=FTPClient();
76   *    FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
77   *    conf.setServerLanguageCode("da");
78   *    conf.setDefaultDateFormat("d MMM yyyy");
79   *    conf.setRecentDateFormat("d MMM HH:mm");
80   *    conf.setTimeZoneId("Europe/Copenhagen");
81   *    f.configure(conf);
82   *    f.connect(server);
83   *    f.login(username, password);
84   *    FTPListParseEngine engine =
85   *       f.initiateListParsing("com.whatever.YourOwnParser", directory);
86   *
87   *    while (engine.hasNext()) {
88   *       FTPFile[] files = engine.getNext(25);  // "page size" you want
89   *       //do whatever you want with these files, display them, etc.
90   *       //expensive FTPFile objects not created until needed.
91   *    }
92   * </pre>
93   * <p>
94   * Unpaged (whole list) access on a VMS server that uses month names
95   * in a language not {@link #getSupportedLanguageCodes() supported} by the system.
96   * but uses the "standard" <code>MMM d yyyy</code> date formatting
97   * <pre>
98   *    FTPClient f=FTPClient();
99   *    FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_VMS);
100  *    conf.setShortMonthNames(
101  *        "jan|feb|mar|apr|ma\u00ED|j\u00FAn|j\u00FAl|\u00e1g\u00FA|sep|okt|n\u00F3v|des");
102  *    f.configure(conf);
103  *    f.connect(server);
104  *    f.login(username, password);
105  *    FTPFile[] files = listFiles(directory);
106  * </pre>
107  * <p>
108  * Unpaged (whole list) access on a Windows-NT server in a different time zone.
109  * (Note, since the NT Format uses numeric date formatting, language issues
110  * are irrelevant here).
111  * <pre>
112  *    FTPClient f=FTPClient();
113  *    FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_NT);
114  *    conf.setTimeZoneId("America/Denver");
115  *    f.configure(conf);
116  *    f.connect(server);
117  *    f.login(username, password);
118  *    FTPFile[] files = listFiles(directory);
119  * </pre>
120  * Unpaged (whole list) access on a Windows-NT server in a different time zone
121  * but which has been configured to use a unix-style listing format.
122  * <pre>
123  *    FTPClient f=FTPClient();
124  *    FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
125  *    conf.setTimeZoneId("America/Denver");
126  *    f.configure(conf);
127  *    f.connect(server);
128  *    f.login(username, password);
129  *    FTPFile[] files = listFiles(directory);
130  * </pre>
131  *
132  * @since 1.4
133  * @see org.apache.commons.net.ftp.Configurable
134  * @see org.apache.commons.net.ftp.FTPClient
135  * @see org.apache.commons.net.ftp.parser.FTPTimestampParserImpl#configure(FTPClientConfig)
136  * @see org.apache.commons.net.ftp.parser.ConfigurableFTPFileEntryParserImpl
137  */
138 public class FTPClientConfig
139 {
140 
141     /**
142      * Identifier by which a unix-based ftp server is known throughout
143      * the commons-net ftp system.
144      */
145     public static final String SYST_UNIX  = "UNIX";
146 
147     /**
148      * Identifier for alternate UNIX parser; same as {@link #SYST_UNIX} but leading spaces are
149      * trimmed from file names. This is to maintain backwards compatibility with
150      * the original behaviour of the parser which ignored multiple spaces between the date
151      * and the start of the file name.
152      * @since 3.4
153      */
154     public static final String SYST_UNIX_TRIM_LEADING  = "UNIX_LTRIM";
155 
156     /**
157      * Identifier by which a vms-based ftp server is known throughout
158      * the commons-net ftp system.
159      */
160     public static final String SYST_VMS   = "VMS";
161 
162     /**
163      * Identifier by which a WindowsNT-based ftp server is known throughout
164      * the commons-net ftp system.
165      */
166     public static final String SYST_NT    = "WINDOWS";
167 
168     /**
169      * Identifier by which an OS/2-based ftp server is known throughout
170      * the commons-net ftp system.
171      */
172     public static final String SYST_OS2   = "OS/2";
173 
174     /**
175      * Identifier by which an OS/400-based ftp server is known throughout
176      * the commons-net ftp system.
177      */
178     public static final String SYST_OS400 = "OS/400";
179 
180     /**
181      * Identifier by which an AS/400-based ftp server is known throughout
182      * the commons-net ftp system.
183      */
184     public static final String SYST_AS400 = "AS/400";
185 
186     /**
187      * Identifier by which an MVS-based ftp server is known throughout
188      * the commons-net ftp system.
189      */
190     public static final String SYST_MVS = "MVS";
191 
192     /**
193      * Some servers return an "UNKNOWN Type: L8" message
194      * in response to the SYST command. We set these to be a Unix-type system.
195      * This may happen if the ftpd in question was compiled without system
196      * information.
197      *
198      * NET-230 - Updated to be UPPERCASE so that the check done in
199      * createFileEntryParser will succeed.
200      *
201      * @since 1.5
202      */
203     public static final String SYST_L8 = "TYPE: L8";
204 
205     /**
206      * Identifier by which an Netware-based ftp server is known throughout
207      * the commons-net ftp system.
208      *
209      * @since 1.5
210      */
211     public static final String SYST_NETWARE = "NETWARE";
212 
213     /**
214      * Identifier by which a Mac pre OS-X -based ftp server is known throughout
215      * the commons-net ftp system.
216      *
217      * @since 3.1
218      */
219     // Full string is "MACOS Peter's Server"; the substring below should be enough
220     public static final String SYST_MACOS_PETER  = "MACOS PETER"; // NET-436
221 
222     private final String serverSystemKey;
223     private String defaultDateFormatStr = null;
224     private String recentDateFormatStr = null;
225     private boolean lenientFutureDates = true; // NET-407
226     private String serverLanguageCode = null;
227     private String shortMonthNames = null;
228     private String serverTimeZoneId = null;
229     private boolean saveUnparseableEntries = false;
230 
231 
232     /**
233      * The main constructor for an FTPClientConfig object
234      * @param systemKey key representing system type of the  server being
235      * connected to. See {@link #getServerSystemKey() serverSystemKey}
236      * If set to the empty string, then FTPClient uses the system type returned by the server.
237      * However this is not recommended for general use;
238      * the correct system type should be set if it is known.
239      */
240     public FTPClientConfig(String systemKey) {
241         this.serverSystemKey = systemKey;
242     }
243 
244     /**
245      * Convenience constructor mainly for use in testing.
246      * Constructs a UNIX configuration.
247      */
248     public FTPClientConfig() {
249         this(SYST_UNIX);
250     }
251 
252     /**
253      * Constructor which allows setting of most member fields
254      * @param systemKey key representing system type of the  server being
255      * connected to. See
256      *  {@link #getServerSystemKey() serverSystemKey}
257      * @param defaultDateFormatStr See
258      *  {@link  #setDefaultDateFormatStr(String)  defaultDateFormatStr}
259      * @param recentDateFormatStr See
260      *  {@link  #setRecentDateFormatStr(String)  recentDateFormatStr}
261      * @param serverLanguageCode See
262      *  {@link  #setServerLanguageCode(String)  serverLanguageCode}
263      * @param shortMonthNames See
264      *  {@link  #setShortMonthNames(String)  shortMonthNames}
265      * @param serverTimeZoneId See
266      *  {@link  #setServerTimeZoneId(String)  serverTimeZoneId}
267      */
268     public FTPClientConfig(String systemKey,
269                            String defaultDateFormatStr,
270                            String recentDateFormatStr,
271                            String serverLanguageCode,
272                            String shortMonthNames,
273                            String serverTimeZoneId)
274     {
275         this(systemKey);
276         this.defaultDateFormatStr = defaultDateFormatStr;
277         this.recentDateFormatStr = recentDateFormatStr;
278         this.serverLanguageCode = serverLanguageCode;
279         this.shortMonthNames = shortMonthNames;
280         this.serverTimeZoneId = serverTimeZoneId;
281     }
282 
283     /**
284      * Constructor which allows setting of all member fields
285      * @param systemKey key representing system type of the  server being
286      * connected to. See
287      *  {@link #getServerSystemKey() serverSystemKey}
288      * @param defaultDateFormatStr See
289      *  {@link  #setDefaultDateFormatStr(String)  defaultDateFormatStr}
290      * @param recentDateFormatStr See
291      *  {@link  #setRecentDateFormatStr(String)  recentDateFormatStr}
292      * @param serverLanguageCode See
293      *  {@link  #setServerLanguageCode(String)  serverLanguageCode}
294      * @param shortMonthNames See
295      *  {@link  #setShortMonthNames(String)  shortMonthNames}
296      * @param serverTimeZoneId See
297      *  {@link  #setServerTimeZoneId(String)  serverTimeZoneId}
298      * @param lenientFutureDates See
299      * {@link  #setLenientFutureDates(boolean)  lenientFutureDates}
300      * @param saveUnparseableEntries See
301      * {@link  #setUnparseableEntries(boolean)  saveUnparseableEntries}
302      */
303     public FTPClientConfig(String systemKey,
304                            String defaultDateFormatStr,
305                            String recentDateFormatStr,
306                            String serverLanguageCode,
307                            String shortMonthNames,
308                            String serverTimeZoneId,
309                            boolean lenientFutureDates,
310                            boolean saveUnparseableEntries)
311     {
312         this(systemKey);
313         this.defaultDateFormatStr = defaultDateFormatStr;
314         this.lenientFutureDates = lenientFutureDates;
315         this.recentDateFormatStr = recentDateFormatStr;
316         this.saveUnparseableEntries = saveUnparseableEntries;
317         this.serverLanguageCode = serverLanguageCode;
318         this.shortMonthNames = shortMonthNames;
319         this.serverTimeZoneId = serverTimeZoneId;
320     }
321 
322     // Copy constructor, intended for use by FTPClient only
323     FTPClientConfig(String systemKey, FTPClientConfig config) {
324         this.serverSystemKey = systemKey;
325         this.defaultDateFormatStr = config.defaultDateFormatStr;
326         this.lenientFutureDates = config.lenientFutureDates;
327         this.recentDateFormatStr = config.recentDateFormatStr;
328         this.saveUnparseableEntries = config.saveUnparseableEntries;
329         this.serverLanguageCode = config.serverLanguageCode;
330         this.serverTimeZoneId = config.serverTimeZoneId;
331         this.shortMonthNames = config.shortMonthNames;
332     }
333 
334     private static final Map<String, Object> LANGUAGE_CODE_MAP = new TreeMap<String, Object>();
335     static {
336 
337         // if there are other commonly used month name encodings which
338         // correspond to particular locales, please add them here.
339 
340 
341 
342         // many locales code short names for months as all three letters
343         // these we handle simply.
344         LANGUAGE_CODE_MAP.put("en", Locale.ENGLISH);
345         LANGUAGE_CODE_MAP.put("de",Locale.GERMAN);
346         LANGUAGE_CODE_MAP.put("it",Locale.ITALIAN);
347         LANGUAGE_CODE_MAP.put("es", new Locale("es", "", "")); // spanish
348         LANGUAGE_CODE_MAP.put("pt", new Locale("pt", "", "")); // portuguese
349         LANGUAGE_CODE_MAP.put("da", new Locale("da", "", "")); // danish
350         LANGUAGE_CODE_MAP.put("sv", new Locale("sv", "", "")); // swedish
351         LANGUAGE_CODE_MAP.put("no", new Locale("no", "", "")); // norwegian
352         LANGUAGE_CODE_MAP.put("nl", new Locale("nl", "", "")); // dutch
353         LANGUAGE_CODE_MAP.put("ro", new Locale("ro", "", "")); // romanian
354         LANGUAGE_CODE_MAP.put("sq", new Locale("sq", "", "")); // albanian
355         LANGUAGE_CODE_MAP.put("sh", new Locale("sh", "", "")); // serbo-croatian
356         LANGUAGE_CODE_MAP.put("sk", new Locale("sk", "", "")); // slovak
357         LANGUAGE_CODE_MAP.put("sl", new Locale("sl", "", "")); // slovenian
358 
359 
360         // some don't
361         LANGUAGE_CODE_MAP.put("fr",
362                 "jan|f\u00e9v|mar|avr|mai|jun|jui|ao\u00fb|sep|oct|nov|d\u00e9c");  //french
363 
364     }
365 
366     /**
367      * Getter for the serverSystemKey property.  This property
368      * specifies the general type of server to which the client connects.
369      * Should be either one of the <code>FTPClientConfig.SYST_*</code> codes
370      * or else the fully qualified class name of a parser implementing both
371      * the <code>FTPFileEntryParser</code> and <code>Configurable</code>
372      * interfaces.
373      * @return Returns the serverSystemKey property.
374      */
375     public String getServerSystemKey() {
376         return serverSystemKey;
377     }
378 
379     /**
380      * getter for the {@link  #setDefaultDateFormatStr(String)  defaultDateFormatStr}
381      * property.
382      * @return Returns the defaultDateFormatStr property.
383      */
384     public String getDefaultDateFormatStr() {
385         return defaultDateFormatStr;
386     }
387 
388     /**
389      * getter for the {@link  #setRecentDateFormatStr(String)  recentDateFormatStr} property.
390      * @return Returns the recentDateFormatStr property.
391      */
392 
393     public String getRecentDateFormatStr() {
394         return recentDateFormatStr;
395     }
396 
397     /**
398      * getter for the {@link  #setServerTimeZoneId(String)  serverTimeZoneId} property.
399      * @return Returns the serverTimeZoneId property.
400      */
401     public String getServerTimeZoneId() {
402         return serverTimeZoneId;
403     }
404 
405     /**
406      * <p>
407      * getter for the {@link  #setShortMonthNames(String)  shortMonthNames}
408      * property.
409      * </p>
410      * @return Returns the shortMonthNames.
411      */
412     public String getShortMonthNames() {
413         return shortMonthNames;
414     }
415 
416     /**
417      * <p>
418      * getter for the {@link  #setServerLanguageCode(String)  serverLanguageCode} property.
419      * </p>
420      * @return Returns the serverLanguageCode property.
421      */
422     public String getServerLanguageCode() {
423         return serverLanguageCode;
424     }
425 
426     /**
427      * <p>
428      * getter for the {@link  #setLenientFutureDates(boolean)  lenientFutureDates} property.
429      * </p>
430      * @return Returns the lenientFutureDates.
431      * @since 1.5
432      */
433     public boolean isLenientFutureDates() {
434         return lenientFutureDates;
435     }
436     /**
437      * <p>
438      * setter for the defaultDateFormatStr property.  This property
439      * specifies the main date format that will be used by a parser configured
440      * by this configuration to parse file timestamps.  If this is not
441      * specified, such a parser will use as a default value, the most commonly
442      * used format which will be in as used in <code>en_US</code> locales.
443      * </p><p>
444      * This should be in the format described for
445      * <code>java.text.SimpleDateFormat</code>.
446      * property.
447      * </p>
448      * @param defaultDateFormatStr The defaultDateFormatStr to set.
449      */
450     public void setDefaultDateFormatStr(String defaultDateFormatStr) {
451         this.defaultDateFormatStr = defaultDateFormatStr;
452     }
453 
454     /**
455      * <p>
456      * setter for the recentDateFormatStr property.  This property
457      * specifies a secondary date format that will be used by a parser
458      * configured by this configuration to parse file timestamps, typically
459      * those less than a year old.  If this is  not specified, such a parser
460      * will not attempt to parse using an alternate format.
461      * </p>
462      * <p>
463      * This is used primarily in unix-based systems.
464      * </p>
465      * <p>
466      * This should be in the format described for
467      * <code>java.text.SimpleDateFormat</code>.
468      * </p>
469      * @param recentDateFormatStr The recentDateFormatStr to set.
470      */
471     public void setRecentDateFormatStr(String recentDateFormatStr) {
472         this.recentDateFormatStr = recentDateFormatStr;
473     }
474 
475     /**
476      * <p>
477      * setter for the lenientFutureDates property.  This boolean property
478      * (default: false) only has meaning when a
479      * {@link  #setRecentDateFormatStr(String)  recentDateFormatStr} property
480      * has been set.  In that case, if this property is set true, then the
481      * parser, when it encounters a listing parseable with the recent date
482      * format, will only consider a date to belong to the previous year if
483      * it is more than one day in the future.  This will allow all
484      * out-of-synch situations (whether based on "slop" - i.e. servers simply
485      * out of synch with one another or because of time zone differences -
486      * but in the latter case it is highly recommended to use the
487      * {@link  #setServerTimeZoneId(String)  serverTimeZoneId} property
488      * instead) to resolve correctly.
489      * </p><p>
490      * This is used primarily in unix-based systems.
491      * </p>
492      * @param lenientFutureDates set true to compensate for out-of-synch
493      * conditions.
494      */
495     public void setLenientFutureDates(boolean lenientFutureDates) {
496         this.lenientFutureDates = lenientFutureDates;
497     }
498     /**
499      * <p>
500      * setter for the serverTimeZoneId property.  This property
501      * allows a time zone to be specified corresponding to that known to be
502      * used by an FTP server in file listings.  This might be particularly
503      * useful to clients such as Ant that try to use these timestamps for
504      * dependency checking.
505      * </p><p>
506      * This should be one of the identifiers used by
507      * <code>java.util.TimeZone</code> to refer to time zones, for example,
508      * <code>America/Chicago</code> or <code>Asia/Rangoon</code>.
509      * </p>
510      * @param serverTimeZoneId The serverTimeZoneId to set.
511      */
512     public void setServerTimeZoneId(String serverTimeZoneId) {
513         this.serverTimeZoneId = serverTimeZoneId;
514     }
515 
516     /**
517      * <p>
518      * setter for the shortMonthNames property.
519      * This property allows the user to specify a set of month names
520      * used by the server that is different from those that may be
521      * specified using the {@link  #setServerLanguageCode(String)  serverLanguageCode}
522      * property.
523      * </p><p>
524      * This should be a string containing twelve strings each composed of
525      * three characters, delimited by pipe (|) characters.  Currently,
526      * only 8-bit ASCII characters are known to be supported.  For example,
527      * a set of month names used by a hypothetical Icelandic FTP server might
528      * conceivably be specified as
529      * <code>"jan|feb|mar|apr|ma&#xED;|j&#xFA;n|j&#xFA;l|&#xE1;g&#xFA;|sep|okt|n&#xF3;v|des"</code>.
530      * </p>
531      * @param shortMonthNames The value to set to the shortMonthNames property.
532      */
533     public void setShortMonthNames(String shortMonthNames) {
534         this.shortMonthNames = shortMonthNames;
535     }
536 
537     /**
538      * <p>
539      * setter for the serverLanguageCode property.  This property allows
540      * user to specify a
541      * <a href="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt">
542      * two-letter ISO-639 language code</a> that will be used to
543      * configure the set of month names used by the file timestamp parser.
544      * If neither this nor the {@link #setShortMonthNames(String) shortMonthNames}
545      * is specified, parsing will assume English month names, which may or
546      * may not be significant, depending on whether the date format(s)
547      * specified via {@link  #setDefaultDateFormatStr(String)  defaultDateFormatStr}
548      * and/or {@link  #setRecentDateFormatStr(String)  recentDateFormatStr} are using
549      * numeric or alphabetic month names.
550      * </p>
551      * <p>If the code supplied is not supported here, <code>en_US</code>
552      * month names will be used.  We are supporting here those language
553      * codes which, when a <code> java.util.Locale</code> is constucted
554      * using it, and a <code>java.text.SimpleDateFormat</code> is
555      * constructed using that Locale, the array returned by the
556      * SimpleDateFormat's <code>getShortMonths()</code> method consists
557      * solely of three 8-bit ASCII character strings.  Additionally,
558      * languages which do not meet this requirement are included if a
559      * common alternative set of short month names is known to be used.
560      * This means that users who can tell us of additional such encodings
561      * may get them added to the list of supported languages by contacting
562      * the Apache Commons Net team.
563      * </p>
564      * <p><strong>
565      * Please note that this attribute will NOT be used to determine a
566      * locale-based date format for the language.  </strong>
567      * Experience has shown that many if not most FTP servers outside the
568      * United States employ the standard <code>en_US</code> date format
569      * orderings of <code>MMM d yyyy</code> and <code>MMM d HH:mm</code>
570      * and attempting to deduce this automatically here would cause more
571      * problems than it would solve.  The date format must be changed
572      * via the {@link  #setDefaultDateFormatStr(String)  defaultDateFormatStr} and/or
573      * {@link  #setRecentDateFormatStr(String)  recentDateFormatStr} parameters.
574      * </p>
575      * @param serverLanguageCode The value to set to the serverLanguageCode property.
576      */
577     public void setServerLanguageCode(String serverLanguageCode) {
578         this.serverLanguageCode = serverLanguageCode;
579     }
580 
581     /**
582      * Looks up the supplied language code in the internally maintained table of
583      * language codes.  Returns a DateFormatSymbols object configured with
584      * short month names corresponding to the code.  If there is no corresponding
585      * entry in the table, the object returned will be that for
586      * <code>Locale.US</code>
587      * @param languageCode See {@link  #setServerLanguageCode(String)  serverLanguageCode}
588      * @return a DateFormatSymbols object configured with short month names
589      * corresponding to the supplied code, or with month names for
590      * <code>Locale.US</code> if there is no corresponding entry in the internal
591      * table.
592      */
593     public static DateFormatSymbols lookupDateFormatSymbols(String languageCode)
594     {
595         Object lang = LANGUAGE_CODE_MAP.get(languageCode);
596         if (lang != null) {
597             if (lang instanceof Locale) {
598                 return new DateFormatSymbols((Locale) lang);
599             } else if (lang instanceof String){
600                 return getDateFormatSymbols((String) lang);
601             }
602         }
603         return new DateFormatSymbols(Locale.US);
604     }
605 
606     /**
607      * Returns a DateFormatSymbols object configured with short month names
608      * as in the supplied string
609      * @param shortmonths This  should be as described in
610      *  {@link  #setShortMonthNames(String)  shortMonthNames}
611      * @return a DateFormatSymbols object configured with short month names
612      * as in the supplied string
613      */
614     public static DateFormatSymbols getDateFormatSymbols(String shortmonths)
615     {
616         String[] months = splitShortMonthString(shortmonths);
617         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
618         dfs.setShortMonths(months);
619         return dfs;
620     }
621 
622     private static String[] splitShortMonthString(String shortmonths) {
623         StringTokenizer st = new StringTokenizer(shortmonths, "|");
624         int monthcnt = st.countTokens();
625         if (12 != monthcnt) {
626             throw new IllegalArgumentException(
627                     "expecting a pipe-delimited string containing 12 tokens");
628         }
629         String[] months = new String[13];
630         int pos = 0;
631         while(st.hasMoreTokens()) {
632             months[pos++] = st.nextToken();
633         }
634         months[pos]="";
635         return months;
636     }
637 
638     /**
639      * Returns a Collection of all the language codes currently supported
640      * by this class. See {@link  #setServerLanguageCode(String)  serverLanguageCode}
641      * for a functional descrption of language codes within this system.
642      *
643      * @return a Collection of all the language codes currently supported
644      * by this class
645      */
646     public static Collection<String> getSupportedLanguageCodes() {
647         return LANGUAGE_CODE_MAP.keySet();
648     }
649 
650     /**
651      * Allow list parsing methods to create basic FTPFile entries if parsing fails.
652      * <p>
653      * In this case, the FTPFile will contain only the unparsed entry {@link FTPFile#getRawListing()}
654      * and {@link FTPFile#isValid()} will return {@code false}
655      * @param saveUnparseable if true, then create FTPFile entries if parsing fails
656      * @since 3.4
657      */
658     public void setUnparseableEntries(boolean saveUnparseable) {
659         this.saveUnparseableEntries = saveUnparseable;
660     }
661 
662     /**
663      * @return true if list parsing should return FTPFile entries even for unparseable response lines
664      * <p>
665      * If true, the FTPFile for any unparseable entries will contain only the unparsed entry
666      * {@link FTPFile#getRawListing()} and {@link FTPFile#isValid()} will return {@code false}
667      * @since 3.4
668      */
669     public boolean getUnparseableEntries() {
670         return this.saveUnparseableEntries;
671     }
672 
673 }