    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017
    018package org.apache.commons.net.ftp;
    019
    020import java.text.DateFormatSymbols;
    021import java.util.Collection;
    022import java.util.Locale;
    023import java.util.Map;
    024import java.util.StringTokenizer;
    025import java.util.TreeMap;
    026
    027/**
    028 * <p>
    029 * This class implements an alternate means of configuring the {@link org.apache.commons.net.ftp.FTPClient FTPClient} object and also subordinate objects which
    030 * it uses. Any class implementing the {@link org.apache.commons.net.ftp.Configurable Configurable } interface can be configured by this object.
    031 * </p>
    032 * <p>
    033 * In particular this class was designed primarily to support configuration of FTP servers which express file timestamps in formats and languages other than
    034 * 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
    035 * automated way, so manual configuration such as this is necessary.
    036 * </p>
    037 * <p>
    038 * This functionality was designed to allow existing clients to work exactly as before without requiring use of this component. This component should only need
    039 * to be explicitly invoked by the user of this package for problem cases that previous implementations could not solve.
    040 * </p>
    041 * <h2>Examples of use of FTPClientConfig</h2> Use cases: You are trying to access a server that
    042 * <ul>
    043 * <li>lists files with timestamps that use month names in languages other than English</li>
    044 * <li>lists files with timestamps that use date formats other than the American English "standard" <code>MM dd yyyy</code></li>
    045 * <li>is in different time zone and you need accurate timestamps for dependency checking as in Ant</li>
    046 * </ul>
    047 * <p>
    048 * Unpaged (whole list) access on a UNIX server that uses French month names but uses the "standard" <code>MMM d yyyy</code> date formatting
    049 *
    050 * <pre>
    051 * FTPClient f = FTPClient();
    052 * FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
    053 * conf.setServerLanguageCode("fr");
    054 * f.configure(conf);
    055 * f.connect(server);
    056 * f.login(user, password);
    057 * FTPFile[] files = listFiles(directory);
    058 * </pre>
    059 * <p>
    060 * 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.
    061 *
    062 * <pre>
    063 * FTPClient f = FTPClient();
    064 * FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
    065 * conf.setServerLanguageCode("da");
    066 * conf.setDefaultDateFormat("d MMM yyyy");
    067 * conf.setRecentDateFormat("d MMM HH:mm");
    068 * conf.setTimeZoneId("Europe/Copenhagen");
    069 * f.configure(conf);
    070 * f.connect(server);
    071 * f.login(user, password);
    072 * FTPListParseEngine engine = f.initiateListParsing("com.whatever.YourOwnParser", directory);
    073 *
    074 * while (engine.hasNext()) {
    075 *     FTPFile[] files = engine.getNext(25); // "page size" you want
    076 *     // do whatever you want with these files, display them, etc.
    077 *     // expensive FTPFile objects not created until needed.
    078 * }
    079 * </pre>
    080 * <p>
    081 * Unpaged (whole list) access on a VMS server that uses month names in a language not {@link #getSupportedLanguageCodes() supported} by the system. but uses
    082 * the "standard" <code>MMM d yyyy</code> date formatting
    083 *
    084 * <pre>
    085 * FTPClient f = FTPClient();
    086 * FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_VMS);
    087 * conf.setShortMonthNames("jan|feb|mar|apr|ma\u00ED|j\u00FAn|j\u00FAl|\u00e1g\u00FA|sep|okt|n\u00F3v|des");
    088 * f.configure(conf);
    089 * f.connect(server);
    090 * f.login(user, password);
    091 * FTPFile[] files = listFiles(directory);
    092 * </pre>
    093 * <p>
    094 * 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
    095 * irrelevant here).
    096 *
    097 * <pre>
    098 * FTPClient f = FTPClient();
    099 * 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 *
    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 *
    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 */
    125public 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     * Returns 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     * Returns 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</code>
    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</code>
    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     * getter for the {@link #setDefaultDateFormatStr(String) defaultDateFormatStr} property.
    404     *
    405     * @return Returns the defaultDateFormatStr property.
    406     */
    407    public String getDefaultDateFormatStr() {
    408        return defaultDateFormatStr;
    409    }
    410
    411    /**
    412     * getter for the {@link #setRecentDateFormatStr(String) recentDateFormatStr} property.
    413     *
    414     * @return Returns the recentDateFormatStr property.
    415     */
    416
    417    public String getRecentDateFormatStr() {
    418        return recentDateFormatStr;
    419    }
    420
    421    /**
    422     * <p>
    423     * getter for the {@link #setServerLanguageCode(String) serverLanguageCode} property.
    424     * </p>
    425     *
    426     * @return Returns the serverLanguageCode property.
    427     */
    428    public String getServerLanguageCode() {
    429        return serverLanguageCode;
    430    }
    431
    432    /**
    433     * Getter for the serverSystemKey property. This property specifies the general type of server to which the client connects. Should be either one of the
    434     * <code>FTPClientConfig.SYST_*</code> codes or else the fully qualified class name of a parser implementing both the <code>FTPFileEntryParser</code> and
    435     * <code>Configurable</code> interfaces.
    436     *
    437     * @return Returns the serverSystemKey property.
    438     */
    439    public String getServerSystemKey() {
    440        return serverSystemKey;
    441    }
    442
    443    /**
    444     * getter for the {@link #setServerTimeZoneId(String) serverTimeZoneId} property.
    445     *
    446     * @return Returns the serverTimeZoneId property.
    447     */
    448    public String getServerTimeZoneId() {
    449        return serverTimeZoneId;
    450    }
    451
    452    /**
    453     * <p>
    454     * getter for the {@link #setShortMonthNames(String) shortMonthNames} property.
    455     * </p>
    456     *
    457     * @return Returns the shortMonthNames.
    458     */
    459    public String getShortMonthNames() {
    460        return shortMonthNames;
    461    }
    462
    463    /**
    464     * @return true if list parsing should return FTPFile entries even for unparseable response lines
    465     *         <p>
    466     *         If true, the FTPFile for any unparseable entries will contain only the unparsed entry {@link FTPFile#getRawListing()} and
    467     *         {@link FTPFile#isValid()} will return {@code false}
    468     * @since 3.4
    469     */
    470    public boolean getUnparseableEntries() {
    471        return this.saveUnparseableEntries;
    472    }
    473
    474    /**
    475     * <p>
    476     * getter for the {@link #setLenientFutureDates(boolean) lenientFutureDates} property.
    477     * </p>
    478     *
    479     * @return Returns the lenientFutureDates (default true).
    480     * @since 1.5
    481     */
    482    public boolean isLenientFutureDates() {
    483        return lenientFutureDates;
    484    }
    485
    486    /**
    487     * <p>
    488     * setter for the defaultDateFormatStr property. This property specifies the main date format that will be used by a parser configured by this configuration
    489     * 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
    490     * <code>en_US</code> locales.
    491     * </p>
    492     * <p>
    493     * This should be in the format described for <code>java.text.SimpleDateFormat</code>. property.
    494     * </p>
    495     *
    496     * @param defaultDateFormatStr The defaultDateFormatStr to set.
    497     */
    498    public void setDefaultDateFormatStr(final String defaultDateFormatStr) {
    499        this.defaultDateFormatStr = defaultDateFormatStr;
    500    }
    501
    502    /**
    503     * <p>
    504     * setter for the lenientFutureDates property. This boolean property (default: true) only has meaning when a {@link #setRecentDateFormatStr(String)
    505     * 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
    506     * 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
    507     * 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
    508     * is highly recommended to use the {@link #setServerTimeZoneId(String) serverTimeZoneId} property instead) to resolve correctly.
    509     * </p>
    510     * <p>
    511     * This is used primarily in unix-based systems.
    512     * </p>
    513     *
    514     * @param lenientFutureDates set true to compensate for out-of-synch conditions.
    515     */
    516    public void setLenientFutureDates(final boolean lenientFutureDates) {
    517        this.lenientFutureDates = lenientFutureDates;
    518    }
    519
    520    /**
    521     * <p>
    522     * setter for the recentDateFormatStr property. This property specifies a secondary date format that will be used by a parser configured by this
    523     * 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
    524     * alternate format.
    525     * </p>
    526     * <p>
    527     * This is used primarily in unix-based systems.
    528     * </p>
    529     * <p>
    530     * This should be in the format described for <code>java.text.SimpleDateFormat</code>.
    531     * </p>
    532     *
    533     * @param recentDateFormatStr The recentDateFormatStr to set.
    534     */
    535    public void setRecentDateFormatStr(final String recentDateFormatStr) {
    536        this.recentDateFormatStr = recentDateFormatStr;
    537    }
    538
    539    /**
    540     * <p>
    541     * setter for the serverLanguageCode property. This property allows user to specify a <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 configure the set of month names used by the file timestamp parser. If neither this nor the
    543     * {@link #setShortMonthNames(String) shortMonthNames} is specified, parsing will assume English month names, which may or may not be significant, depending
    544     * on whether the date format(s) specified via {@link #setDefaultDateFormatStr(String) defaultDateFormatStr} and/or {@link #setRecentDateFormatStr(String)
    545     * recentDateFormatStr} are using numeric or alphabetic month names.
    546     * </p>
    547     * <p>
    548     * If the code supplied is not supported here, <code>en_US</code> month names will be used. We are supporting here those language codes which, when a
    549     * <code> java.util.Locale</code> is constructed using it, and a <code>java.text.SimpleDateFormat</code> is constructed using that Locale, the array
    550     * returned by the SimpleDateFormat's <code>getShortMonths()</code> method consists solely of three 8-bit ASCII character strings. Additionally, languages
    551     * 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
    552     * us of additional such encodings may get them added to the list of supported languages by contacting the Apache Commons Net team.
    553     * </p>
    554     * <p>
    555     * <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
    556     * many if not most FTP servers outside the United States employ the standard <code>en_US</code> date format orderings of <code>MMM d yyyy</code> and
    557     * <code>MMM d HH:mm</code> and attempting to deduce this automatically here would cause more problems than it would solve. The date format must be changed
    558     * via the {@link #setDefaultDateFormatStr(String) defaultDateFormatStr} and/or {@link #setRecentDateFormatStr(String) recentDateFormatStr} parameters.
    559     * </p>
    560     *
    561     * @param serverLanguageCode The value to set to the serverLanguageCode property.
    562     */
    563    public void setServerLanguageCode(final String serverLanguageCode) {
    564        this.serverLanguageCode = serverLanguageCode;
    565    }
    566
    567    /**
    568     * <p>
    569     * setter for the serverTimeZoneId property. This property allows a time zone to be specified corresponding to that known to be used by an FTP server in
    570     * file listings. This might be particularly useful to clients such as Ant that try to use these timestamps for dependency checking.
    571     * </p>
    572     * <p>
    573     * This should be one of the identifiers used by <code>java.util.TimeZone</code> to refer to time zones, for example, <code>America/Chicago</code> or
    574     * <code>Asia/Rangoon</code>.
    575     * </p>
    576     *
    577     * @param serverTimeZoneId The serverTimeZoneId to set.
    578     */
    579    public void setServerTimeZoneId(final String serverTimeZoneId) {
    580        this.serverTimeZoneId = serverTimeZoneId;
    581    }
    582
    583    /**
    584     * <p>
    585     * setter for the shortMonthNames property. This property allows the user to specify a set of month names used by the server that is different from those
    586     * that may be specified using the {@link #setServerLanguageCode(String) serverLanguageCode} property.
    587     * </p>
    588     * <p>
    589     * This should be a string containing twelve strings each composed of three characters, delimited by pipe (|) characters. Currently, only 8-bit ASCII
    590     * 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
    591     * <code>"jan|feb|mar|apr|ma&#xED;|j&#xFA;n|j&#xFA;l|&#xE1;g&#xFA;|sep|okt|n&#xF3;v|des"</code>.
    592     * </p>
    593     *
    594     * @param shortMonthNames The value to set to the shortMonthNames property.
    595     */
    596    public void setShortMonthNames(final String shortMonthNames) {
    597        this.shortMonthNames = shortMonthNames;
    598    }
    599
    600    /**
    601     * Allow list parsing methods to create basic FTPFile entries if parsing fails.
    602     * <p>
    603     * In this case, the FTPFile will contain only the unparsed entry {@link FTPFile#getRawListing()} and {@link FTPFile#isValid()} will return {@code false}
    604     *
    605     * @param saveUnparseable if true, then create FTPFile entries if parsing fails
    606     * @since 3.4
    607     */
    608    public void setUnparseableEntries(final boolean saveUnparseable) {
    609        this.saveUnparseableEntries = saveUnparseable;
    610    }
    611
    612}