void createParser()

in src/main/java/org/apache/commons/net/ftp/FTPClient.java [1210:1250]


    void createParser(final String parserKey) throws IOException {
        // We cache the value to avoid creation of a new object every
        // time a file listing is generated.
        // Note: we don't check against a null parserKey (NET-544)
        if (entryParser == null || (parserKey != null && !entryParserKey.equals(parserKey))) {
            if (null != parserKey) {
                // if a parser key was supplied in the parameters,
                // use that to create the parser
                entryParser = parserFactory.createFileEntryParser(parserKey);
                entryParserKey = parserKey;

            } else // if no parserKey was supplied, check for a configuration
            // in the params, and if it has a non-empty system type, use that.
            if (null != configuration && configuration.getServerSystemKey().length() > 0) {
                entryParser = parserFactory.createFileEntryParser(configuration);
                entryParserKey = configuration.getServerSystemKey();
            } else {
                // if a parserKey hasn't been supplied, and a configuration
                // hasn't been supplied, and the override property is not set
                // then autodetect by calling
                // the SYST command and use that to choose the parser.
                String systemType = System.getProperty(FTP_SYSTEM_TYPE);
                if (systemType == null) {
                    systemType = getSystemType(); // cannot be null
                    final Properties override = getOverrideProperties();
                    if (override != null) {
                        final String newType = override.getProperty(systemType);
                        if (newType != null) {
                            systemType = newType;
                        }
                    }
                }
                if (null != configuration) { // system type must have been empty above
                    entryParser = parserFactory.createFileEntryParser(new FTPClientConfig(systemType, configuration));
                } else {
                    entryParser = parserFactory.createFileEntryParser(systemType);
                }
                entryParserKey = systemType;
            }
        }
    }