/[classpath]/inetlib/source/gnu/inet/nntp/OverviewIterator.java
ViewVC logotype

Diff of /inetlib/source/gnu/inet/nntp/OverviewIterator.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by dog, Thu Oct 21 15:21:55 2004 UTC revision 1.7 by dog, Thu Nov 25 22:15:05 2004 UTC
# Line 1  Line 1 
1  /*  /*
2   * $Id$   * OverviewIterator.java
3   * Copyright (C) 2002 The Free Software Foundation   * Copyright (C) 2002 The Free Software Foundation
4   *   *
5   * This file is part of GNU inetlib, a library.   * This file is part of GNU inetlib, a library.
# Line 45  import java.util.NoSuchElementException; Line 45  import java.util.NoSuchElementException;
45   * An iterator over an overview listing.   * An iterator over an overview listing.
46   *   *
47   * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>   * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
  * @version $Revision$ $Date$  
48   */   */
49  public class OverviewIterator extends LineIterator  public class OverviewIterator
50      extends LineIterator
51  {  {
52    
53    OverviewIterator (NNTPConnection connection)    OverviewIterator(NNTPConnection connection)
54    {    {
55      super (connection);      super(connection);
56    }    }
57    
58    /**    /**
59     * Returns the next overview entry.     * Returns the next overview entry.
60     */     */
61    public Object next ()    public Object next()
62    {    {
63      try      try
64        {        {
65          return nextOverview ();          return nextOverview();
66        }        }
67      catch (IOException e)      catch (IOException e)
68        {        {
69          throw new NoSuchElementException ("I/O error: " + e.getMessage ());          throw new NoSuchElementException("I/O error: " + e.getMessage());
70        }        }
71    }    }
72    
73    /**    /**
74     * Returns the next overview entry.     * Returns the next overview entry.
75     */     */
76    public Overview nextOverview () throws IOException    public Overview nextOverview()
77        throws IOException
78    {    {
79      String line = nextLine ();      String line = nextLine();
80    
81      // Parse line      // Parse line
82      int start = 0, end;      int start = 0, end;
83      end = line.indexOf ('\t', start);      end = line.indexOf('\t', start);
84      int articleNumber = Integer.parseInt (line.substring (start, end));      int articleNumber = Integer.parseInt(line.substring(start, end));
85      start = end + 1;      start = end + 1;
86      Overview overview = new Overview (articleNumber);      Overview overview = new Overview(articleNumber);
87      end = line.indexOf ('\t', start);      end = line.indexOf('\t', start);
88      while (end > -1)      while(end > -1)
89        {        {
90          String entry = line.substring (start, end);          String entry = line.substring(start, end);
91          overview.add (entry);          overview.add(entry);
92          start = end + 1;          start = end + 1;
93          end = line.indexOf ('\t', start);          end = line.indexOf('\t', start);
94        }        }
95      String entry = line.substring (start);      String entry = line.substring(start);
96      overview.add (entry);      overview.add(entry);
97    
98      return overview;      return overview;
99    }    }
100    
101  }  }
102    

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26