36 |
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> |
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> |
37 |
* @version $Revision$ $Date$ |
* @version $Revision$ $Date$ |
38 |
*/ |
*/ |
39 |
public class OverviewIterator |
public class OverviewIterator extends LineIterator |
|
extends LineIterator |
|
40 |
{ |
{ |
41 |
|
|
42 |
OverviewIterator(NNTPConnection connection) |
OverviewIterator(NNTPConnection connection) |
46 |
|
|
47 |
/** |
/** |
48 |
* Returns the next overview entry. |
* Returns the next overview entry. |
49 |
*/ |
*/ |
50 |
public Object next() |
public Object next() |
51 |
{ |
{ |
52 |
try |
try |
53 |
{ |
{ |
54 |
return nextOverview(); |
return nextOverview(); |
55 |
} |
} |
56 |
catch (IOException e) |
catch(IOException e) |
57 |
{ |
{ |
58 |
throw new NoSuchElementException("I/O error: "+e.getMessage()); |
throw new NoSuchElementException("I/O error: " + e.getMessage()); |
59 |
} |
} |
60 |
} |
} |
61 |
|
|
62 |
/** |
/** |
63 |
* Returns the next overview entry. |
* Returns the next overview entry. |
64 |
*/ |
*/ |
65 |
public Overview nextOverview() |
public Overview nextOverview() throws IOException |
|
throws IOException |
|
66 |
{ |
{ |
67 |
String line = nextLine(); |
String line = nextLine(); |
68 |
|
|
69 |
// Parse line |
// Parse line |
70 |
int start = 0, end; |
int start = 0, end; |
71 |
end = line.indexOf('\t', start); |
end = line.indexOf('\t', start); |
72 |
int articleNumber = Integer.parseInt(line.substring(start, end)); |
int articleNumber = Integer.parseInt(line.substring(start, end)); |
73 |
start = end+1; |
start = end + 1; |
74 |
Overview overview = new Overview(articleNumber); |
Overview overview = new Overview(articleNumber); |
75 |
end = line.indexOf('\t', start); |
end = line.indexOf('\t', start); |
76 |
while (end>-1) |
while (end > -1) |
77 |
{ |
{ |
78 |
String entry = line.substring(start, end); |
String entry = line.substring(start, end); |
79 |
overview.add(entry); |
overview.add(entry); |
80 |
end = line.indexOf('\t', start); |
end = line.indexOf('\t', start); |
81 |
start = end+1; |
start = end + 1; |
82 |
} |
} |
83 |
String entry = line.substring(start); |
String entry = line.substring(start); |
84 |
overview.add(entry); |
overview.add(entry); |
85 |
|
|
86 |
return overview; |
return overview; |
87 |
} |
} |
88 |
|
|