38 |
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> |
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> |
39 |
* @version $Revision$ $Date$ |
* @version $Revision$ $Date$ |
40 |
*/ |
*/ |
41 |
public class ActiveTimesIterator |
public class ActiveTimesIterator extends LineIterator |
|
extends LineIterator |
|
42 |
{ |
{ |
43 |
|
|
44 |
ActiveTimesIterator(NNTPConnection connection) |
ActiveTimesIterator(NNTPConnection connection) |
48 |
|
|
49 |
/** |
/** |
50 |
* Returns the next group active time. |
* Returns the next group active time. |
51 |
*/ |
*/ |
52 |
public Object next() |
public Object next() |
53 |
{ |
{ |
54 |
try |
try |
55 |
{ |
{ |
56 |
return nextGroup(); |
return nextGroup(); |
57 |
} |
} |
58 |
catch (IOException e) |
catch(IOException e) |
59 |
{ |
{ |
60 |
throw new NoSuchElementException("I/O error: "+e.getMessage()); |
throw new NoSuchElementException("I/O error: " + e.getMessage()); |
61 |
} |
} |
62 |
} |
} |
63 |
|
|
64 |
/** |
/** |
65 |
* Returns the next group active time. |
* Returns the next group active time. |
66 |
*/ |
*/ |
67 |
public ActiveTime nextGroup() |
public ActiveTime nextGroup() throws IOException |
|
throws IOException |
|
68 |
{ |
{ |
69 |
String line = nextLine(); |
String line = nextLine(); |
70 |
|
|
71 |
// Parse line |
// Parse line |
72 |
try |
try |
73 |
{ |
{ |
74 |
int start = 0, end; |
int start = 0, end; |
75 |
end = line.indexOf(' ', start); |
end = line.indexOf(' ', start); |
76 |
String group = line.substring(start, end); |
String group = line.substring(start, end); |
77 |
start = end+1; |
start = end + 1; |
78 |
end = line.indexOf(' ', start); |
end = line.indexOf(' ', start); |
79 |
Date time = connection.parseDate(line.substring(start, end)); |
Date time = connection.parseDate(line.substring(start, end)); |
80 |
start = end+1; |
start = end + 1; |
81 |
String email = line.substring(start); |
String email = line.substring(start); |
82 |
|
|
83 |
return new ActiveTime(group, time, email); |
return new ActiveTime(group, time, email); |
84 |
} |
} |
85 |
catch (ParseException e) |
catch(ParseException e) |
86 |
{ |
{ |
87 |
throw new IOException(e.getMessage()); |
throw new IOException(e.getMessage()); |
88 |
} |
} |