    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 *      https://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}</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} date formatting
    049 * </p>
    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 * </p>
    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} date formatting
    083 * </p>
    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 * </p>
    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 * <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 */
    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     * 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="https://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&#xED;|j&#xFA;n|j&#xFA;l|&#xE1;g&#xFA;|sep|okt|n&#xF3;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}