org.apache.commons.net.ftp.parser
Class FTPTimestampParserImpl

java.lang.Object
  extended by org.apache.commons.net.ftp.parser.FTPTimestampParserImpl
All Implemented Interfaces:
Configurable, FTPTimestampParser

public class FTPTimestampParserImpl
extends Object
implements FTPTimestampParser, Configurable

Default implementation of the FTPTimestampParser interface also implements the Configurable interface to allow the parsing to be configured from the outside.

Since:
1.4
See Also:
ConfigurableFTPFileEntryParserImpl

Field Summary
 
Fields inherited from interface org.apache.commons.net.ftp.parser.FTPTimestampParser
DEFAULT_RECENT_SDF, DEFAULT_SDF
 
Constructor Summary
FTPTimestampParserImpl()
          The only constructor for this class.
 
Method Summary
 void configure(FTPClientConfig config)
          Implementation of the Configurable interface.
 SimpleDateFormat getDefaultDateFormat()
           
 String getDefaultDateFormatString()
           
 SimpleDateFormat getRecentDateFormat()
           
 String getRecentDateFormatString()
           
 TimeZone getServerTimeZone()
           
 String[] getShortMonths()
           
 Calendar parseTimestamp(String timestampStr)
          Implements the one method in the FTPTimestampParser interface according to this algorithm: If the recentDateFormat member has been defined, try to parse the supplied string with that.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FTPTimestampParserImpl

public FTPTimestampParserImpl()
The only constructor for this class.

Method Detail

parseTimestamp

public Calendar parseTimestamp(String timestampStr)
                        throws ParseException
Implements the one method in the FTPTimestampParser interface according to this algorithm: If the recentDateFormat member has been defined, try to parse the supplied string with that. If that parse fails, or if the recentDateFormat member has not been defined, attempt to parse with the defaultDateFormat member. If that fails, throw a ParseException.

Specified by:
parseTimestamp in interface FTPTimestampParser
Parameters:
timestampStr - - the timestamp portion of the FTP directory listing to be parsed
Returns:
a java.util.Calendar object initialized to the date parsed by the parser
Throws:
ParseException - if none of the parser mechanisms belonging to the implementor can parse the input.
See Also:
FTPTimestampParser.parseTimestamp(java.lang.String)

getDefaultDateFormat

public SimpleDateFormat getDefaultDateFormat()
Returns:
Returns the defaultDateFormat.

getDefaultDateFormatString

public String getDefaultDateFormatString()
Returns:
Returns the defaultDateFormat pattern string.

getRecentDateFormat

public SimpleDateFormat getRecentDateFormat()
Returns:
Returns the recentDateFormat.

getRecentDateFormatString

public String getRecentDateFormatString()
Returns:
Returns the recentDateFormat.

getShortMonths

public String[] getShortMonths()
Returns:
returns an array of 12 strings representing the short month names used by this parse.

getServerTimeZone

public TimeZone getServerTimeZone()
Returns:
Returns the serverTimeZone used by this parser.

configure

public void configure(FTPClientConfig config)
Implementation of the Configurable interface. Configures this FTPTimestampParser according to the following logic:

Set up the defaultDateFormat and optionally the recentDateFormat to values supplied in the config based on month names configured as follows:

Finally if a serverTimeZoneId has been supplied via the config, set that into all date formats that have been configured.

Specified by:
configure in interface Configurable
Parameters:
config - the object containing the configuration data


Copyright © 1997-2010 The Apache Software Foundation. All Rights Reserved.