Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## junitutils
Class LineIterator

    java.lang.Object
      junitutils.LineIterator

All Implemented Interfaces:
  java.util.Iterator

public class LineIterator
extends java.lang.Object
implements java.util.Iterator

This is a utility class that is an iterator over the lines produced by reading a file. It is used in particular by various JUnit tests.

Author:
  David R. Cok

Field Summary
`private java.lang.String` | `nextLine` The next value to be returned by the iterator.
`private java.io.BufferedReader` | `r` A reader that reads lines from the file.

Constructor Summary
`LineIterator(java.lang.String filename)` Starts an iterator reading from the given external process.

Method Summary
`boolean` | `hasNext()` Per a standard iterator, returns true if there is another value waiting.
`java.lang.Object` | `next()` Per a standard iterator, returns the next value - and throws java.util.NoSuchElementException if the list has been exhausted (hasNext() returns false).
`void` | `remove()` This operation will throw an exception, as there is no need for remove in this context.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### r

    private java.io.BufferedReader r

  A reader that reads lines from the file.

### nextLine

    private java.lang.String nextLine

  The next value to be returned by the iterator. We read ahead one so that we know the value of hasNext() when asked.

Constructor Detail

### LineIterator

    public LineIterator(java.lang.String filename)
                 throws java.io.IOException

  Starts an iterator reading from the given external process.

Parameters:
  `filename` - The name of the file to be read

Method Detail

### hasNext

    public boolean hasNext()
                    throws java.lang.RuntimeException

  Per a standard iterator, returns true if there is another value waiting.

  Specified by:
    `hasNext` in interface `java.util.Iterator`
  Throws:
    `java.lang.RuntimeException`

### next

    public java.lang.Object next()
                          throws java.util.NoSuchElementException,
                                 java.lang.RuntimeException

  Per a standard iterator, returns the next value - and throws java.util.NoSuchElementException if the list has been exhausted (hasNext() returns false).

  Specified by:
    `next` in interface `java.util.Iterator`
  Throws:
    `java.util.NoSuchElementException`
    `java.lang.RuntimeException`

### remove

    public void remove()
                throws java.lang.UnsupportedOperationException

  This operation will throw an exception, as there is no need for remove in this context.

  Specified by:
    `remove` in interface `java.util.Iterator`
  Throws:
    `java.lang.UnsupportedOperationException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

The ESC/Java2 Project Homepage