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

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

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

revision 1.5 by dog, Thu Oct 21 15:21:55 2004 UTC revision 1.6 by dog, Thu Nov 25 22:15:05 2004 UTC
# Line 1  Line 1 
1  /*  /*
2   * $Id$   * PairIterator.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 a pair listing.   * An iterator over a pair 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 PairIterator extends LineIterator  public class PairIterator
50      extends LineIterator
51  {  {
52    
53    PairIterator (NNTPConnection connection)    PairIterator(NNTPConnection connection)
54    {    {
55      super (connection);      super(connection);
56    }    }
57    
58    /**    /**
59     * Returns the next pair.     * Returns the next pair.
60     */     */
61    public Object next ()    public Object next()
62    {    {
63      try      try
64        {        {
65          return nextPair ();          return nextPair();
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 pair.     * Returns the next pair.
75     */     */
76    public Pair nextPair () throws IOException    public Pair nextPair()
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 (' ', start);      end = line.indexOf(' ', start);
84      String key = line.substring (start, end);      String key = line.substring(start, end);
85      start = end + 1;      start = end + 1;
86      String value = line.substring (start);      String value = line.substring(start);
87    
88      return new Pair (key, value);      return new Pair(key, value);
89    }    }
90    
91  }  }
92    

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

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