1 16 package org.apache.commons.net.ftp.parser; 17 18 import java.text.ParseException ; 19 import java.util.Calendar ; 20 21 import org.apache.commons.net.ftp.Configurable; 22 import org.apache.commons.net.ftp.FTPClientConfig; 23 24 25 39 43 public abstract class ConfigurableFTPFileEntryParserImpl 44 extends RegexFTPFileEntryParserImpl 45 implements Configurable 46 { 47 48 private FTPTimestampParser timestampParser; 49 50 55 public ConfigurableFTPFileEntryParserImpl(String regex) 56 { 57 super(regex); 58 this.timestampParser = new FTPTimestampParserImpl(); 59 } 60 61 71 public Calendar parseTimestamp(String timestampStr) throws ParseException { 72 return this.timestampParser.parseTimestamp(timestampStr); 73 } 74 75 76 88 public void configure(FTPClientConfig config) 89 { 90 if (this.timestampParser instanceof Configurable) { 91 FTPClientConfig defaultCfg = getDefaultConfiguration(); 92 if (config != null) { 93 if (null == config.getDefaultDateFormatStr()) { 94 config.setDefaultDateFormatStr(defaultCfg.getDefaultDateFormatStr()); 95 } 96 if (null == config.getRecentDateFormatStr()) { 97 config.setRecentDateFormatStr(defaultCfg.getRecentDateFormatStr()); 98 } 99 ((Configurable)this.timestampParser).configure(config); 100 } else { 101 ((Configurable)this.timestampParser).configure(defaultCfg); 102 } 103 } 104 } 105 106 113 protected abstract FTPClientConfig getDefaultConfiguration(); 114 } 115 | Popular Tags |