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/01/01 21:49:49 UTC
cvs commit: jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser VMSFTPEntryParser.java
scohen 2004/01/01 12:49:49
Modified: net/src/java/examples ExtendedNNTPOps.java
net/src/java/org/apache/commons/net/ftp/parser
VMSFTPEntryParser.java
Log:
refactor back to JDK 1.1 compatibility.
HashMap -> Hashtable
ArrayList -> [] or use StringTokenizer to avoid having to fall back to deprecated methods in ORO.
Revision Changes Path
1.3 +8 -5 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ExtendedNNTPOps.java 23 Sep 2003 02:53:56 -0000 1.2
+++ ExtendedNNTPOps.java 1 Jan 2004 20:49:48 -0000 1.3
@@ -58,7 +58,6 @@
import java.io.IOException;
import java.io.Reader;
import java.io.PrintWriter;
-import java.util.ArrayList;
import java.util.StringTokenizer;
import org.apache.commons.net.io.DotTerminatedMessageReader;
@@ -143,9 +142,8 @@
int highArticleNumber)
throws IOException
{
- ArrayList articles = new ArrayList();
Reader reader = null;
-
+ Article[] articles = new Article[0];
reader = (DotTerminatedMessageReader)
client.retrieveArticleInfo(lowArticleNumber, highArticleNumber);
@@ -156,6 +154,11 @@
// Extract the article information
// Mandatory format (from NNTP RFC 2980) is :
// Subject\tAuthor\tDate\tID\tReference(s)\tByte Count\tLine Count
+
+ int count = st.countTokens();
+ articles = new Article[count];
+ int index = 0;
+
while (st.hasMoreTokens()) {
StringTokenizer stt = new StringTokenizer(st.nextToken(), "\t");
Article article = new Article();
@@ -165,13 +168,13 @@
article.setDate(stt.nextToken());
article.setArticleId(stt.nextToken());
article.addHeaderField("References", stt.nextToken());
- articles.add(article);
+ articles[index++] = article;
}
} else {
return null;
}
- return (Article[]) articles.toArray(new Article[articles.size()]);
+ return articles;
}
private String readerToString(Reader reader)
1.9 +18 -14 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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- VMSFTPEntryParser.java 30 Dec 2003 03:58:52 -0000 1.8
+++ VMSFTPEntryParser.java 1 Jan 2004 20:49:48 -0000 1.9
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,8 +55,9 @@
*/
import java.util.Calendar;
-import java.util.HashMap;
-import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -209,7 +210,7 @@
files = super.parseFileList(listingStream);
} else {
FTPFile[] tempFiles = super.parseFileList(listingStream);
- HashMap filesHash = new HashMap();
+ Hashtable filesHash = new Hashtable();
String fileName;
for (int index = 0; index < tempFiles.length; index++) {
@@ -218,8 +219,14 @@
filesHash.put(fileName, (FTPFile) tempFiles[index]);
}
}
+ files = new FTPFile[filesHash.size()];
+ Enumeration e = filesHash.keys();
+ int index = 0;
+ while (e.hasMoreElements()) {
+ FTPFile ftpf = (FTPFile) filesHash.get(e.nextElement());
+ files[index++] = ftpf;
+ }
- files = (FTPFile[]) filesHash.values().toArray(new FTPFile[0]);
}
return files;
@@ -256,18 +263,15 @@
String owner = group(9);
String grp;
String user;
- ArrayList list = new ArrayList();
-
- Util.split(list, _matcher_, OWNER_SPLIT_PATTERN, owner);
-
- switch (list.size()) {
+ StringTokenizer t = new StringTokenizer(owner, ",");
+ switch (t.countTokens()) {
case 1:
grp = null;
- user = (String)list.get(0);
+ user = t.nextToken();
break;
case 2:
- grp = (String)list.get(0);
- user = (String)list.get(1);
+ grp = t.nextToken();
+ user = t.nextToken();
break;
default:
grp = null;
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org