Secure FTP Factory

com.jscape.inet.ftp
Class UnixParser

java.lang.Object
  extended by com.jscape.inet.ftp.UnixParser
All Implemented Interfaces:
FtpFileParser

public class UnixParser
extends java.lang.Object
implements FtpFileParser

Parser responsible for handling FTP directory listing returned in UNIX format. The following is a partial example listing of the format expected.

 -rw-r--r--    1 vglass   vglass       3651 Feb  2  2002 .screenrc
 drwxr-xr-x    3 vglass   vglass       4096 Jul 23 17:42 Archive
 -rw-r--r--    1 vglass   vglass       1096 Jul 23 13:35 GZipTest1.class
 -rw-r--r--    1 vglass   vglass        733 Jul 23 13:35 GZipTest1.java *
 


Constructor Summary
UnixParser()
           
 
Method Summary
 java.util.Date getDateTime(FtpFile file)
          Gets the date and time for an FtpFile entry sourced from a UNIX directory listing.
 java.util.Date getDateTime(FtpFile file, java.util.TimeZone zone, java.util.Locale locale)
          Gets the date and time for an FtpFile entry sourced from a UNIX directory listing.
 java.util.Date getFileDate(java.lang.String date)
          Parses a string which contains a date and returns a date object
 java.util.Enumeration parse(java.io.BufferedReader in)
          Parses directory listing.
 FtpFile parseLine(java.lang.String line)
           
 void setLocale(java.util.Locale locale)
          Sets locale used for parsing date.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnixParser

public UnixParser()
Method Detail

parse

public java.util.Enumeration parse(java.io.BufferedReader in)
                            throws java.io.IOException
Parses directory listing. Reads directory listing from FTP server and parses contents into an Enumeration of FtpFile.

Specified by:
parse in interface FtpFileParser
Parameters:
in - the BufferedReader passed in by Ftp class when invoking Ftp#getDirListing method.
Returns:
an Enumeration of FtpFile
Throws:
java.io.IOException - if an I/O or FTP related error occurs
See Also:
FtpFile, Ftp.getDirListing(java.lang.String)

getDateTime

public java.util.Date getDateTime(FtpFile file,
                                  java.util.TimeZone zone,
                                  java.util.Locale locale)
                           throws java.text.ParseException
Gets the date and time for an FtpFile entry sourced from a UNIX directory listing.

Parameters:
file - the FtpFile
zone - the TimeZone to use when calculating time. Your default timezone is used if not provided.
locale - the Locale to use when parsing date. Locale.US is used if not provided.
Returns:
a Date, or null if FtpFile#getDate or FtpFile#getTime values are null
Throws:
java.text.ParseException - if an error occurs while parsing entry
See Also:
TimeZone, Locale, FtpFile

getDateTime

public java.util.Date getDateTime(FtpFile file)
                           throws java.text.ParseException
Gets the date and time for an FtpFile entry sourced from a UNIX directory listing.

Specified by:
getDateTime in interface FtpFileParser
Parameters:
file - the FtpFile
Throws:
java.text.ParseException - if an error occurs while parsing entry
See Also:
FtpFile

parseLine

public FtpFile parseLine(java.lang.String line)

getFileDate

public java.util.Date getFileDate(java.lang.String date)
                           throws java.text.ParseException
Parses a string which contains a date and returns a date object

Specified by:
getFileDate in interface FtpFileParser
Parameters:
date - The string will be parsed
Returns:
A object date which corresponds with the input string argument
Throws:
java.text.ParseException - if an error ocurrs

setLocale

public void setLocale(java.util.Locale locale)
Sets locale used for parsing date.

Parameters:
locale - the locale

Secure FTP Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved