List of usage examples for java.util NoSuchElementException NoSuchElementException
public NoSuchElementException()
From source file:InlineSchemaValidator.java
public Iterator getPrefixes(String namespaceURI) { if (namespaceURI == null) { throw new IllegalArgumentException("Namespace URI cannot be null."); } else if (XMLConstants.XML_NS_URI.equals(namespaceURI)) { return new Iterator() { boolean more = true; public boolean hasNext() { return more; }/*from www.j a v a 2 s . c o m*/ public Object next() { if (!hasNext()) { throw new NoSuchElementException(); } more = false; return XMLConstants.XML_NS_PREFIX; } public void remove() { throw new UnsupportedOperationException(); } }; } else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) { return new Iterator() { boolean more = true; public boolean hasNext() { return more; } public Object next() { if (!hasNext()) { throw new NoSuchElementException(); } more = false; return XMLConstants.XMLNS_ATTRIBUTE; } public void remove() { throw new UnsupportedOperationException(); } }; } else if (fURIToPrefixMappings != null) { HashSet prefixes = (HashSet) fURIToPrefixMappings.get(namespaceURI); if (prefixes != null && prefixes.size() > 0) { return prefixes.iterator(); } } return Collections.EMPTY_LIST.iterator(); }
From source file:com.cloudera.oryx.common.collection.LongObjectMap.java
void iteratorRemove(int lastNext) { if (lastNext >= values.length) { throw new NoSuchElementException(); }/*w w w . j a va 2s . c o m*/ Preconditions.checkState(lastNext >= 0); values[lastNext] = null; keys[lastNext] = REMOVED; numEntries--; }
From source file:org.apache.mina.util.CircularQueue.java
public E remove() { if (isEmpty()) { throw new NoSuchElementException(); } return poll(); }
From source file:com.predic8.membrane.core.interceptor.authentication.session.LDAPUserDataProvider.java
@Override public Map<String, String> verify(Map<String, String> postData) { String username = postData.get("username"); String password = postData.get("password"); if (username == null || password == null) throw new NoSuchElementException(); try {/*from ww w.jav a 2 s . c o m*/ return auth(username, password); } catch (NoSuchElementException e) { throw e; } catch (AuthenticationException e) { log.debug(e); throw new NoSuchElementException(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.apache.mina.util.CircularQueue.java
public E element() { if (isEmpty()) { throw new NoSuchElementException(); } return peek(); }
From source file:org.obiba.mica.micaConfig.service.OpalService.java
public Search.EntitiesResultDto getEntitiesCount(String opalUrl, String query, String entityType) { try {/*ww w . j a v a 2s . co m*/ return opalServiceHelper.getEntitiesCount(getOpalJavaClient(opalUrl), query, entityType); } catch (URISyntaxException e) { log.error("Malformed opal URI", e); throw new NoSuchElementException(); } }
From source file:fr.mtlx.odm.spring.SpringOperationsImpl.java
@Override public Iterable<List<T>> pages(final int pageSize, String filter, Name base, final SearchControls controls) { class PagedResultIterator implements Iterator<List<T>> { private PagedResultsCookie cookie = null; @Override//from w w w. jav a 2 s . c o m public boolean hasNext() { return cookie == null || cookie.getCookie() != null; } @Override public List<T> next() { if (!hasNext()) { throw new NoSuchElementException(); } PagedResultsDirContextProcessor processor = new PagedResultsDirContextProcessor(pageSize, cookie); try { List<T> results = search(base, controls, filter, Optional.of(processor)); cookie = processor.getCookie(); return results; } catch (javax.naming.SizeLimitExceededException ex) { throw new NoSuchElementException(ex.getExplanation()); } } } return () -> new PagedResultIterator(); }
From source file:com.telefonica.euro_iaas.sdc.pupperwrapper.services.tests.ActionsServiceTest.java
@Test(expected = IOException.class) public void deleteNodeTestException() throws IOException { Process shell = mock(Process.class); Process shellNodeName = mock(Process.class); String[] cmd = { anyString() }; when(processBuilderFactory.createProcessBuilder(cmd)).thenReturn(shellNodeName).thenReturn(shellNodeName) .thenReturn(shell);/* w w w. jav a2s .c om*/ String strNodeName = "1.novalocal"; when(shellNodeName.getInputStream()).thenReturn(new ByteArrayInputStream(strNodeName.getBytes("UTF-8"))) .thenReturn(new ByteArrayInputStream(strNodeName.getBytes("UTF-8"))); when(shellNodeName.getErrorStream()).thenReturn(new ByteArrayInputStream(" ".getBytes("UTF-8"))); String str = ""; String strdelete = ""; 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"))); when(catalogManagerMongo.getNode("1")).thenReturn(node1).thenThrow(new NoSuchElementException()) .thenReturn(node1); // delete node 1 actionsService.deleteNode("1"); verify(shell, times(1)).getInputStream(); verify(processBuilderFactory, times(3)).createProcessBuilder((String[]) anyObject()); }
From source file:chat.viska.commons.pipelines.Pipeline.java
public void addTowardsInboundEnd(final Pipe previous, final String name, final Pipe pipe) { Completable.fromAction(() -> {/* w ww . j av a 2 s . c om*/ pipeLock.writeLock().lockInterruptibly(); try { if (getIteratorOf(name) != null) { throw new IllegalArgumentException("Name collision: " + name); } ListIterator<Map.Entry<String, Pipe>> iterator = getIteratorOf(previous); if (iterator == null) { throw new NoSuchElementException(); } iterator.next(); iterator.add(new AbstractMap.SimpleImmutableEntry<>(name, pipe)); pipe.onAddedToPipeline(this); } finally { pipeLock.writeLock().unlock(); } }).onErrorComplete().subscribeOn(Schedulers.io()).subscribe(); }
From source file:net.mlw.vlh.adapter.jdbc.dynabean.fix.ResultSetIterator.java
/** * <p>Return the next element in the iteration.</p> */// w ww.ja v a 2 s . c om public Object next() { try { advance(); if (eof) { throw new NoSuchElementException(); } current = false; return (this); } catch (SQLException e) { throw new RuntimeException("next(): SQLException: " + e); } }