After building Maven (instead of using distributed binary) I can finally see
the Checkstyle output without committing first, so could REALLY clean it up
this time. The only things left in the new files are places where checkstyle
may be in error (as reported yesterday) or a few cases of comment that are
lines of actual sample FTP output longer than 80 chars which I refuse to
split.
Index: FTPClient2.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons-sandbox/net/src/java/org/apache/commons/net/ftp/ftp2/FTPClient2.java,v
retrieving revision 1.1
diff -u -r1.1 FTPClient2.java
--- FTPClient2.java 29 Apr 2002 03:55:31 -0000 1.1
+++ FTPClient2.java 2 May 2002 12:24:36 -0000
@@ -59,7 +59,6 @@
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPCommand;
import org.apache.commons.net.ftp.FTPFile;
-import org.apache.commons.net.ftp.ftp2.FTPFileEntryParser;
import org.apache.commons.net.ftp.ftp2.parser.UnixFTPEntryParser;
/**
@@ -78,11 +77,14 @@
*/
public class FTPClient2 extends FTPClient
{
- private FTPFileEntryParser __fileEntryParser;
+ private FTPFileEntryParser defaultParser;
+ /**
+ * The only constructor for this class.
+ */
public FTPClient2()
{
super();
- __fileEntryParser = new UnixFTPEntryParser();
+ this.defaultParser = new UnixFTPEntryParser();
}
/**
@@ -144,7 +146,7 @@
*/
public FTPFile[] listFiles(String pathname) throws IOException
{
- return listFiles(__fileEntryParser, pathname);
+ return listFiles(this.defaultParser, pathname);
}
/**
@@ -168,7 +170,7 @@
*/
public FTPFile[] listFiles() throws IOException
{
- return listFiles(__fileEntryParser, null);
+ return listFiles(this.defaultParser, null);
}
/**
@@ -182,13 +184,12 @@
* using glob expressions because the return format for glob listings
* differs from server to server and will likely cause this method to fail.
* <p>
- * @param pathname The file or directory to list.
* @return An iteratable object that holds the raw information and is
* capable of providing parsed FTPFile objects, one for each file containing
* information contained in the given path in the format determined by the
* <code> parser </code> parameter. Null will be returned if a
- * data connection cannot be opened. If the current working directory contains
- * no files, an empty array will be the return.
+ * data connection cannot be opened. If the current working directory
+ * contains no files, an empty array will be the return.
* @exception FTPConnectionClosedException
* If the FTP server prematurely closes the connection as a result
* of the client being idle or some other reason causing the server
@@ -200,7 +201,7 @@
*/
public FTPFileList createFileList() throws IOException
{
- return createFileList(null, this.__fileEntryParser);
+ return createFileList(null, this.defaultParser);
}
/**
@@ -214,7 +215,7 @@
* using glob expressions because the return format for glob listings
* differs from server to server and will likely cause this method to fail.
* <p>
- * @param pathname The file or directory to list.
+ * @param basedir The file or directory to list.
* @return An iteratable object that holds the raw information and is
* capable of providing parsed FTPFile objects, one for each file containing
* information contained in the given path in the format determined by the
@@ -232,7 +233,7 @@
*/
public FTPFileList createFileList(String basedir) throws IOException
{
- return createFileList(basedir, this.__fileEntryParser);
+ return createFileList(basedir, this.defaultParser);
}
/**
@@ -306,7 +307,9 @@
FTPFile[] results;
if ((socket = __openDataConnection(FTPCommand.LIST, pathname)) == null)
+ {
return null;
+ }
FTPFileList list =
FTPFileList.create(socket.getInputStream(), parser);
Index: FTPFileEntryParser.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons-sandbox/net/src/java/org/apache/commons/net/ftp/ftp2/FTPFileEntryParser.java,v
retrieving revision 1.1
diff -u -r1.1 FTPFileEntryParser.java
--- FTPFileEntryParser.java 29 Apr 2002 03:55:31 -0000 1.1
+++ FTPFileEntryParser.java 2 May 2002 12:24:36 -0000
@@ -58,7 +58,8 @@
/**
* FTPFileEntryParser defines the interface for parsing a single FTP file
- * listing and converting that information into an <a href="org.apache.commons.net.ftp.FTPFile.html"> FTPFile </a> instance.
+ * listing and converting that information into an
+ * <a href="org.apache.commons.net.ftp.FTPFile.html"> FTPFile </a> instance.
* Sometimes you will want to parse unusual listing formats, in which
* case you would create your own implementation of FTPFileEntryParser and
* if necessary, subclass FTPFile.
Index: FTPFileIterator.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons-sandbox/net/src/java/org/apache/commons/net/ftp/ftp2/FTPFileIterator.java,v
retrieving revision 1.1
diff -u -r1.1 FTPFileIterator.java
--- FTPFileIterator.java 29 Apr 2002 03:55:31 -0000 1.1
+++ FTPFileIterator.java 2 May 2002 12:24:37 -0000
@@ -114,7 +114,7 @@
FTPFile entry = null;
for (int iter = 0; iter < this.rawlines.size(); iter++)
{
- String line = (String)this.rawlines.elementAt(iter);
+ String line = (String) this.rawlines.elementAt(iter);
entry = parseFTPEntry(line);
if (null != entry)
{
@@ -149,24 +149,27 @@
}
/**
- * Returns an array of at most <code>howMany</code> FTPFile objects
- * starting at this iterator's current position within its associated
- * list. If fewer than <code>howMany</code> 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 the current position is advanced by either
- * <code>howMany</code> or the number of entries available after the
- * iterator, whichever is fewer.
- * @param howMany the maximum number of entries we want to get. A 0
+ * Returns an array of at most <code>quantityRequested</code> FTPFile
+ * objects starting at this iterator's current position within its
+ * associated list. If fewer than <code>quantityRequested</code> 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 the current position is advanced by
+ * either <code>quantityRequested</code> or the number of entries
+ * available after the iterator, whichever is fewer.
+ *
+ * @param quantityRequested
+ * the maximum number of entries we want to get. A 0
* passed here is a signal to get ALL the entries.
- * @return an array of at most <code>howMany</code> FTPFile objects
- * starting at the current position of this iterator within its list
- * and at least the number of elements which exist in the list at and
- * after its current position.
+ *
+ * @return an array of at most <code>quantityRequested</code> FTPFile
+ * objects starting at the current position of this iterator within its
+ * list and at least the number of elements which exist in the list at
+ * and after its current position.
*/
- public FTPFile[] getNext(int howMany)
+ public FTPFile[] getNext(int quantityRequested)
{
// if we haven't gotten past the initial junk do so.
@@ -184,17 +187,17 @@
// now that we know the maximum we can possibly get,
// resolve a 0 request to ask for that many.
- int _howMany = (howMany == 0) ? max : howMany;
- _howMany = (_howMany + this.itemptr < this.rawlines.size())
- ? _howMany
+ int howMany = (quantityRequested == 0) ? max : quantityRequested;
+ howMany = (howMany + this.itemptr < this.rawlines.size())
+ ? howMany
: this.rawlines.size() - this.itemptr;
- FTPFile[] output = new FTPFile[_howMany];
+ FTPFile[] output = new FTPFile[howMany];
for (int i = 0, e = this.firstGoodEntry + this.itemptr ;
- i < _howMany; i++, e++)
+ i < howMany; i++, e++)
{
- output[i] = parseFTPEntry((String)this.rawlines.elementAt(e));
+ output[i] = parseFTPEntry((String) this.rawlines.elementAt(e));
this.itemptr++;
}
@@ -249,36 +252,37 @@
}
/**
- * Returns an array of at most <code>howMany</code> FTPFile objects
- * starting at the position preceding this iterator's current position
- * within its associated list. If fewer than <code>howMany</code> such
- * elements are available, the returned array will have a length
- * equal to the number of entries after the iterator. If no such entries
- * are found, this array will have a length of 0. The entries will be
- * ordered in the same order as the list, not reversed.
- *
- * After this method is called the current position is moved back by either
- * <code>howMany</code> or the number of entries available before the
- * current position, whichever is fewer.
- * @param howMany the maximum number of entries we want to get. A 0
- * passed here is a signal to get ALL the entries.
- * @return an array of at most <code>howMany</code> FTPFile objects
- * starting at the position preceding the current position of this
- * iterator within its list and at least the number of elements which
+ * Returns an array of at most <code>quantityRequested</code> FTPFile
+ * objects starting at the position preceding this iterator's current
+ * position within its associated list. If fewer than
+ * <code>quantityRequested</code> such elements are available, the
+ * returned array will have a length equal to the number of entries after
+ * the iterator. If no such entries are found, this array will have a
+ * length of 0. The entries will be ordered in the same order as the
+ * list, not reversed.
+ *
+ * After this method is called the current position is moved back by
+ * either <code>quantityRequested</code> or the number of entries
+ * available before the current position, whichever is fewer.
+ * @param quantityRequested the maximum number of entries we want to get.
+ * A 0 passed here is a signal to get ALL the entries.
+ * @return an array of at most <code>quantityRequested</code> FTPFile
+ * objects starting at the position preceding the current position of
+ * this iterator within its list and at least the number of elements which
* exist in the list prior to its current position.
*/
- public FTPFile[] getPrevious(int howMany)
+ public FTPFile[] getPrevious(int quantityRequested)
{
- int _howMany = howMany;
- // can't retreat further than we've come.
- if (_howMany > this.itemptr)
+ int howMany = quantityRequested;
+ // can't retreat further than we've previously advanced
+ if (howMany > this.itemptr)
{
- _howMany = this.itemptr;
+ howMany = this.itemptr;
}
- FTPFile[] output = new FTPFile[_howMany];
- for (int i = _howMany, e = this.firstGoodEntry + this.itemptr; i > 0;)
+ FTPFile[] output = new FTPFile[howMany];
+ for (int i = howMany, e = this.firstGoodEntry + this.itemptr; i > 0; )
{
- output[--i] = parseFTPEntry((String)this.rawlines.elementAt(--e));
+ output[--i] = parseFTPEntry((String) this.rawlines.elementAt(--e));
this.itemptr--;
}
return output;
Index: FTPFileList.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons-sandbox/net/src/java/org/apache/commons/net/ftp/ftp2/FTPFileList.java,v
retrieving revision 1.1
diff -u -r1.1 FTPFileList.java
--- FTPFileList.java 29 Apr 2002 03:55:32 -0000 1.1
+++ FTPFileList.java 2 May 2002 12:24:37 -0000
@@ -58,10 +58,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.Enumeration;
import java.util.Vector;
import org.apache.commons.net.ftp.FTPFile;
-import org.apache.commons.net.ftp.ftp2.FTPFileEntryParser;
/**
* FTPFileList.java
@@ -85,8 +83,17 @@
*/
public class FTPFileList
{
+ /**
+ * storage for the raw lines of input read from the FTP server
+ */
private Vector lines = null;
+ /**
+ * the FTPFileEntryParser assigned to be used with this lister
+ */
private FTPFileEntryParser parser;
+ /**
+ * private status code for an empty directory
+ */
private static final int EMPTY_DIR = -2;
/**
@@ -103,7 +110,7 @@
}
/**
- * The only way to create an <code> FTPFileList</code> object. Invokes
+ * The only way to create an <code>FTPFileList</code> object. Invokes
* the private constructor and then reads the stream supplied stream to
* build the intermediate array of "lines" which will later be parsed
* into <code>FTPFile</code> object.
@@ -112,29 +119,29 @@
* the output of the LIST command was returned
* @param parser the default <code>FTPFileEntryParser</code> to be used
* by this object. This may later be changed using the init() method.
- * @param sleepInterval - amount of time in milliseconds to sleep
- * between lines read.
+ *
* @return the <code>FTPFileList</code> created, with an initialized
* of unparsed lines of output. Will be null if the listing cannot
* be read from the stream.
+ * @exception IOException
+ * Thrown on any failure to read from the socket.
*/
public static FTPFileList create( InputStream stream,
FTPFileEntryParser parser)
+ throws IOException
{
- try
- {
- FTPFileList list = new FTPFileList(parser);
- list.readStream(stream);
- return list;
-
- }
- catch (IOException e)
- {
- System.out.println("IOException " + e.getMessage());
- return null;
- }
- }
+ FTPFileList list = new FTPFileList(parser);
+ list.readStream(stream);
+ return list;
+ }
+ /**
+ * internal method for reading the input into the <code>lines</code> vector.
+ *
+ * @param stream The socket stream on which the input will be read.
+ *
+ * @exception IOException
+ */
private void readStream(InputStream stream) throws IOException
{
BufferedReader reader =
@@ -150,29 +157,50 @@
reader.close();
}
+ /**
+ * Accessor for this object's default parser.
+ *
+ * @return this object's default parser.
+ */
FTPFileEntryParser getParser()
{
return this.parser;
}
+ /**
+ * Package private accessor for the collection of raw input lines.
+ *
+ * @return vector containing all the raw input lines returned from the FTP
+ * server
+ */
Vector getLines()
{
return this.lines;
}
+ /**
+ * create an iterator over this list using the parser with which this list
+ * was initally created
+ *
+ * @return an iterator over this list using the list's default parser.
+ */
public FTPFileIterator iterator()
{
return new FTPFileIterator(this);
}
+ /**
+ * create an iterator over this list using the supplied parser
+ *
+ * @param parser The user-supplied parser with which the list is to be
+ * iterated, may be different from this list's default parser.
+ *
+ * @return an iterator over this list using the supplied parser.
+ */
public FTPFileIterator iterator(FTPFileEntryParser parser)
{
return new FTPFileIterator(this, parser);
}
- private FTPFile parseFTPEntry(String entry)
- {
- return this.parser.parseFTPEntry(entry);
- }
/**
* returns an array of FTPFile objects for all the files in the directory
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>