Search in sources :

Example 6 with NoSuchElementException

use of java.util.NoSuchElementException in project groovy by apache.

the class EmptyRangeTest method testIterator.

/**
     * Test method for {@link groovy.lang.EmptyRange#iterator()}.
     */
public void testIterator() {
    final Iterator iterator = range.iterator();
    assertFalse("iterator has next value", iterator.hasNext());
    try {
        iterator.next();
        fail("got next value in an empty range");
    } catch (NoSuchElementException e) {
        assertTrue("expected exception thrown", true);
    }
}
Also used : Iterator(java.util.Iterator) ListIterator(java.util.ListIterator) NoSuchElementException(java.util.NoSuchElementException)

Example 7 with NoSuchElementException

use of java.util.NoSuchElementException in project flink by apache.

the class DataSourceTask method getInputSplits.

private Iterator<InputSplit> getInputSplits() {
    final InputSplitProvider provider = getEnvironment().getInputSplitProvider();
    return new Iterator<InputSplit>() {

        private InputSplit nextSplit;

        private boolean exhausted;

        @Override
        public boolean hasNext() {
            if (exhausted) {
                return false;
            }
            if (nextSplit != null) {
                return true;
            }
            final InputSplit split;
            try {
                split = provider.getNextInputSplit(getUserCodeClassLoader());
            } catch (InputSplitProviderException e) {
                throw new RuntimeException("Could not retrieve next input split.", e);
            }
            if (split != null) {
                this.nextSplit = split;
                return true;
            } else {
                exhausted = true;
                return false;
            }
        }

        @Override
        public InputSplit next() {
            if (this.nextSplit == null && !hasNext()) {
                throw new NoSuchElementException();
            }
            final InputSplit tmp = this.nextSplit;
            this.nextSplit = null;
            return tmp;
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
}
Also used : Iterator(java.util.Iterator) InputSplitProviderException(org.apache.flink.runtime.jobgraph.tasks.InputSplitProviderException) InputSplitProvider(org.apache.flink.runtime.jobgraph.tasks.InputSplitProvider) InputSplit(org.apache.flink.core.io.InputSplit) NoSuchElementException(java.util.NoSuchElementException)

Example 8 with NoSuchElementException

use of java.util.NoSuchElementException in project hadoop by apache.

the class CorruptFileBlockIterator method next.

@Override
public Path next() throws IOException {
    if (!hasNext()) {
        throw new NoSuchElementException("No more corrupt file blocks");
    }
    Path result = nextPath;
    loadNext();
    return result;
}
Also used : Path(org.apache.hadoop.fs.Path) NoSuchElementException(java.util.NoSuchElementException)

Example 9 with NoSuchElementException

use of java.util.NoSuchElementException in project hbase by apache.

the class WALEntryStream method next.

/**
   * @return the next WAL entry in this stream
   * @throws WALEntryStreamRuntimeException if there was an IOException
   * @throws NoSuchElementException if no more entries in the stream.
   */
@Override
public Entry next() {
    if (!hasNext())
        throw new NoSuchElementException();
    Entry save = currentEntry;
    // gets reloaded by hasNext()
    currentEntry = null;
    return save;
}
Also used : Entry(org.apache.hadoop.hbase.wal.WAL.Entry) NoSuchElementException(java.util.NoSuchElementException)

Example 10 with NoSuchElementException

use of java.util.NoSuchElementException in project hbase by apache.

the class RowResultGenerator method next.

public Cell next() {
    if (cache != null) {
        Cell kv = cache;
        cache = null;
        return kv;
    }
    if (valuesI == null) {
        return null;
    }
    try {
        return valuesI.next();
    } catch (NoSuchElementException e) {
        return null;
    }
}
Also used : Cell(org.apache.hadoop.hbase.Cell) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

NoSuchElementException (java.util.NoSuchElementException)645 Iterator (java.util.Iterator)119 Scanner (java.util.Scanner)59 Test (org.junit.Test)53 IOException (java.io.IOException)49 ArrayList (java.util.ArrayList)47 InputMismatchException (java.util.InputMismatchException)46 StringTokenizer (java.util.StringTokenizer)43 Locale (java.util.Locale)24 HashMap (java.util.HashMap)22 NodeIterator (javax.jcr.NodeIterator)20 File (java.io.File)19 Map (java.util.Map)19 ConcurrentLinkedDeque (java.util.concurrent.ConcurrentLinkedDeque)16 Collection (java.util.Collection)15 LinkedList (java.util.LinkedList)15 List (java.util.List)15 Set (java.util.Set)15 BufferedReader (java.io.BufferedReader)13 Enumeration (java.util.Enumeration)13