List of usage examples for java.util NoSuchElementException NoSuchElementException
public NoSuchElementException()
From source file:com.joyent.manta.client.MantaDirectoryListingIterator.java
@Override public synchronized Map<String, Object> next() { if (!hasNext()) { throw new NoSuchElementException(); }//from w w w . j a v a 2 s . c om try { String line = nextLine.getAndSet(br.readLine()); lines.incrementAndGet(); if (line == null) { selectReader(); if (finished.get()) { throw new NoSuchElementException(); } line = nextLine.getAndSet(br.readLine()); } final Map<String, Object> lookup = mapper.readValue(line, new TypeReference<Map<String, Object>>() { }); final String name = Objects.toString(lookup.get("name")); Validate.notNull(name, "Name must not be null in JSON input"); /* Explicitly set the path of the object here so that we don't need * to create a new instance of MantaObjectConversionFunction per * object being read. */ lookup.put("path", path); this.lastMarker = name; return lookup; } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:net.javacoding.queue.DiskQueue.java
/** * @see org.archive.queue.Queue#getIterator(boolean) * @return iterator//from w w w .j av a 2s . c o m */ public Iterator getIterator(boolean inCacheOnly) { // There are no levels of storage so we will return all items. Iterator it = null; if (isInitialized) { try { it = new DiskQueueIterator(bytes.getReadAllInputStream(), length); } catch (IOException e) { e.printStackTrace(); } } if (it == null) { it = new Iterator() { public void remove() { throw new UnsupportedOperationException(); } public boolean hasNext() { return false; } public Object next() { throw new NoSuchElementException(); } }; } return it; }
From source file:edu.uci.ics.jung.algorithms.util.MapBinaryHeap.java
public T element() throws NoSuchElementException { T top = this.peek(); if (top == null) throw new NoSuchElementException(); return top;/*from w ww . j av a 2 s. c o m*/ }
From source file:com.telefonica.euro_iaas.sdc.pupperwrapper.services.tests.ActionsServiceTest.java
@Test public void deleteNodeTestOK() throws IOException { Process shell = mock(Process.class); Process shell2 = mock(Process.class); Process shellNodeName = mock(Process.class); String[] cmd = { anyString() }; // call to puppet cert list --all when(processBuilderFactory.createProcessBuilder(cmd)).thenReturn(shellNodeName).thenReturn(shell) .thenReturn(shell2);/*from w w w. ja va2 s. c o m*/ String strNodeName = "\"1.novalocal\""; when(shellNodeName.getInputStream()).thenReturn(new ByteArrayInputStream(strNodeName.getBytes("UTF-8"))); when(shellNodeName.getErrorStream()).thenReturn(new ByteArrayInputStream(" ".getBytes("UTF-8"))); String str = "Node 1.novalocal is registered"; String strdelete = "Node 1 unregistered"; when(shell.getInputStream()).thenReturn(new ByteArrayInputStream(str.getBytes("UTF-8"))) .thenReturn(new ByteArrayInputStream(strdelete.getBytes("UTF-8"))); String strEr = " "; when(shell.getErrorStream()).thenReturn(new ByteArrayInputStream(strEr.getBytes("UTF-8"))); String str2 = "1.novalocal"; when(shell2.getInputStream()).thenReturn(new ByteArrayInputStream(str2.getBytes("UTF-8"))); String strEr2 = " "; when(shell2.getErrorStream()).thenReturn(new ByteArrayInputStream(strEr2.getBytes("UTF-8"))); when(catalogManagerMongo.getNode("1")).thenReturn(node1).thenThrow(new NoSuchElementException()) .thenReturn(node1); when(statusLine.getStatusCode()).thenReturn(200); actionsService.deleteNode("1"); verify(shell, times(1)).getInputStream(); verify(shell2, times(1)).getInputStream(); verify(shellNodeName, times(1)).getInputStream(); verify(processBuilderFactory, times(3)).createProcessBuilder((String[]) anyObject()); }
From source file:CircularQueue.java
public E remove() { if (isEmpty()) { throw new NoSuchElementException(); } return poll(); }
From source file:com.nofuturecorp.www.connector.DataSet.java
@Override public Iterator<ColumnSet> iterator() { return new Iterator<ColumnSet>() { @Override//from w w w.ja v a 2s . co m public boolean hasNext() { if (dataSet != null && dataSet.size() > 0) { if (position >= dataSet.size() - 1) { position = -1; return false; } else { return true; } } else { position = -1; return false; } } @Override public ColumnSet next() { if (position == dataSet.size()) { throw new NoSuchElementException(); } position++; return dataSet.get(position); } @Override public void remove() { } }; }
From source file:CircularQueue.java
public E element() { if (isEmpty()) { throw new NoSuchElementException(); } return peek(); }
From source file:com.cloudera.oryx.common.collection.LongFloatMap.java
void iteratorRemove(int lastNext) { if (lastNext >= values.length) { throw new NoSuchElementException(); }//from w w w .j a va2s.c om Preconditions.checkState(lastNext >= 0); values[lastNext] = VALUE_NULL; keys[lastNext] = REMOVED; numEntries--; }
From source file:edu.uci.ics.jung.algorithms.util.MapBinaryHeap.java
public T remove() { T top = this.poll(); if (top == null) throw new NoSuchElementException(); return top;/*from w w w. j a va 2 s .co m*/ }
From source file:org.obiba.mica.micaConfig.service.OpalService.java
private synchronized Map<String, Taxonomy> getTaxonomiesInternal() { try {//from w ww .j a v a 2s.co m return opalServiceHelper.getTaxonomies(getOpalJavaClient()); } catch (URISyntaxException e) { log.error("Malformed opal URI", e); throw new NoSuchElementException(); } }