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

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

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

revision 1.1 by dog, Sun Oct 19 08:51:37 2003 UTC revision 1.2 by dog, Sun Oct 19 16:16:50 2003 UTC
# Line 36  import java.util.NoSuchElementException; Line 36  import java.util.NoSuchElementException;
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 GroupIterator  public class GroupIterator extends LineIterator
   extends LineIterator  
40  {  {
41    
42    static final String CAN_POST = "y";    static final String CAN_POST = "y";
43      
44    GroupIterator(NNTPConnection connection)      GroupIterator(NNTPConnection connection)
45    {    {
46      super(connection);      super(connection);
47    }    }
48    
49    /**    /**
50     * Returns the next group.     * Returns the next group.
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.     * Returns the next group.
66     */     */
67    public Group nextGroup()    public Group nextGroup() throws IOException
     throws IOException  
68    {    {
69      String line = nextLine();      String line = nextLine();
70        
71      // Parse line      // Parse line
72      int start = 0, end;      int start = 0, end;
73      end = line.indexOf(' ', start);        end = line.indexOf(' ', start);
74      String name = line.substring(start, end);      String name = line.substring(start, end);
75      start = end+1;        start = end + 1;
76      end = line.indexOf(' ', start);        end = line.indexOf(' ', start);
77      int last = Integer.parseInt(line.substring(start, end));      int last = Integer.parseInt(line.substring(start, end));
78      start = end+1;        start = end + 1;
79      end = line.indexOf(' ', start);        end = line.indexOf(' ', start);
80      int first = Integer.parseInt(line.substring(start, end));      int first = Integer.parseInt(line.substring(start, end));
81      start = end+1;        start = end + 1;
82      boolean canPost = CAN_POST.equals(line.substring(start));      boolean canPost = CAN_POST.equals(line.substring(start));
83        
84      return new Group(name, last, first, canPost);        return new Group(name, last, first, canPost);
85    }    }
86    
87  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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