Skip to content

Commit 7ddf77b

Browse files
author
Rory Winston
committed
NET-276: Use long instead of int for newsgroup article counts
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/net/branches/NET_2_0@771683 13f79535-47bb-0310-9956-ffa450edef68
1 parent b1147fd commit 7ddf77b

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

src/main/java/examples/nntp/ExtendedNNTPOps.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public void demo(String host, String user, String password) {
5858
// XOVER
5959
NewsgroupInfo testGroup = new NewsgroupInfo();
6060
client.selectNewsgroup("alt.test", testGroup);
61-
int lowArticleNumber = testGroup.getFirstArticle();
62-
int highArticleNumber = lowArticleNumber + 100;
61+
long lowArticleNumber = testGroup.getFirstArticle();
62+
long highArticleNumber = lowArticleNumber + 100;
6363
List<Article> articles = NNTPUtils.getArticleInfo(client, lowArticleNumber, highArticleNumber);
6464

6565
for (Article article : articles) {

src/main/java/examples/nntp/MessageThreading.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public static void main(String[] args) throws SocketException, IOException {
5656
NewsgroupInfo group = new NewsgroupInfo();
5757
client.selectNewsgroup("alt.test", group);
5858

59-
int lowArticleNumber = group.getFirstArticle();
60-
int highArticleNumber = lowArticleNumber + 5000;
59+
long lowArticleNumber = group.getFirstArticle();
60+
long highArticleNumber = lowArticleNumber + 5000;
6161

6262
System.out.println("Retrieving articles between [" + lowArticleNumber + "] and [" + highArticleNumber + "]");
6363
List<Article> articles = NNTPUtils.getArticleInfo(client, lowArticleNumber, highArticleNumber);

src/main/java/examples/nntp/NNTPUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class NNTPUtils {
4545
* @return Article[] An array of Article
4646
* @throws IOException
4747
*/
48-
public static List<Article> getArticleInfo(NNTPClient client, int lowArticleNumber, int highArticleNumber)
48+
public static List<Article> getArticleInfo(NNTPClient client, long lowArticleNumber, long highArticleNumber)
4949
throws IOException {
5050
Reader reader = null;
5151
List<Article> articles = new ArrayList<Article>();

src/main/java/org/apache/commons/net/nntp/ArticlePointer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
public final class ArticlePointer
2929
{
3030
/** The number of the referenced article. */
31-
public int articleNumber;
31+
public long articleNumber;
3232
/**
3333
* The unique id of the referenced article, including the enclosing
3434
* &lt and &gt symbols which are technically not part of the

src/main/java/org/apache/commons/net/nntp/NNTPClient.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private void __parseArticlePointer(String reply, ArticlePointer pointer)
108108
// Get article number
109109
try
110110
{
111-
pointer.articleNumber = Integer.parseInt(tokenizer.nextToken());
111+
pointer.articleNumber = Long.parseLong(tokenizer.nextToken());
112112
}
113113
catch (NumberFormatException e)
114114
{
@@ -153,9 +153,9 @@ private void __parseGroupReply(String reply, NewsgroupInfo info)
153153

154154
try
155155
{
156-
info._setArticleCount(Integer.parseInt(count));
157-
info._setFirstArticle(Integer.parseInt(first));
158-
info._setLastArticle(Integer.parseInt(last));
156+
info._setArticleCount(Long.parseLong(count));
157+
info._setFirstArticle(Long.parseLong(first));
158+
info._setLastArticle(Long.parseLong(last));
159159
}
160160
catch (NumberFormatException e)
161161
{
@@ -176,7 +176,7 @@ private NewsgroupInfo __parseNewsgroupListEntry(String entry)
176176
{
177177
NewsgroupInfo result;
178178
StringTokenizer tokenizer;
179-
int lastNum, firstNum;
179+
long lastNum, firstNum;
180180
String last, first, permission;
181181

182182
result = new NewsgroupInfo();
@@ -192,8 +192,8 @@ private NewsgroupInfo __parseNewsgroupListEntry(String entry)
192192

193193
try
194194
{
195-
lastNum = Integer.parseInt(last);
196-
firstNum = Integer.parseInt(first);
195+
lastNum = Long.parseLong(last);
196+
firstNum = Long.parseLong(first);
197197
result._setFirstArticle(firstNum);
198198
result._setLastArticle(lastNum);
199199

@@ -1212,8 +1212,8 @@ public Reader retrieveArticleInfo(int articleNumber) throws IOException
12121212
* @return a DotTerminatedReader if successful, null otherwise
12131213
* @throws IOException
12141214
*/
1215-
public Reader retrieveArticleInfo(int lowArticleNumber,
1216-
int highArticleNumber)
1215+
public Reader retrieveArticleInfo(long lowArticleNumber,
1216+
long highArticleNumber)
12171217
throws IOException
12181218
{
12191219
return

src/main/java/org/apache/commons/net/nntp/NewsgroupInfo.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,26 @@ public final class NewsgroupInfo
5454
public static final int PROHIBITED_POSTING_PERMISSION = 3;
5555

5656
private String __newsgroup;
57-
private int __estimatedArticleCount;
58-
private int __firstArticle, __lastArticle;
57+
private long __estimatedArticleCount;
58+
private long __firstArticle, __lastArticle;
5959
private int __postingPermission;
6060

6161
void _setNewsgroup(String newsgroup)
6262
{
6363
__newsgroup = newsgroup;
6464
}
6565

66-
void _setArticleCount(int count)
66+
void _setArticleCount(long count)
6767
{
6868
__estimatedArticleCount = count;
6969
}
7070

71-
void _setFirstArticle(int first)
71+
void _setFirstArticle(long first)
7272
{
7373
__firstArticle = first;
7474
}
7575

76-
void _setLastArticle(int last)
76+
void _setLastArticle(long last)
7777
{
7878
__lastArticle = last;
7979
}
@@ -99,7 +99,7 @@ public String getNewsgroup()
9999
* <p>
100100
* @return The estimated number of articles in the newsgroup.
101101
***/
102-
public int getArticleCount()
102+
public long getArticleCount()
103103
{
104104
return __estimatedArticleCount;
105105
}
@@ -109,7 +109,7 @@ public int getArticleCount()
109109
* <p>
110110
* @return The number of the first article in the newsgroup.
111111
***/
112-
public int getFirstArticle()
112+
public long getFirstArticle()
113113
{
114114
return __firstArticle;
115115
}
@@ -119,7 +119,7 @@ public int getFirstArticle()
119119
* <p>
120120
* @return The number of the last article in the newsgroup.
121121
***/
122-
public int getLastArticle()
122+
public long getLastArticle()
123123
{
124124
return __lastArticle;
125125
}

0 commit comments

Comments
 (0)