Class MLSxEntryParser

  • All Implemented Interfaces:
    FTPFileEntryParser

    public class MLSxEntryParser
    extends FTPFileEntryParserImpl
    Parses MSLT and MLSD replies. See RFC 3659.

    The format is as follows:

     entry            = [ facts ] SP path
     facts            = 1*( fact ";" )
     fact             = factname "=" value
     factname         = "Size" / "Modify" / "Create" /
                        "Type" / "Unique" / "Perm" /
                        "Lang" / "Media-Type" / "CharSet" /
     os-depend-fact / local-fact
     os-depend-fact   = {IANA assigned OS name} "." token
     local-fact       = "X." token
     value            = *SCHAR
    
     Sample os-depend-fact:
     UNIX.group=0;UNIX.mode=0755;UNIX.owner=0;
     

    A single control response entry (MLST) is returned with a leading space; multiple (data) entries are returned without any leading spaces. The parser requires that the leading space from the MLST entry is removed. MLSD entries can begin with a single space if there are no facts.

    Since:
    3.0
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void doUnixPerms​(FTPFile file, java.lang.String valueLowerCase)  
      static MLSxEntryParser getInstance()
      Gets the singleton instance.
      static FTPFile parseEntry​(java.lang.String entry)
      Parses a line of an FTP server file listing and converts it into a usable format in the form of an FTPFile instance.
      FTPFile parseFTPEntry​(java.lang.String entry)
      Parses a line of an FTP server file listing and converts it into a usable format in the form of an FTPFile instance.
      static java.util.Calendar parseGMTdateTime​(java.lang.String timestamp)
      Parse a GMT time stamp of the form yyyyMMDDHHMMSS[.sss]
      static java.time.Instant parseGmtInstant​(java.lang.String timestamp)
      Parse a GMT time stamp of the form yyyyMMDDHHMMSS[.sss]
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TYPE_TO_INT

        private static final java.util.HashMap<java.lang.String,​java.lang.Integer> TYPE_TO_INT
      • UNIX_GROUPS

        private static final int[] UNIX_GROUPS
      • UNIX_PERMS

        private static final int[][] UNIX_PERMS
    • Constructor Detail

      • MLSxEntryParser

        @Deprecated
        public MLSxEntryParser()
        Deprecated.
        Creates the parser for MSLT and MSLD listing entries This class is immutable, so one can use getInstance() instead.
    • Method Detail

      • getInstance

        public static MLSxEntryParser getInstance()
        Gets the singleton instance.
        Returns:
        the singleton instance.
      • parseEntry

        public static FTPFile parseEntry​(java.lang.String entry)
        Parses a line of an FTP server file listing and converts it into a usable format in the form of an FTPFile instance. If the file listing line doesn't describe a file, null should be returned, otherwise a FTPFile instance representing the files in the directory is returned.
        Parameters:
        entry - A line of text from the file listing
        Returns:
        An FTPFile instance corresponding to the supplied entry
      • parseGMTdateTime

        public static java.util.Calendar parseGMTdateTime​(java.lang.String timestamp)
        Parse a GMT time stamp of the form yyyyMMDDHHMMSS[.sss]
        Parameters:
        timestamp - the date-time to parse
        Returns:
        a Calendar entry, may be null
        Since:
        3.4
      • parseGmtInstant

        public static java.time.Instant parseGmtInstant​(java.lang.String timestamp)
        Parse a GMT time stamp of the form yyyyMMDDHHMMSS[.sss]
        Parameters:
        timestamp - the date-time to parse
        Returns:
        a Calendar entry, may be null
        Since:
        3.9.0
      • doUnixPerms

        private void doUnixPerms​(FTPFile file,
                                 java.lang.String valueLowerCase)
      • parseFTPEntry

        public FTPFile parseFTPEntry​(java.lang.String entry)
        Description copied from interface: FTPFileEntryParser
        Parses a line of an FTP server file listing and converts it into a usable format in the form of an FTPFile instance. If the file listing line doesn't describe a file, null should be returned, otherwise a FTPFile instance representing the files in the directory is returned.
        Parameters:
        entry - A line of text from the file listing
        Returns:
        An FTPFile instance corresponding to the supplied entry