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