This class handles the entire process of parsing a listing of
file entries from the server.
This object defines a two-part parsing mechanism.
The first part is comprised of reading the raw input into an internal
list of strings. Every item in this list corresponds to an actual
file. All extraneous matter emitted by the server will have been
removed by the end of this phase. This is accomplished in conjunction
with the FTPFileEntryParser associated with this engine, by calling
its methods readNextEntry() - which handles the issue of
what delimits one entry from another, usually but not always a line
feed and preParse() - which handles removal of
extraneous matter such as the preliminary lines of a listing, removal
of duplicates on versioning systems, etc.
The second part is composed of the actual parsing, again in conjunction
with the particular parser used by this engine. This is controlled
by an iterator over the internal list of strings. This may be done
either in block mode, by calling the getNext() and
getPrevious() methods to provide "paged" output of less
than the whole list at one time, or by calling the
getFiles() method to return the entire list.
Examples:
Paged access:
FTPClient f=FTPClient();
f.connect(server);
f.login(username, password);
FTPListParseEngine engine = f.initiateListParsing(directory);
while (engine.hasNext()) {
FTPFile[] files = engine.getNext(25); // "page size" you want
//do whatever you want with these files, display them, etc.
//expensive FTPFile objects not created until needed.
}
For unpaged access, simply use FTPClient.listFiles(). That method
uses this class transparently. |