java.lang.Object | +--org.apache.commons.net.ftp.FTPListParseEngine
FTPListParseEngine(FTPFileEntryParser parser) |
FTPFile[] | getFiles() Returns an array of FTPFile objects containing the whole list of files returned by the server as read by this object's parser. |
FTPFile[] | getNext(int quantityRequested) Returns an array of at most quantityRequested FTPFile objects starting at this object's internal iterator's current position. |
FTPFile[] | getPrevious(int quantityRequested) Returns an array of at most quantityRequested FTPFile objects starting at this object's internal iterator's current position, and working back toward the beginning. |
boolean | hasNext() convenience method to allow clients to know whether this object's internal iterator's current position is at the end of the list. |
boolean | convenience method to allow clients to know whether this object's internal iterator's current position is at the beginning of the list. |
void | readServerList(InputStream stream) handle the iniitial reading and preparsing of the list returned by the server. |
void | resets this object's internal iterator to the beginning of the list. |
public FTPListParseEngine(FTPFileEntryParser parser)
public FTPFile[] getFiles()
- public FTPFile[] getNext(int quantityRequested)
quantityRequested FTPFile
objects starting at this object's internal iterator's current position.
If fewer than quantityRequested such
elements are available, the returned array will have a length equal
to the number of entries at and after after the current position.
If no such entries are found, this array will have a length of 0.
After this method is called this object's internal iterator is advanced
by a number of positions equal to the size of the array returned.
public FTPFile[] getPrevious(int quantityRequested)
quantityRequested FTPFile
objects starting at this object's internal iterator's current position,
and working back toward the beginning.
If fewer than quantityRequested such
elements are available, the returned array will have a length equal
to the number of entries at and after after the current position.
If no such entries are found, this array will have a length of 0.
After this method is called this object's internal iterator is moved
back by a number of positions equal to the size of the array returned.
public boolean hasNext()
public boolean hasPrevious()
public void readServerList(InputStream stream)
- thrown on any failure to read from the sever.public void resetIterator()
readNextEntry()- which handles the issue of what delimits one entry from another, usually but not always a line feed andpreParse()- 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 thegetNext()andgetPrevious()methods to provide "paged" output of less than the whole list at one time, or by calling thegetFiles()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.