Secure FTP Factory

com.jscape.filetransfer
Class FileTransferRemoteSort

java.lang.Object
  extended by com.jscape.filetransfer.FileTransferRemoteSort

public class FileTransferRemoteSort
extends java.lang.Object

Sorts an Enumeration of FileTransferRemoteFile. The user must specify a Comparator instance which will be used by the sort algorithm.

The following is an example usage

 FtpTransfer ftp = new FtpTransfer(host, user, password, port);
 ftp.connect();
 

// Get the remote files enumeration Enumeration e = ftp.getDirListing();

//Creates the sorter with the file date comparator FileTransferRemoteSort sorter = new FileTransferRemoteSort(e, new FileTransferRemoteSort.FileDateComparator());

// sort in ascending order sorter.setAscendent(true); // sorts enumeration e = sorter.sort();

Author:
Alvaro

Nested Class Summary
static class FileTransferRemoteSort.FileDateComparator
          Sorts files by date.
static class FileTransferRemoteSort.FileNameComparator
          Sorts files by name.
static class FileTransferRemoteSort.FileSizeComparator
          Sorts files by filesize.
 
Constructor Summary
FileTransferRemoteSort(java.util.Enumeration e, com.jscape.filetransfer.FileTransferRemoteComparator comparator)
          Creates a new FileTransferRemoteSort instance used to sort an Enumeration of FileTransferRemoteFile.
 
Method Summary
 com.jscape.filetransfer.FileTransferRemoteComparator getComparator()
          Gets FileTransferRemoteComparator instance.
 java.util.Enumeration getData()
          Gets the data to be sorted.
 boolean isAscendent()
          Gets whether sort will be performed in ascending or descending order.
 void setAscendent(boolean ascendent)
          Sets whether sort will be performed in ascending or descending order.
 void setComparator(com.jscape.filetransfer.FileTransferRemoteComparator comparator)
          Sets FileTransferRemoteComparator.
 void setData(java.util.Enumeration e)
          Sets the data to be sorted.
 java.util.Enumeration sort()
          Sorts the data.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileTransferRemoteSort

public FileTransferRemoteSort(java.util.Enumeration e,
                              com.jscape.filetransfer.FileTransferRemoteComparator comparator)
Creates a new FileTransferRemoteSort instance used to sort an Enumeration of FileTransferRemoteFile.

Parameters:
e - an Enumeration containing remote files
comparator - the Comparator to use in sorting
Method Detail

getComparator

public com.jscape.filetransfer.FileTransferRemoteComparator getComparator()
Gets FileTransferRemoteComparator instance.

Returns:
a FileTransferRemoteComparator

setComparator

public void setComparator(com.jscape.filetransfer.FileTransferRemoteComparator comparator)
Sets FileTransferRemoteComparator.

Parameters:
comparator - a FileTransferRemoteComparator

setAscendent

public void setAscendent(boolean ascendent)
Sets whether sort will be performed in ascending or descending order.

Parameters:
ascendent - if true the data will be sorted in ascending order

isAscendent

public boolean isAscendent()
Gets whether sort will be performed in ascending or descending order.

Returns:
true if the data will be sorted in ascending order

setData

public void setData(java.util.Enumeration e)
Sets the data to be sorted.

Parameters:
e - an Enumeration of FileTransferRemoteFile

getData

public java.util.Enumeration getData()
Gets the data to be sorted.

Returns:
an Enumeration of FileTranferRemoteFile

sort

public java.util.Enumeration sort()
Sorts the data.

Returns:
a sorted Enumeration of FileTransferRemoteFile

Secure FTP Factory

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