You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2004/04/22 02:48:07 UTC
cvs commit: jakarta-commons/net/src/java/org/apache/commons/net/ftp FTPClient.java FTPFileEntryParserImpl.java FTPListParseEngine.java FTP.java
scohen 2004/04/21 17:48:07
Modified: net/src/test/org/apache/commons/net/ftp/parser
CompositeFTPParseTestFramework.java
NTFTPEntryParserTest.java
VMSFTPEntryParserTest.java AllTests.java
UnixFTPEntryParserTest.java
OS400FTPEntryParserTest.java
net/src/java/org/apache/commons/net/smtp SMTP.java
net/src/java/org/apache/commons/net/tftp TFTPClient.java
net/src/java/examples ExtendedNNTPOps.java ftp.java
net/src/java/org/apache/commons/net/ftp/parser
VMSFTPEntryParser.java OS400FTPEntryParser.java
VMSVersioningFTPEntryParser.java
UnixFTPEntryParser.java
RegexFTPFileEntryParserImpl.java
net/src/java/org/apache/commons/net/ftp FTPClient.java
FTPFileEntryParserImpl.java FTPListParseEngine.java
FTP.java
Log:
make checkstyle happy by converting tabs to spaces.
Revision Changes Path
1.2 +112 -112 jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/CompositeFTPParseTestFramework.java
Index: CompositeFTPParseTestFramework.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/CompositeFTPParseTestFramework.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CompositeFTPParseTestFramework.java 16 Apr 2004 01:52:24 -0000 1.1
+++ CompositeFTPParseTestFramework.java 22 Apr 2004 00:48:07 -0000 1.2
@@ -24,115 +24,115 @@
*/
public abstract class CompositeFTPParseTestFramework extends FTPParseTestFramework
{
- /**
- * @see junit.framework.TestCase#TestCase(String)
- */
- public CompositeFTPParseTestFramework(String name)
- {
- super(name);
- }
-
- /**
- * @see FTPParseTestFramework#getGoodListing()
- */
- protected String[] getGoodListing()
- {
- return (getGoodListings()[0]);
- }
-
- /**
- * Method getBadListing.
- * Implementors must provide multiple listing that contains failures and
- * must force the composite parser to switch the FtpEntryParser
- *
- * @return String[]
- */
- protected abstract String[][] getBadListings();
-
- /**
- * Method getGoodListing.
- * Implementors must provide multiple listing that passes and
- * must force the composite parser to switch the FtpEntryParser
- *
- * @return String[]
- */
- protected abstract String[][] getGoodListings();
-
- /**
- * @see FTPParseTestFramework#getBadListing()
- */
- protected String[] getBadListing()
- {
- return (getBadListings()[0]);
- }
-
- /* (non-Javadoc)
- * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testGoodListing()
- */
- public void testConsistentListing() throws Exception
- {
- String goodsamples[][] = getGoodListings();
-
- for (int i = 0; i < goodsamples.length; i++)
- {
- FTPFileEntryParser parser = getParser();
- for (int j = 0; j < goodsamples[i].length; j++)
- {
- String test = goodsamples[i][j];
- FTPFile f = parser.parseFTPEntry(test);
- assertNotNull("Failed to parse " + test,
- f);
-
- doAdditionalGoodTests(test, f);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testGoodListing()
- */
- public void testBadListing() throws Exception
- {
- String badsamples[][] = getBadListings();
-
- for (int i = 0; i < badsamples.length; i++)
- {
- FTPFileEntryParser parser = getParser();
- for (int j = 0; j < badsamples[i].length; j++)
- {
- String test = badsamples[i][j];
- FTPFile f = parser.parseFTPEntry(test);
- assertNull("Should have Failed to parse " + test,
- f);
-
- doAdditionalBadTests(test, f);
- }
- }
- }
-
- // even though all these listings are good using one parser
- // or the other, this tests that a parser that has succeeded
- // on one format will fail if another format is substituted.
- public void testInconsistentListing() throws Exception
- {
- String goodsamples[][] = getGoodListings();
-
- FTPFileEntryParser parser = getParser();
-
- for (int i = 0; i < goodsamples.length; i++)
- {
- String test = goodsamples[i][0];
- FTPFile f = parser.parseFTPEntry(test);
-
- switch (i)
- {
- case 0:
- assertNotNull("Failed to parse " + test, f);
- break;
- case 1:
- assertNull("Should have failed to parse " + test, f);
- break;
- }
- }
- }
+ /**
+ * @see junit.framework.TestCase#TestCase(String)
+ */
+ public CompositeFTPParseTestFramework(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * @see FTPParseTestFramework#getGoodListing()
+ */
+ protected String[] getGoodListing()
+ {
+ return (getGoodListings()[0]);
+ }
+
+ /**
+ * Method getBadListing.
+ * Implementors must provide multiple listing that contains failures and
+ * must force the composite parser to switch the FtpEntryParser
+ *
+ * @return String[]
+ */
+ protected abstract String[][] getBadListings();
+
+ /**
+ * Method getGoodListing.
+ * Implementors must provide multiple listing that passes and
+ * must force the composite parser to switch the FtpEntryParser
+ *
+ * @return String[]
+ */
+ protected abstract String[][] getGoodListings();
+
+ /**
+ * @see FTPParseTestFramework#getBadListing()
+ */
+ protected String[] getBadListing()
+ {
+ return (getBadListings()[0]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testGoodListing()
+ */
+ public void testConsistentListing() throws Exception
+ {
+ String goodsamples[][] = getGoodListings();
+
+ for (int i = 0; i < goodsamples.length; i++)
+ {
+ FTPFileEntryParser parser = getParser();
+ for (int j = 0; j < goodsamples[i].length; j++)
+ {
+ String test = goodsamples[i][j];
+ FTPFile f = parser.parseFTPEntry(test);
+ assertNotNull("Failed to parse " + test,
+ f);
+
+ doAdditionalGoodTests(test, f);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.net.ftp.parser.FTPParseTestFramework#testGoodListing()
+ */
+ public void testBadListing() throws Exception
+ {
+ String badsamples[][] = getBadListings();
+
+ for (int i = 0; i < badsamples.length; i++)
+ {
+ FTPFileEntryParser parser = getParser();
+ for (int j = 0; j < badsamples[i].length; j++)
+ {
+ String test = badsamples[i][j];
+ FTPFile f = parser.parseFTPEntry(test);
+ assertNull("Should have Failed to parse " + test,
+ f);
+
+ doAdditionalBadTests(test, f);
+ }
+ }
+ }
+
+ // even though all these listings are good using one parser
+ // or the other, this tests that a parser that has succeeded
+ // on one format will fail if another format is substituted.
+ public void testInconsistentListing() throws Exception
+ {
+ String goodsamples[][] = getGoodListings();
+
+ FTPFileEntryParser parser = getParser();
+
+ for (int i = 0; i < goodsamples.length; i++)
+ {
+ String test = goodsamples[i][0];
+ FTPFile f = parser.parseFTPEntry(test);
+
+ switch (i)
+ {
+ case 0:
+ assertNotNull("Failed to parse " + test, f);
+ break;
+ case 1:
+ assertNull("Should have failed to parse " + test, f);
+ break;
+ }
+ }
+ }
}
1.14 +39 -39 jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/NTFTPEntryParserTest.java
Index: NTFTPEntryParserTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/NTFTPEntryParserTest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- NTFTPEntryParserTest.java 21 Apr 2004 23:30:33 -0000 1.13
+++ NTFTPEntryParserTest.java 22 Apr 2004 00:48:07 -0000 1.14
@@ -35,18 +35,18 @@
"12-05-96 05:03PM <DIR> absoft2",
"11-14-97 04:21PM 953 AUDITOR3.INI",
"05-22-97 08:08AM 828 AUTOEXEC.BAK",
- "01-22-98 01:52PM 795 AUTOEXEC.BAT",
- "05-13-97 01:46PM 828 AUTOEXEC.DOS",
- "12-03-96 06:38AM 403 AUTOTOOL.LOG",
- "12-03-96 06:38AM <DIR> 123xyz",
- "01-20-97 03:48PM <DIR> bin",
- },
- {
- "-rw-r--r-- 1 root root 111325 Apr 27 2001 zxJDBC-2.0.1b1.tar.gz",
- "-rw-r--r-- 1 root root 190144 Apr 27 2001 zxJDBC-2.0.1b1.zip",
- "-rwxr-xr-x 2 500 500 166 Nov 2 2001 73131-testtes1.afp",
- "-rw-r--r-- 1 500 500 166 Nov 9 2001 73131-testtes1.AFP",
- }
+ "01-22-98 01:52PM 795 AUTOEXEC.BAT",
+ "05-13-97 01:46PM 828 AUTOEXEC.DOS",
+ "12-03-96 06:38AM 403 AUTOTOOL.LOG",
+ "12-03-96 06:38AM <DIR> 123xyz",
+ "01-20-97 03:48PM <DIR> bin",
+ },
+ {
+ "-rw-r--r-- 1 root root 111325 Apr 27 2001 zxJDBC-2.0.1b1.tar.gz",
+ "-rw-r--r-- 1 root root 190144 Apr 27 2001 zxJDBC-2.0.1b1.zip",
+ "-rwxr-xr-x 2 500 500 166 Nov 2 2001 73131-testtes1.afp",
+ "-rw-r--r-- 1 500 500 166 Nov 9 2001 73131-testtes1.AFP",
+ }
};
private static final String[][] badsamples =
@@ -54,8 +54,8 @@
{
"05-26-1995 10:57AM 143712 $LDR$",
"20-05-97 03:31PM 681 .bash_history",
- "drwxr-xr-x 2 root 99 4096 Feb 23 30:01 zzplayer",
- "12-05-96 17:03 <DIR> absoft2",
+ "drwxr-xr-x 2 root 99 4096 Feb 23 30:01 zzplayer",
+ "12-05-96 17:03 <DIR> absoft2",
"05-22-97 08:08 828 AUTOEXEC.BAK",
" 0 DIR 05-19-97 12:56 local",
" 0 DIR 05-12-97 16:52 Maintenance Desktop",
@@ -72,7 +72,7 @@
};
private static final String directoryBeginningWithNumber =
- "12-03-96 06:38AM <DIR> 123xyz";
+ "12-03-96 06:38AM <DIR> 123xyz";
/**
@@ -104,11 +104,11 @@
*/
protected FTPFileEntryParser getParser()
{
- return new CompositeFileEntryParser(new FTPFileEntryParser[]
- {
- new NTFTPEntryParser(),
- new UnixFTPEntryParser()
- });
+ return new CompositeFileEntryParser(new FTPFileEntryParser[]
+ {
+ new NTFTPEntryParser(),
+ new UnixFTPEntryParser()
+ });
}
/**
@@ -138,7 +138,7 @@
dir = getParser().parseFTPEntry("12-03-96 06:38AM <DIR> 123456");
assertNotNull("Could not parse entry.", dir);
assertTrue("Should have been a directory.",
- dir.isDirectory());
+ dir.isDirectory());
assertEquals("123456", dir.getName());
assertEquals(0, dir.getSize());
@@ -162,13 +162,13 @@
// on the hour.
f = getParser().parseFTPEntry(
- "-rw-rw-r-- 1 mqm mqm 17707 Mar 12 3:33 killmq.sh.log");
+ "-rw-rw-r-- 1 mqm mqm 17707 Mar 12 3:33 killmq.sh.log");
assertNotNull("Could not parse entry.", f);
Calendar cal = Calendar.getInstance();
cal.setTime(f.getTimestamp().getTime());
assertEquals("hour", 3, cal.get(Calendar.HOUR));
assertTrue("Should have been a file.",
- f.isFile());
+ f.isFile());
assertEquals(17707, f.getSize());
@@ -181,22 +181,22 @@
protected void doAdditionalGoodTests(String test, FTPFile f)
{
if (test.indexOf("<DIR>") >= 0)
- {
- assertEquals("directory.type",
- FTPFile.DIRECTORY_TYPE, f.getType());
- }
- }
-
- /**
- * test condition reported as bug 20259.
- * directory with name beginning with a numeric character
- * was not parsing correctly
+ {
+ assertEquals("directory.type",
+ FTPFile.DIRECTORY_TYPE, f.getType());
+ }
+ }
+
+ /**
+ * test condition reported as bug 20259.
+ * directory with name beginning with a numeric character
+ * was not parsing correctly
*
- * @throws Exception
- */
+ * @throws Exception
+ */
public void testDirectoryBeginningWithNumber() throws Exception
{
- FTPFile f = getParser().parseFTPEntry(directoryBeginningWithNumber);
- assertEquals("name", "123xyz", f.getName());
- }
+ FTPFile f = getParser().parseFTPEntry(directoryBeginningWithNumber);
+ assertEquals("name", "123xyz", f.getName());
+ }
}
1.15 +3 -3 jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java
Index: VMSFTPEntryParserTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/VMSFTPEntryParserTest.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- VMSFTPEntryParserTest.java 21 Apr 2004 23:30:33 -0000 1.14
+++ VMSFTPEntryParserTest.java 22 Apr 2004 00:48:07 -0000 1.15
@@ -90,7 +90,7 @@
VMSFTPEntryParser parser = new VMSFTPEntryParser();
FTPListParseEngine engine = new FTPListParseEngine(parser);
engine.readServerList(
- new ByteArrayInputStream(fullListing.getBytes()));
+ new ByteArrayInputStream(fullListing.getBytes()));
FTPFile[] files = engine.getFiles();
assertEquals(6, files.length);
assertFileInListing(files, "2-JUN.LIS");
@@ -110,7 +110,7 @@
VMSFTPEntryParser parser = new VMSVersioningFTPEntryParser();
FTPListParseEngine engine = new FTPListParseEngine(parser);
engine.readServerList(
- new ByteArrayInputStream(fullListing.getBytes()));
+ new ByteArrayInputStream(fullListing.getBytes()));
FTPFile[] files = engine.getFiles();
assertEquals(3, files.length);
assertFileInListing(files, "1-JUN.LIS;1");
1.2 +14 -14 jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/AllTests.java
Index: AllTests.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/AllTests.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AllTests.java 6 Apr 2004 04:40:57 -0000 1.1
+++ AllTests.java 22 Apr 2004 00:48:07 -0000 1.2
@@ -17,18 +17,18 @@
*/
public class AllTests {
- public static Test suite() {
- TestSuite suite =
- new TestSuite("Test for org.apache.commons.net.ftp.parser");
- //$JUnit-BEGIN$
- suite.addTest(OS2FTPEntryParserTest.suite());
- suite.addTest(VMSFTPEntryParserTest.suite());
- suite.addTest(UnixFTPEntryParserTest.suite());
- suite.addTestSuite(DefaultFTPFileEntryParserFactoryTest.class);
- suite.addTest(EnterpriseUnixFTPEntryParserTest.suite());
- suite.addTest(OS400FTPEntryParserTest.suite());
- suite.addTest(NTFTPEntryParserTest.suite());
- //$JUnit-END$
- return suite;
- }
+ public static Test suite() {
+ TestSuite suite =
+ new TestSuite("Test for org.apache.commons.net.ftp.parser");
+ //$JUnit-BEGIN$
+ suite.addTest(OS2FTPEntryParserTest.suite());
+ suite.addTest(VMSFTPEntryParserTest.suite());
+ suite.addTest(UnixFTPEntryParserTest.suite());
+ suite.addTestSuite(DefaultFTPFileEntryParserFactoryTest.class);
+ suite.addTest(EnterpriseUnixFTPEntryParserTest.suite());
+ suite.addTest(OS400FTPEntryParserTest.suite());
+ suite.addTest(NTFTPEntryParserTest.suite());
+ //$JUnit-END$
+ return suite;
+ }
}
1.11 +5 -5 jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java
Index: UnixFTPEntryParserTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/UnixFTPEntryParserTest.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- UnixFTPEntryParserTest.java 21 Apr 2004 23:30:33 -0000 1.10
+++ UnixFTPEntryParserTest.java 22 Apr 2004 00:48:07 -0000 1.11
@@ -64,10 +64,10 @@
"-rw-r--r-- 1 500 500 2040000 Aug 5 07:35 testRemoteUPCopyNIX",
"-rw-r--r-- 1 500 500 2040000 Aug 5 07:31 testRemoteUPDCopyNIX",
"-rw-r--r-- 1 500 500 2040000 Aug 5 07:31 testRemoteUPVCopyNIX",
- "-rw-r--r-T 1 500 500 0 Mar 25 08:20 testSticky",
- "-rwxr-xr-t 1 500 500 0 Mar 25 08:21 testStickyExec",
- "-rwSr-Sr-- 1 500 500 0 Mar 25 08:22 testSuid",
- "-rwsr-sr-- 1 500 500 0 Mar 25 08:23 testSuidExec"
+ "-rw-r--r-T 1 500 500 0 Mar 25 08:20 testSticky",
+ "-rwxr-xr-t 1 500 500 0 Mar 25 08:21 testStickyExec",
+ "-rwSr-Sr-- 1 500 500 0 Mar 25 08:22 testSuid",
+ "-rwsr-sr-- 1 500 500 0 Mar 25 08:23 testSuidExec"
};
/**
1.3 +15 -15 jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/OS400FTPEntryParserTest.java
Index: OS400FTPEntryParserTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/test/org/apache/commons/net/ftp/parser/OS400FTPEntryParserTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- OS400FTPEntryParserTest.java 16 Apr 2004 01:52:24 -0000 1.2
+++ OS400FTPEntryParserTest.java 22 Apr 2004 00:48:07 -0000 1.3
@@ -30,11 +30,11 @@
private static final String[][] badsamples =
{
{
- "PEP 4019 04/03/18 18:58:16 STMF einladung.zip",
- "PEP 422 03/24 14:06:26 *STMF readme",
- "PEP 6409 04/03/24 30:06:29 *STMF build.xml",
- "PEP USR 36864 04/03/24 14:06:34 *DIR dir1/",
- "PEP 3686404/03/24 14:06:47 *DIR zdir2/"
+ "PEP 4019 04/03/18 18:58:16 STMF einladung.zip",
+ "PEP 422 03/24 14:06:26 *STMF readme",
+ "PEP 6409 04/03/24 30:06:29 *STMF build.xml",
+ "PEP USR 36864 04/03/24 14:06:34 *DIR dir1/",
+ "PEP 3686404/03/24 14:06:47 *DIR zdir2/"
},
{
@@ -49,11 +49,11 @@
private static final String[][] goodsamples =
{
{
- "PEP 4019 04/03/18 18:58:16 *STMF einladung.zip",
- "PEP 422 04/03/24 14:06:26 *STMF readme",
- "PEP 6409 04/03/24 14:06:29 *STMF build.xml",
- "PEP 36864 04/03/24 14:06:34 *DIR dir1/",
- "PEP 36864 04/03/24 14:06:47 *DIR zdir2/"
+ "PEP 4019 04/03/18 18:58:16 *STMF einladung.zip",
+ "PEP 422 04/03/24 14:06:26 *STMF readme",
+ "PEP 6409 04/03/24 14:06:29 *STMF build.xml",
+ "PEP 36864 04/03/24 14:06:34 *DIR dir1/",
+ "PEP 36864 04/03/24 14:06:47 *DIR zdir2/"
},
{
"----rwxr-x 1 PEP 0 4019 Mar 18 18:58 einladung.zip",
@@ -121,9 +121,9 @@
cal.set(Calendar.MONTH, Calendar.MARCH);
cal.set(Calendar.YEAR, 2004);
- cal.set(Calendar.DATE, 24);
+ cal.set(Calendar.DATE, 24);
cal.set(Calendar.HOUR_OF_DAY, 14);
- cal.set(Calendar.MINUTE, 6);
+ cal.set(Calendar.MINUTE, 6);
cal.set(Calendar.SECOND, 34);
assertEquals(df.format(cal.getTime()),
@@ -159,11 +159,11 @@
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DATE, 24);
- cal.set(Calendar.MONTH, Calendar.MARCH);
+ cal.set(Calendar.MONTH, Calendar.MARCH);
cal.set(Calendar.YEAR, 2004);
cal.set(Calendar.HOUR_OF_DAY, 14);
cal.set(Calendar.MINUTE, 6);
- cal.set(Calendar.SECOND, 29);
+ cal.set(Calendar.SECOND, 29);
assertEquals(df.format(cal.getTime()),
df.format(f.getTimestamp().getTime()));
}
1.10 +1 -1 jakarta-commons/net/src/java/org/apache/commons/net/smtp/SMTP.java
Index: SMTP.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/smtp/SMTP.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SMTP.java 21 Apr 2004 23:30:32 -0000 1.9
+++ SMTP.java 22 Apr 2004 00:48:07 -0000 1.10
@@ -175,7 +175,7 @@
try
{
- String code = line.substring(0, 3);
+ String code = line.substring(0, 3);
_replyCode = Integer.parseInt(code);
}
catch (NumberFormatException e)
1.12 +2 -2 jakarta-commons/net/src/java/org/apache/commons/net/tftp/TFTPClient.java
Index: TFTPClient.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/tftp/TFTPClient.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- TFTPClient.java 21 Apr 2004 23:30:32 -0000 1.11
+++ TFTPClient.java 22 Apr 2004 00:48:07 -0000 1.12
@@ -181,7 +181,7 @@
}
// The first time we receive we get the port number and
- // answering host address (for hosts with multiple IPs)
+ // answering host address (for hosts with multiple IPs)
if (lastBlock == 0)
{
hostPort = received.getPort();
@@ -420,7 +420,7 @@
}
// The first time we receive we get the port number and
- // answering host address (for hosts with multiple IPs)
+ // answering host address (for hosts with multiple IPs)
if (lastBlock == 0)
{
hostPort = received.getPort();
1.8 +11 -11 jakarta-commons/net/src/java/examples/ExtendedNNTPOps.java
Index: ExtendedNNTPOps.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/java/examples/ExtendedNNTPOps.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ExtendedNNTPOps.java 21 Apr 2004 23:30:34 -0000 1.7
+++ ExtendedNNTPOps.java 22 Apr 2004 00:48:07 -0000 1.8
@@ -167,31 +167,31 @@
// AUTHINFO USER/AUTHINFO PASS
boolean success = client.authenticate(user, password);
if(success)
- {
+ {
System.out.println("Authentication succeeded");
- }
+ }
else
- {
+ {
System.out.println("Authentication failed, error =" +
client.getReplyString());
- }
+ }
- // XOVER
- NewsgroupInfo testGroup = new NewsgroupInfo();
+ // XOVER
+ NewsgroupInfo testGroup = new NewsgroupInfo();
client.selectNewsgroup("alt.test", testGroup);
int lowArticleNumber = testGroup.getFirstArticle();
int highArticleNumber = testGroup.getLastArticle();
- Article[] articles =
+ Article[] articles =
getArticleInfo(lowArticleNumber, highArticleNumber);
- for(int i =0; i < articles.length; ++i)
+ for(int i =0; i < articles.length; ++i)
{
System.out.println(articles[i].getSubject());
}
- // LIST ACTIVE
- NewsgroupInfo[] fanGroups = client.listNewsgroups("alt.fan.*");
- for(int i = 0; i < fanGroups.length; ++i)
+ // LIST ACTIVE
+ NewsgroupInfo[] fanGroups = client.listNewsgroups("alt.fan.*");
+ for(int i = 0; i < fanGroups.length; ++i)
{
System.out.println(fanGroups[i].getNewsgroup());
}
1.10 +3 -3 jakarta-commons/net/src/java/examples/ftp.java
Index: ftp.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/java/examples/ftp.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ftp.java 29 Feb 2004 10:26:54 -0000 1.9
+++ ftp.java 22 Apr 2004 00:48:07 -0000 1.10
@@ -128,9 +128,9 @@
if (binaryTransfer)
ftp.setFileType(FTP.BINARY_FILE_TYPE);
- // Use passive mode as default because most of us are
- // behind firewalls these days.
- ftp.enterLocalPassiveMode();
+ // Use passive mode as default because most of us are
+ // behind firewalls these days.
+ ftp.enterLocalPassiveMode();
if (storeFile)
{
1.23 +4 -4 jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java
Index: VMSFTPEntryParser.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- VMSFTPEntryParser.java 21 Apr 2004 23:30:33 -0000 1.22
+++ VMSFTPEntryParser.java 22 Apr 2004 00:48:07 -0000 1.23
@@ -100,9 +100,9 @@
* @exception IOException If an I/O error occurs reading the listStream.
***/
public FTPFile[] parseFileList(InputStream listStream) throws IOException {
- FTPListParseEngine engine = new FTPListParseEngine(this);
- engine.readServerList(listStream);
- return engine.getFiles();
+ FTPListParseEngine engine = new FTPListParseEngine(this);
+ engine.readServerList(listStream);
+ return engine.getFiles();
}
1.3 +108 -108 jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParser.java
Index: OS400FTPEntryParser.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/OS400FTPEntryParser.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- OS400FTPEntryParser.java 6 Apr 2004 04:40:57 -0000 1.2
+++ OS400FTPEntryParser.java 22 Apr 2004 00:48:07 -0000 1.3
@@ -25,111 +25,111 @@
public class OS400FTPEntryParser extends RegexFTPFileEntryParserImpl
{
- private static final String REGEX =
- "(\\S+)\\s+" // user
- + "(\\d+)\\s+" // size
- + "(\\d\\d)/(\\d\\d)/(\\d\\d)\\s+" // year/month/day
- + "([0-2][0-9]):([0-5][0-9]):([0-5][0-9])\\s+" // hour:minutes:seconds
- + "(\\*\\S+)\\s+" // *STMF/*DIR
- + "(\\S+/?)\\s*"; // filename
-
- public OS400FTPEntryParser()
- {
- super(REGEX);
- }
-
- public FTPFile parseFTPEntry(String entry)
- {
-
- FTPFile file = new FTPFile();
- file.setRawListing(entry);
- int type;
-
- if (matches(entry))
- {
- String usr = group(1);
- String filesize = group(2);
- String yr = group(3);
- String mo = group(4);
- String da = group(5);
- String hr = group(6);
- String min = group(7);
- String sec = group(8);
- String typeStr = group(9);
- String name = group(10);
-
- if (typeStr.equalsIgnoreCase("*STMF"))
- {
- type = FTPFile.FILE_TYPE;
- }
- else if (typeStr.equalsIgnoreCase("*DIR"))
- {
- type = FTPFile.DIRECTORY_TYPE;
- }
- else
- {
- type = FTPFile.UNKNOWN_TYPE;
- }
-
- file.setType(type);
-
- file.setUser(usr);
-
- try
- {
- file.setSize(Integer.parseInt(filesize));
- }
- catch (NumberFormatException e)
- {
- // intentionally do nothing
- }
-
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.HOUR_OF_DAY, 0);
-
- try
- {
- int year = Integer.parseInt(yr, 10);
- if (year < 70)
- {
- year += 2000;
- }
- else
- {
- year += 1900;
- }
-
- cal.set(Calendar.YEAR, year);
- cal.set(Calendar.MONTH, Integer.parseInt(mo, 10)-1);
- cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(da, 10));
-
- cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hr, 10));
- cal.set(Calendar.MINUTE, Integer.parseInt(min, 10));
- cal.set(Calendar.SECOND, Integer.parseInt(sec, 10));
-
- file.setTimestamp(cal);
- }
- catch (NumberFormatException e)
- {
- // do nothing, date will be uninitialized
- }
-
- if (name.endsWith("/"))
- {
- name = name.substring(0, name.length() - 1);
- }
- int pos = name.lastIndexOf('/');
- if (pos > -1)
- {
- name = name.substring(pos + 1);
- }
-
- file.setName(name);
-
- return file;
- }
- return null;
- }
+ private static final String REGEX =
+ "(\\S+)\\s+" // user
+ + "(\\d+)\\s+" // size
+ + "(\\d\\d)/(\\d\\d)/(\\d\\d)\\s+" // year/month/day
+ + "([0-2][0-9]):([0-5][0-9]):([0-5][0-9])\\s+" // hour:minutes:seconds
+ + "(\\*\\S+)\\s+" // *STMF/*DIR
+ + "(\\S+/?)\\s*"; // filename
+
+ public OS400FTPEntryParser()
+ {
+ super(REGEX);
+ }
+
+ public FTPFile parseFTPEntry(String entry)
+ {
+
+ FTPFile file = new FTPFile();
+ file.setRawListing(entry);
+ int type;
+
+ if (matches(entry))
+ {
+ String usr = group(1);
+ String filesize = group(2);
+ String yr = group(3);
+ String mo = group(4);
+ String da = group(5);
+ String hr = group(6);
+ String min = group(7);
+ String sec = group(8);
+ String typeStr = group(9);
+ String name = group(10);
+
+ if (typeStr.equalsIgnoreCase("*STMF"))
+ {
+ type = FTPFile.FILE_TYPE;
+ }
+ else if (typeStr.equalsIgnoreCase("*DIR"))
+ {
+ type = FTPFile.DIRECTORY_TYPE;
+ }
+ else
+ {
+ type = FTPFile.UNKNOWN_TYPE;
+ }
+
+ file.setType(type);
+
+ file.setUser(usr);
+
+ try
+ {
+ file.setSize(Integer.parseInt(filesize));
+ }
+ catch (NumberFormatException e)
+ {
+ // intentionally do nothing
+ }
+
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+
+ try
+ {
+ int year = Integer.parseInt(yr, 10);
+ if (year < 70)
+ {
+ year += 2000;
+ }
+ else
+ {
+ year += 1900;
+ }
+
+ cal.set(Calendar.YEAR, year);
+ cal.set(Calendar.MONTH, Integer.parseInt(mo, 10)-1);
+ cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(da, 10));
+
+ cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hr, 10));
+ cal.set(Calendar.MINUTE, Integer.parseInt(min, 10));
+ cal.set(Calendar.SECOND, Integer.parseInt(sec, 10));
+
+ file.setTimestamp(cal);
+ }
+ catch (NumberFormatException e)
+ {
+ // do nothing, date will be uninitialized
+ }
+
+ if (name.endsWith("/"))
+ {
+ name = name.substring(0, name.length() - 1);
+ }
+ int pos = name.lastIndexOf('/');
+ if (pos > -1)
+ {
+ name = name.substring(pos + 1);
+ }
+
+ file.setName(name);
+
+ return file;
+ }
+ return null;
+ }
}
1.8 +2 -2 jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/VMSVersioningFTPEntryParser.java
Index: VMSVersioningFTPEntryParser.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/VMSVersioningFTPEntryParser.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- VMSVersioningFTPEntryParser.java 21 Apr 2004 23:30:33 -0000 1.7
+++ VMSVersioningFTPEntryParser.java 22 Apr 2004 00:48:07 -0000 1.8
@@ -96,7 +96,7 @@
* @return Original list purged of duplicates
*/
public List preParse(List original) {
- original = super.preParse(original);
+ original = super.preParse(original);
HashMap existingEntries = new HashMap();
ListIterator iter = original.listIterator();
while (iter.hasNext()) {
1.15 +193 -193 jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java
Index: UnixFTPEntryParser.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- UnixFTPEntryParser.java 21 Apr 2004 23:30:33 -0000 1.14
+++ UnixFTPEntryParser.java 22 Apr 2004 00:48:07 -0000 1.15
@@ -30,15 +30,15 @@
*/
public class UnixFTPEntryParser extends RegexFTPFileEntryParserImpl
{
- /**
- * months abbreviations looked for by this parser. Also used
- * to determine which month is matched by the parser
- */
- private static final String MONTHS =
- "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)";
+ /**
+ * months abbreviations looked for by this parser. Also used
+ * to determine which month is matched by the parser
+ */
+ private static final String MONTHS =
+ "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)";
- /**
- * this is the regular expression used by this parser.
+ /**
+ * this is the regular expression used by this parser.
*
* Permissions:
* r the file is readable
@@ -55,198 +55,198 @@
* execution is on
* T the 1000 bit is turned on, and execution is off (undefined bit-
* state)
- */
- private static final String REGEX =
- "([bcdlf-])"
- + "(((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-])))\\s+"
- + "(\\d+)\\s+"
- + "(\\S+)\\s+"
- + "(?:(\\S+)\\s+)?"
- + "(\\d+)\\s+"
- + MONTHS + "\\s+"
- + "((?:[0-9])|(?:[0-2][0-9])|(?:3[0-1]))\\s+"
- + "((\\d\\d\\d\\d)|((?:[01]\\d)|(?:2[0123])|(?:[1-9])):([012345]\\d))\\s+"
- + "(\\S+)(\\s*.*)";
-
-
- /**
- * The sole constructor for a UnixFTPEntryParser object.
- *
- * @exception IllegalArgumentException
- * Thrown if the regular expression is unparseable. Should not be seen
- * under normal conditions. It it is seen, this is a sign that
- * <code>REGEX</code> is not a valid regular expression.
- */
- public UnixFTPEntryParser()
- {
- super(REGEX);
- }
-
- /**
- * Parses a line of a unix (standard) FTP server file listing and converts
- * it into a usable format in the form of an <code> FTPFile </code>
- * instance. If the file listing line doesn't describe a file,
- * <code> null </code> is returned, otherwise a <code> FTPFile </code>
- * instance representing the files in the directory is returned.
- * <p>
- * @param entry A line of text from the file listing
- * @return An FTPFile instance corresponding to the supplied entry
- */
- public FTPFile parseFTPEntry(String entry)
- {
-
- FTPFile file = new FTPFile();
- file.setRawListing(entry);
- int type;
- boolean isDevice = false;
-
- if (matches(entry))
- {
- String typeStr = group(1);
- String hardLinkCount = group(15);
- String usr = group(16);
- String grp = group(17);
- String filesize = group(18);
- String mo = group(19);
- String da = group(20);
- String yr = group(22);
- String hr = group(23);
- String min = group(24);
- String name = group(25);
- String endtoken = group(26);
-
- switch (typeStr.charAt(0))
- {
- case 'd':
- type = FTPFile.DIRECTORY_TYPE;
- break;
- case 'l':
- type = FTPFile.SYMBOLIC_LINK_TYPE;
- break;
- case 'b':
- case 'c':
- isDevice = true;
- // break; - fall through
- default:
- type = FTPFile.FILE_TYPE;
- }
-
- file.setType(type);
-
- int g = 4;
- for (int access = 0; access < 3; access++, g += 4)
- {
- // Use != '-' to avoid having to check for suid and sticky bits
- file.setPermission(access, FTPFile.READ_PERMISSION,
- (!group(g).equals("-")));
- file.setPermission(access, FTPFile.WRITE_PERMISSION,
- (!group(g + 1).equals("-")));
+ */
+ private static final String REGEX =
+ "([bcdlf-])"
+ + "(((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-])))\\s+"
+ + "(\\d+)\\s+"
+ + "(\\S+)\\s+"
+ + "(?:(\\S+)\\s+)?"
+ + "(\\d+)\\s+"
+ + MONTHS + "\\s+"
+ + "((?:[0-9])|(?:[0-2][0-9])|(?:3[0-1]))\\s+"
+ + "((\\d\\d\\d\\d)|((?:[01]\\d)|(?:2[0123])|(?:[1-9])):([012345]\\d))\\s+"
+ + "(\\S+)(\\s*.*)";
+
+
+ /**
+ * The sole constructor for a UnixFTPEntryParser object.
+ *
+ * @exception IllegalArgumentException
+ * Thrown if the regular expression is unparseable. Should not be seen
+ * under normal conditions. It it is seen, this is a sign that
+ * <code>REGEX</code> is not a valid regular expression.
+ */
+ public UnixFTPEntryParser()
+ {
+ super(REGEX);
+ }
+
+ /**
+ * Parses a line of a unix (standard) FTP server file listing and converts
+ * it into a usable format in the form of an <code> FTPFile </code>
+ * instance. If the file listing line doesn't describe a file,
+ * <code> null </code> is returned, otherwise a <code> FTPFile </code>
+ * instance representing the files in the directory is returned.
+ * <p>
+ * @param entry A line of text from the file listing
+ * @return An FTPFile instance corresponding to the supplied entry
+ */
+ public FTPFile parseFTPEntry(String entry)
+ {
+
+ FTPFile file = new FTPFile();
+ file.setRawListing(entry);
+ int type;
+ boolean isDevice = false;
+
+ if (matches(entry))
+ {
+ String typeStr = group(1);
+ String hardLinkCount = group(15);
+ String usr = group(16);
+ String grp = group(17);
+ String filesize = group(18);
+ String mo = group(19);
+ String da = group(20);
+ String yr = group(22);
+ String hr = group(23);
+ String min = group(24);
+ String name = group(25);
+ String endtoken = group(26);
+
+ switch (typeStr.charAt(0))
+ {
+ case 'd':
+ type = FTPFile.DIRECTORY_TYPE;
+ break;
+ case 'l':
+ type = FTPFile.SYMBOLIC_LINK_TYPE;
+ break;
+ case 'b':
+ case 'c':
+ isDevice = true;
+ // break; - fall through
+ default:
+ type = FTPFile.FILE_TYPE;
+ }
+
+ file.setType(type);
+
+ int g = 4;
+ for (int access = 0; access < 3; access++, g += 4)
+ {
+ // Use != '-' to avoid having to check for suid and sticky bits
+ file.setPermission(access, FTPFile.READ_PERMISSION,
+ (!group(g).equals("-")));
+ file.setPermission(access, FTPFile.WRITE_PERMISSION,
+ (!group(g + 1).equals("-")));
String execPerm = group(g + 2);
if (!execPerm.equals("-") && !Character.isUpperCase(execPerm.charAt(0)))
{
- file.setPermission(access, FTPFile.EXECUTE_PERMISSION, true);
+ file.setPermission(access, FTPFile.EXECUTE_PERMISSION, true);
}
else
{
file.setPermission(access, FTPFile.EXECUTE_PERMISSION, false);
}
- }
+ }
+
+ if (!isDevice)
+ {
+ try
+ {
+ file.setHardLinkCount(Integer.parseInt(hardLinkCount));
+ }
+ catch (NumberFormatException e)
+ {
+ // intentionally do nothing
+ }
+ }
+
+ file.setUser(usr);
+ file.setGroup(grp);
- if (!isDevice)
- {
- try
- {
- file.setHardLinkCount(Integer.parseInt(hardLinkCount));
- }
- catch (NumberFormatException e)
- {
- // intentionally do nothing
- }
- }
-
- file.setUser(usr);
- file.setGroup(grp);
-
- try
- {
- file.setSize(Integer.parseInt(filesize));
- }
- catch (NumberFormatException e)
- {
- // intentionally do nothing
- }
-
- Calendar cal = Calendar.getInstance();
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.HOUR_OF_DAY, 0);
-
- try
- {
- int pos = MONTHS.indexOf(mo);
- int month = pos / 4;
-
- if (null != yr)
- {
- // it's a year
- cal.set(Calendar.YEAR, Integer.parseInt(yr));
- }
- else
- {
- // it must be hour/minute or we wouldn't have matched
- int year = cal.get(Calendar.YEAR);
- // if the month we're reading is greater than now, it must
- // be last year
- if (cal.get(Calendar.MONTH) < month)
- {
- year--;
- }
- cal.set(Calendar.YEAR, year);
- cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hr));
- cal.set(Calendar.MINUTE, Integer.parseInt(min));
- }
- cal.set(Calendar.MONTH, month);
-
- cal.set(Calendar.DATE, Integer.parseInt(da));
- file.setTimestamp(cal);
- }
- catch (NumberFormatException e)
- {
- // do nothing, date will be uninitialized
- }
- if (null == endtoken)
- {
- file.setName(name);
- }
- else
- {
- // oddball cases like symbolic links, file names
- // with spaces in them.
- name += endtoken;
- if (type == FTPFile.SYMBOLIC_LINK_TYPE)
- {
-
- int end = name.indexOf(" -> ");
- // Give up if no link indicator is present
- if (end == -1)
- {
- file.setName(name);
- }
- else
- {
- file.setName(name.substring(0, end));
- file.setLink(name.substring(end + 4));
- }
-
- }
- else
- {
- file.setName(name);
- }
- }
- return file;
- }
- return null;
- }
+ try
+ {
+ file.setSize(Integer.parseInt(filesize));
+ }
+ catch (NumberFormatException e)
+ {
+ // intentionally do nothing
+ }
+
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+
+ try
+ {
+ int pos = MONTHS.indexOf(mo);
+ int month = pos / 4;
+
+ if (null != yr)
+ {
+ // it's a year
+ cal.set(Calendar.YEAR, Integer.parseInt(yr));
+ }
+ else
+ {
+ // it must be hour/minute or we wouldn't have matched
+ int year = cal.get(Calendar.YEAR);
+ // if the month we're reading is greater than now, it must
+ // be last year
+ if (cal.get(Calendar.MONTH) < month)
+ {
+ year--;
+ }
+ cal.set(Calendar.YEAR, year);
+ cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hr));
+ cal.set(Calendar.MINUTE, Integer.parseInt(min));
+ }
+ cal.set(Calendar.MONTH, month);
+
+ cal.set(Calendar.DATE, Integer.parseInt(da));
+ file.setTimestamp(cal);
+ }
+ catch (NumberFormatException e)
+ {
+ // do nothing, date will be uninitialized
+ }
+ if (null == endtoken)
+ {
+ file.setName(name);
+ }
+ else
+ {
+ // oddball cases like symbolic links, file names
+ // with spaces in them.
+ name += endtoken;
+ if (type == FTPFile.SYMBOLIC_LINK_TYPE)
+ {
+
+ int end = name.indexOf(" -> ");
+ // Give up if no link indicator is present
+ if (end == -1)
+ {
+ file.setName(name);
+ }
+ else
+ {
+ file.setName(name.substring(0, end));
+ file.setLink(name.substring(end + 4));
+ }
+
+ }
+ else
+ {
+ file.setName(name);
+ }
+ }
+ return file;
+ }
+ return null;
+ }
}
1.4 +115 -115 jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/RegexFTPFileEntryParserImpl.java
Index: RegexFTPFileEntryParserImpl.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/RegexFTPFileEntryParserImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RegexFTPFileEntryParserImpl.java 21 Apr 2004 23:30:33 -0000 1.3
+++ RegexFTPFileEntryParserImpl.java 22 Apr 2004 00:48:07 -0000 1.4
@@ -34,122 +34,122 @@
*/
public abstract class RegexFTPFileEntryParserImpl extends FTPFileEntryParserImpl
{
- /**
- * internal pattern the matcher tries to match, representing a file
- * entry
- */
- private Pattern pattern = null;
-
- /**
- * internal match result used by the parser
- */
- private MatchResult result = null;
-
- /**
- * Internal PatternMatcher object used by the parser. It has protected
- * scope in case subclasses want to make use of it for their own purposes.
- */
- protected PatternMatcher _matcher_ = null;
-
-
- /**
- * The constructor for a RegexFTPFileEntryParserImpl object.
- *
- * @param regex The regular expression with which this object is
- * initialized.
- *
- * @exception IllegalArgumentException
- * Thrown if the regular expression is unparseable. Should not be seen in
- * normal conditions. It it is seen, this is a sign that a subclass has
- * been created with a bad regular expression. Since the parser must be
- * created before use, this means that any bad parser subclasses created
- * from this will bomb very quickly, leading to easy detection.
- */
- public RegexFTPFileEntryParserImpl(String regex)
- {
- super();
-
- try
- {
- _matcher_ = new Perl5Matcher();
- pattern = new Perl5Compiler().compile(regex);
- }
- catch (MalformedPatternException e)
- {
- throw new IllegalArgumentException (
- "Unparseable regex supplied: " + regex);
- }
- }
-
-
- /**
- * Convenience method delegates to the internal MatchResult's matches()
- * method.
- *
- * @param s the String to be matched
- * @return true if s matches this object's regular expression.
- */
- public boolean matches(String s)
- {
- this.result = null;
- if (_matcher_.matches(s.trim(), this.pattern))
- {
- this.result = _matcher_.getMatch();
- }
- return null != this.result;
- }
-
- /**
- * Convenience method delegates to the internal MatchResult's groups()
- * method.
- *
- * @return the number of groups() in the internal MatchResult.
- */
- public int getGroupCnt()
- {
- if (this.result == null)
- {
- return 0;
- }
- return this.result.groups();
- }
-
- /**
- * Convenience method delegates to the internal MatchResult's group()
- * method.
- *
- * @param matchnum match group number to be retrieved
- *
- * @return the content of the <code>matchnum'th<code> group of the internal
- * match or null if this method is called without a match having
- * been made.
- */
- public String group(int matchnum)
- {
- if (this.result == null)
- {
- return null;
- }
- return this.result.group(matchnum);
- }
-
- /**
- * For debugging purposes - returns a string shows each match group by
- * number.
- *
- * @return a string shows each match group by number.
- */
- public String getGroupsAsString()
- {
- StringBuffer b = new StringBuffer();
- for (int i = 1; i <= this.result.groups(); i++)
- {
- b.append(i).append(") ").append(this.result.group(i))
- .append(System.getProperty("line.separator"));
- }
- return b.toString();
+ /**
+ * internal pattern the matcher tries to match, representing a file
+ * entry
+ */
+ private Pattern pattern = null;
+
+ /**
+ * internal match result used by the parser
+ */
+ private MatchResult result = null;
+
+ /**
+ * Internal PatternMatcher object used by the parser. It has protected
+ * scope in case subclasses want to make use of it for their own purposes.
+ */
+ protected PatternMatcher _matcher_ = null;
+
+
+ /**
+ * The constructor for a RegexFTPFileEntryParserImpl object.
+ *
+ * @param regex The regular expression with which this object is
+ * initialized.
+ *
+ * @exception IllegalArgumentException
+ * Thrown if the regular expression is unparseable. Should not be seen in
+ * normal conditions. It it is seen, this is a sign that a subclass has
+ * been created with a bad regular expression. Since the parser must be
+ * created before use, this means that any bad parser subclasses created
+ * from this will bomb very quickly, leading to easy detection.
+ */
+ public RegexFTPFileEntryParserImpl(String regex)
+ {
+ super();
+
+ try
+ {
+ _matcher_ = new Perl5Matcher();
+ pattern = new Perl5Compiler().compile(regex);
+ }
+ catch (MalformedPatternException e)
+ {
+ throw new IllegalArgumentException (
+ "Unparseable regex supplied: " + regex);
+ }
+ }
+
+
+ /**
+ * Convenience method delegates to the internal MatchResult's matches()
+ * method.
+ *
+ * @param s the String to be matched
+ * @return true if s matches this object's regular expression.
+ */
+ public boolean matches(String s)
+ {
+ this.result = null;
+ if (_matcher_.matches(s.trim(), this.pattern))
+ {
+ this.result = _matcher_.getMatch();
+ }
+ return null != this.result;
+ }
+
+ /**
+ * Convenience method delegates to the internal MatchResult's groups()
+ * method.
+ *
+ * @return the number of groups() in the internal MatchResult.
+ */
+ public int getGroupCnt()
+ {
+ if (this.result == null)
+ {
+ return 0;
+ }
+ return this.result.groups();
+ }
+
+ /**
+ * Convenience method delegates to the internal MatchResult's group()
+ * method.
+ *
+ * @param matchnum match group number to be retrieved
+ *
+ * @return the content of the <code>matchnum'th<code> group of the internal
+ * match or null if this method is called without a match having
+ * been made.
+ */
+ public String group(int matchnum)
+ {
+ if (this.result == null)
+ {
+ return null;
+ }
+ return this.result.group(matchnum);
+ }
+
+ /**
+ * For debugging purposes - returns a string shows each match group by
+ * number.
+ *
+ * @return a string shows each match group by number.
+ */
+ public String getGroupsAsString()
+ {
+ StringBuffer b = new StringBuffer();
+ for (int i = 1; i <= this.result.groups(); i++)
+ {
+ b.append(i).append(") ").append(this.result.group(i))
+ .append(System.getProperty("line.separator"));
+ }
+ return b.toString();
- }
+ }
}
/* Emacs configuration
1.35 +115 -115 jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPClient.java
Index: FTPClient.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPClient.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- FTPClient.java 21 Apr 2004 23:30:33 -0000 1.34
+++ FTPClient.java 22 Apr 2004 00:48:07 -0000 1.35
@@ -2053,7 +2053,7 @@
throws IOException
{
FTPListParseEngine engine =
- initiateListParsing(parserKey, pathname);
+ initiateListParsing(parserKey, pathname);
return engine.getFiles();
}
@@ -2180,9 +2180,9 @@
* @see FTPListParseEngine
*/
public FTPListParseEngine initiateListParsing()
- throws IOException
- {
- return initiateListParsing("");
+ throws IOException
+ {
+ return initiateListParsing("");
}
/**
@@ -2201,18 +2201,18 @@
* expensive FTPFile objects are not created until needed which may be
* an advantage on large lists.
* <p>
- * <pre>
- * 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.
- * }
- * </pre>
+ * <pre>
+ * 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.
+ * }
+ * </pre>
*
* @return A FTPListParseEngine object that holds the raw information and
* is capable of providing parsed FTPFile objects, one for each file
@@ -2235,48 +2235,48 @@
* @see FTPListParseEngine
*/
public FTPListParseEngine initiateListParsing(
- String pathname)
- throws IOException
- {
- String key = null;
- return initiateListParsing(key, pathname);
- }
-
- /**
- * Using the supplied parser key, initialize an FTPListParseEngine
- * object containing a raw file information for the supplied directory.
- * This information is obtained through the LIST command. This object
- * is then capable of being iterated to return a sequence of FTPFile
- * objects with information filled in by the
- * <code> FTPFileEntryParser </code> used.
- * <p>
- * The server may or may not expand glob expressions. You should avoid
- * using glob expressions because the return format for glob listings
- * differs from server to server and will likely cause this method to fail.
- * <p>
- * This method differs from using the listFiles() methods in that
- * expensive FTPFile objects are not created until needed which may be
- * an advantage on large lists.
- *
- * @param parserKey A string representing a designated code or fully-qualified
+ String pathname)
+ throws IOException
+ {
+ String key = null;
+ return initiateListParsing(key, pathname);
+ }
+
+ /**
+ * Using the supplied parser key, initialize an FTPListParseEngine
+ * object containing a raw file information for the supplied directory.
+ * This information is obtained through the LIST command. This object
+ * is then capable of being iterated to return a sequence of FTPFile
+ * objects with information filled in by the
+ * <code> FTPFileEntryParser </code> used.
+ * <p>
+ * The server may or may not expand glob expressions. You should avoid
+ * using glob expressions because the return format for glob listings
+ * differs from server to server and will likely cause this method to fail.
+ * <p>
+ * This method differs from using the listFiles() methods in that
+ * expensive FTPFile objects are not created until needed which may be
+ * an advantage on large lists.
+ *
+ * @param parserKey A string representing a designated code or fully-qualified
* class name of an <code> FTPFileEntryParser </code> that should be
- * used to parse each server file listing.
- *
- * @return A FTPListParseEngine 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.
- *
- * @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
- * to send FTP reply code 421. This exception may be caught either
- * as an IOException or independently as itself.
- * @exception IOException
- * If an I/O error occurs while either sending a
- * command to the server or receiving a reply from the server.
+ * used to parse each server file listing.
+ *
+ * @return A FTPListParseEngine 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.
+ *
+ * @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
+ * to send FTP reply code 421. This exception may be caught either
+ * as an IOException or independently as itself.
+ * @exception IOException
+ * If an I/O error occurs while either sending a
+ * command to the server or receiving a reply from the server.
* @exception ParserInitializationException
* Thrown if the parserKey parameter cannot be
* resolved by the selected parser factory.
@@ -2288,25 +2288,25 @@
* nor a string containing one of the recognized keys
* mapping to such a parser or if class loader
* security issues prevent its being loaded.
- * @see FTPListParseEngine
- */
- public FTPListParseEngine initiateListParsing(
- String parserKey, String pathname)
- throws IOException
- {
- // if a null parserKey is supplied, autodetect by calling
- // the SYST command and use that to choose the parser.
- if (null == parserKey) {
- parserKey = getSystemName();
- }
-
- // We cache the value to avoid creation of a new object every
- // time a file listing is generated.
- if(__entryParser == null) {
- __entryParser = __parserFactory.createFileEntryParser(parserKey);
- }
+ * @see FTPListParseEngine
+ */
+ public FTPListParseEngine initiateListParsing(
+ String parserKey, String pathname)
+ throws IOException
+ {
+ // if a null parserKey is supplied, autodetect by calling
+ // the SYST command and use that to choose the parser.
+ if (null == parserKey) {
+ parserKey = getSystemName();
+ }
+
+ // We cache the value to avoid creation of a new object every
+ // time a file listing is generated.
+ if(__entryParser == null) {
+ __entryParser = __parserFactory.createFileEntryParser(parserKey);
+ }
- return initiateListParsing(__entryParser, pathname);
+ return initiateListParsing(__entryParser, pathname);
}
@@ -2326,24 +2326,24 @@
* @see FTPListParseEngine
*/
private FTPListParseEngine initiateListParsing(
- FTPFileEntryParser parser, String pathname)
- throws IOException
- {
- Socket socket;
+ FTPFileEntryParser parser, String pathname)
+ throws IOException
+ {
+ Socket socket;
- FTPListParseEngine engine = new FTPListParseEngine(parser);
- if ((socket = _openDataConnection_(FTPCommand.LIST, pathname)) == null)
- {
- return engine;
- }
+ FTPListParseEngine engine = new FTPListParseEngine(parser);
+ if ((socket = _openDataConnection_(FTPCommand.LIST, pathname)) == null)
+ {
+ return engine;
+ }
- engine.readServerList(socket.getInputStream());
+ engine.readServerList(socket.getInputStream());
- socket.close();
+ socket.close();
- completePendingCommand();
- return engine;
+ completePendingCommand();
+ return engine;
}
/***
@@ -2417,21 +2417,21 @@
* @deprecated use listFiles(String parserKey, String pathname) instead
*/
public FTPFile[] listFiles(FTPFileListParser parser, String pathname)
- throws IOException
- {
- Socket socket;
- FTPFile[] results;
+ throws IOException
+ {
+ Socket socket;
+ FTPFile[] results;
- if ((socket = _openDataConnection_(FTPCommand.LIST, pathname)) == null)
- return new FTPFile[0];
+ if ((socket = _openDataConnection_(FTPCommand.LIST, pathname)) == null)
+ return new FTPFile[0];
- results = parser.parseFileList(socket.getInputStream());
+ results = parser.parseFileList(socket.getInputStream());
- socket.close();
+ socket.close();
- completePendingCommand();
+ completePendingCommand();
- return results;
+ return results;
}
@@ -2461,8 +2461,8 @@
* @deprecated use listFiles(String parserKey) instead.
*/
public FTPFile[] listFiles(FTPFileListParser parser) throws IOException
- {
- return listFiles(parser, null);
+ {
+ return listFiles(parser, null);
}
@@ -2517,8 +2517,8 @@
* @see FTPFileList
*/
public FTPFileList createFileList(FTPFileEntryParser parser) throws IOException
- {
- return createFileList(null, parser);
+ {
+ return createFileList(null, parser);
}
/**
@@ -2553,22 +2553,22 @@
* @see FTPFileList
*/
public FTPFileList createFileList(String pathname,
- FTPFileEntryParser parser)
- throws IOException
- {
- Socket socket;
-
- if ((socket = _openDataConnection_(FTPCommand.LIST, pathname)) == null)
- {
- return null;
- }
+ FTPFileEntryParser parser)
+ throws IOException
+ {
+ Socket socket;
+
+ if ((socket = _openDataConnection_(FTPCommand.LIST, pathname)) == null)
+ {
+ return null;
+ }
- FTPFileList list = FTPFileList.create(socket.getInputStream(), parser);
+ FTPFileList list = FTPFileList.create(socket.getInputStream(), parser);
- socket.close();
+ socket.close();
- completePendingCommand();
- return list;
+ completePendingCommand();
+ return list;
}}
/* Emacs configuration
1.8 +9 -9 jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPFileEntryParserImpl.java
Index: FTPFileEntryParserImpl.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPFileEntryParserImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FTPFileEntryParserImpl.java 21 Apr 2004 23:30:33 -0000 1.7
+++ FTPFileEntryParserImpl.java 22 Apr 2004 00:48:07 -0000 1.8
@@ -87,15 +87,15 @@
* @return <code>original</code> unmodified.
*/
public List preParse(List original) {
- Iterator it = original.iterator();
- while (it.hasNext()){
- String entry = (String) it.next();
- if (null == parseFTPEntry(entry)) {
- it.remove();
- } else {
- break;
- }
- }
+ Iterator it = original.iterator();
+ while (it.hasNext()){
+ String entry = (String) it.next();
+ if (null == parseFTPEntry(entry)) {
+ it.remove();
+ } else {
+ break;
+ }
+ }
return original;
}
}
1.7 +70 -70 jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPListParseEngine.java
Index: FTPListParseEngine.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPListParseEngine.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FTPListParseEngine.java 21 Apr 2004 23:30:33 -0000 1.6
+++ FTPListParseEngine.java 22 Apr 2004 00:48:07 -0000 1.7
@@ -71,14 +71,14 @@
* @version $Id$
*/
public class FTPListParseEngine {
- private List entries = new LinkedList();
- private ListIterator _internalIterator = entries.listIterator();
+ private List entries = new LinkedList();
+ private ListIterator _internalIterator = entries.listIterator();
- FTPFileEntryParser parser = null;
+ FTPFileEntryParser parser = null;
- public FTPListParseEngine(FTPFileEntryParser parser) {
- this.parser = parser;
- }
+ public FTPListParseEngine(FTPFileEntryParser parser) {
+ this.parser = parser;
+ }
/**
* handle the iniitial reading and preparsing of the list returned by
@@ -91,14 +91,14 @@
* @exception IOException
* thrown on any failure to read from the sever.
*/
- public void readServerList(InputStream stream)
- throws IOException
- {
- this.entries = new LinkedList();
- readStream(stream);
+ public void readServerList(InputStream stream)
+ throws IOException
+ {
+ this.entries = new LinkedList();
+ readStream(stream);
this.parser.preParse(this.entries);
- resetIterator();
- }
+ resetIterator();
+ }
/**
@@ -114,20 +114,20 @@
* @exception IOException
* thrown on any failure to read the stream
*/
- private void readStream(InputStream stream) throws IOException
- {
- BufferedReader reader =
- new BufferedReader(new InputStreamReader(stream));
-
- String line = this.parser.readNextEntry(reader);
-
- while (line != null)
- {
- this.entries.add(line);
- line = this.parser.readNextEntry(reader);
- }
- reader.close();
- }
+ private void readStream(InputStream stream) throws IOException
+ {
+ BufferedReader reader =
+ new BufferedReader(new InputStreamReader(stream));
+
+ String line = this.parser.readNextEntry(reader);
+
+ while (line != null)
+ {
+ this.entries.add(line);
+ line = this.parser.readNextEntry(reader);
+ }
+ reader.close();
+ }
/**
* Returns an array of at most <code>quantityRequested</code> FTPFile
@@ -148,18 +148,18 @@
* list and at least the number of elements which exist in the list at
* and after its current position.
*/
- public FTPFile[] getNext(int quantityRequested) {
- List tmpResults = new LinkedList();
- int count = quantityRequested;
- while (count > 0 && this._internalIterator.hasNext()) {
- String entry = (String) this._internalIterator.next();
- FTPFile temp = this.parser.parseFTPEntry(entry);
- tmpResults.add(temp);
- count--;
- }
- return (FTPFile[]) tmpResults.toArray(new FTPFile[0]);
+ public FTPFile[] getNext(int quantityRequested) {
+ List tmpResults = new LinkedList();
+ int count = quantityRequested;
+ while (count > 0 && this._internalIterator.hasNext()) {
+ String entry = (String) this._internalIterator.next();
+ FTPFile temp = this.parser.parseFTPEntry(entry);
+ tmpResults.add(temp);
+ count--;
+ }
+ return (FTPFile[]) tmpResults.toArray(new FTPFile[0]);
- }
+ }
/**
* Returns an array of at most <code>quantityRequested</code> FTPFile
@@ -183,17 +183,17 @@
* and after its current position. This array will be in the same order
* as the underlying list (not reversed).
*/
- public FTPFile[] getPrevious(int quantityRequested) {
- List tmpResults = new LinkedList();
- int count = quantityRequested;
- while (count > 0 && this._internalIterator.hasPrevious()) {
- String entry = (String) this._internalIterator.previous();
- FTPFile temp = this.parser.parseFTPEntry(entry);
- tmpResults.add(0,temp);
- count--;
- }
- return (FTPFile[]) tmpResults.toArray(new FTPFile[0]);
- }
+ public FTPFile[] getPrevious(int quantityRequested) {
+ List tmpResults = new LinkedList();
+ int count = quantityRequested;
+ while (count > 0 && this._internalIterator.hasPrevious()) {
+ String entry = (String) this._internalIterator.previous();
+ FTPFile temp = this.parser.parseFTPEntry(entry);
+ tmpResults.add(0,temp);
+ count--;
+ }
+ return (FTPFile[]) tmpResults.toArray(new FTPFile[0]);
+ }
/**
* Returns an array of FTPFile objects containing the whole list of
@@ -203,19 +203,19 @@
* files returned by the server as read by this object's parser.
* @exception IOException
*/
- public FTPFile[] getFiles()
- throws IOException
- {
- List tmpResults = new LinkedList();
+ public FTPFile[] getFiles()
+ throws IOException
+ {
+ List tmpResults = new LinkedList();
Iterator iter = this.entries.iterator();
- while (iter.hasNext()) {
- String entry = (String) iter.next();
- FTPFile temp = this.parser.parseFTPEntry(entry);
- tmpResults.add(temp);
- }
- return (FTPFile[]) tmpResults.toArray(new FTPFile[0]);
+ while (iter.hasNext()) {
+ String entry = (String) iter.next();
+ FTPFile temp = this.parser.parseFTPEntry(entry);
+ tmpResults.add(temp);
+ }
+ return (FTPFile[]) tmpResults.toArray(new FTPFile[0]);
- }
+ }
/**
* convenience method to allow clients to know whether this object's
@@ -224,9 +224,9 @@
* @return true if internal iterator is not at end of list, false
* otherwise.
*/
- public boolean hasNext() {
- return _internalIterator.hasNext();
- }
+ public boolean hasNext() {
+ return _internalIterator.hasNext();
+ }
/**
* convenience method to allow clients to know whether this object's
@@ -235,14 +235,14 @@
* @return true if internal iterator is not at beginning of list, false
* otherwise.
*/
- public boolean hasPrevious() {
- return _internalIterator.hasPrevious();
- }
+ public boolean hasPrevious() {
+ return _internalIterator.hasPrevious();
+ }
/**
* resets this object's internal iterator to the beginning of the list.
*/
- public void resetIterator() {
- this._internalIterator = this.entries.listIterator();
- }
+ public void resetIterator() {
+ this._internalIterator = this.entries.listIterator();
+ }
}
1.12 +1 -1 jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTP.java
Index: FTP.java
===================================================================
RCS file: /home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTP.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- FTP.java 21 Apr 2004 23:30:33 -0000 1.11
+++ FTP.java 22 Apr 2004 00:48:07 -0000 1.12
@@ -262,7 +262,7 @@
try
{
- String code = line.substring(0, 3);
+ String code = line.substring(0, 3);
_replyCode = Integer.parseInt(code);
}
catch (NumberFormatException e)
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org