List of usage examples for java.util NoSuchElementException NoSuchElementException
public NoSuchElementException()
From source file:jenkins.model.lazy.AbstractLazyLoadRunMap.java
public Integer firstKey() { R r = newestBuild();// w w w . j a v a 2 s . co m if (r == null) throw new NoSuchElementException(); return getNumberOf(r); }
From source file:eu.stratosphere.pact.runtime.sort.CombiningUnilateralSortMergerITCase.java
private static Iterator<Integer> getReducingIterator(MutableObjectIterator<Record> data, TypeSerializer<Record> serializer, TypeComparator<Record> comparator) { final KeyGroupedIterator<Record> groupIter = new KeyGroupedIterator<Record>(data, serializer, comparator); return new Iterator<Integer>() { private boolean hasNext = false; @Override//from ww w . ja v a 2 s .c o m public boolean hasNext() { if (hasNext) { return true; } try { hasNext = groupIter.nextKey(); } catch (IOException e) { throw new RuntimeException(e); } return hasNext; } @Override public Integer next() { if (hasNext()) { hasNext = false; Iterator<Record> values = groupIter.getValues(); Record rec = null; int cnt = 0; while (values.hasNext()) { rec = values.next(); cnt += rec.getField(1, IntValue.class).getValue(); } return cnt; } else { throw new NoSuchElementException(); } } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
From source file:jenkins.model.lazy.AbstractLazyLoadRunMap.java
public Integer lastKey() { R r = oldestBuild();/* ww w . ja v a 2 s . c o m*/ if (r == null) throw new NoSuchElementException(); return getNumberOf(r); }
From source file:com.telefonica.euro_iaas.sdc.pupperwrapper.services.tests.ActionsServiceTest.java
@Test(expected = NoSuchElementException.class) public void deleteNodeTestPuupetDBConnError() 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);// w ww . j a v a 2 s . c o m String strNodeName = "nodename"; when(shellNodeName.getInputStream()).thenReturn(new ByteArrayInputStream(strNodeName.getBytes("UTF-8"))); when(shellNodeName.getErrorStream()).thenReturn(new ByteArrayInputStream(" ".getBytes("UTF-8"))); String str = "Node 1 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 = "Node1.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); actionsService.deleteNode("1"); verify(shell, times(1)).getInputStream(); verify(shell2, times(2)).getInputStream(); verify(processBuilderFactory, times(3)).createProcessBuilder((String[]) anyObject()); }
From source file:chat.viska.commons.pipelines.Pipeline.java
public void addTowardsOutboundEnd(final Pipe next, final String name, final Pipe pipe) { Completable.fromAction(() -> {//from w w w . j a v a 2s. co m pipeLock.writeLock().lockInterruptibly(); try { if (getIteratorOf(name) != null) { throw new IllegalArgumentException("Name collision: " + name); } ListIterator<Map.Entry<String, Pipe>> iterator = getIteratorOf(next); if (iterator == null) { throw new NoSuchElementException(); } iterator.add(new AbstractMap.SimpleImmutableEntry<>(name, pipe)); pipe.onAddedToPipeline(this); } finally { pipeLock.writeLock().unlock(); } }).onErrorComplete().subscribeOn(Schedulers.io()).subscribe(); }
From source file:ArrayDeque.java
/** * Retrieves, but does not remove, the first element of this * deque. This method differs from the <tt>peek</tt> method only * in that it throws an exception if this deque is empty. * * @return the first element of this deque * @throws NoSuchElementException if this deque is empty *///ww w . j av a 2 s . c o m public E getFirst() { E x = elements[head]; if (x == null) throw new NoSuchElementException(); return x; }
From source file:ArrayDeque.java
/** * Retrieves, but does not remove, the last element of this * deque. This method differs from the <tt>peek</tt> method only * in that it throws an exception if this deque is empty. * * @return the last element of this deque * @throws NoSuchElementException if this deque is empty *//*from www . jav a 2s . c om*/ public E getLast() { E x = elements[(tail - 1) & (elements.length - 1)]; if (x == null) throw new NoSuchElementException(); return x; }
From source file:jp.terasoluna.fw.file.dao.standard.AbstractFileLineIterator.java
/** * ?????<br>//w w w.ja va2 s .com * <p> * ???????????<br> * ????????<br> * </p> * ?????InputFileColumn?? ?????<br> * ????????? ??????<br> * ???InputFileColumn????????????<br> * ??????????????<br> * <ul> * <li>?</li> * <li>?</li> * <li>??</li> * <li>?()?</li> * </ul> * @return * @throws FileException ?????? * @throws FileLineException ?????? */ @Override public T next() { if (readTrailer) { throw new FileLineException("Data part should be called before trailer part.", new IllegalStateException(), fileName, currentLineCount); } if (!hasNext()) { throw new FileLineException("The data which can be acquired doesn't exist.", new NoSuchElementException(), fileName, currentLineCount + 1); } T fileLineObject = null; // ?hasNext()??????null???? String currentString = readLine(); currentLineCount++; // ????? try { fileLineObject = clazz.newInstance(); } catch (InstantiationException e) { throw new FileException("Failed in an instantiate of a FileLineObject.", e, fileName); } catch (IllegalAccessException e) { throw new FileException("Failed in an instantiate of a FileLineObject.", e, fileName); } // CSV???????? // ???? String[] columns = separateColumns(currentString); // ???????? if (fields.length != columns.length) { throw new FileLineException("Column Count is different from " + "FileLineObject's column counts", new IllegalStateException(), fileName, currentLineCount); } int columnIndex = -1; String columnString = null; for (int i = 0; i < fields.length; i++) { // JavaBean??? columnIndex = columnIndexs[i]; // 1?? columnString = columns[columnIndex]; // ??? if (isCheckByte(columnBytes[i])) { try { if (columnString.getBytes(fileEncoding).length != columnBytes[i]) { throw new FileLineException("Data size is different from a set point " + "of a column.", new IllegalStateException(), fileName, currentLineCount, fields[i].getName(), columnIndex); } } catch (UnsupportedEncodingException e) { throw new FileException("fileEncoding which isn't supported was set.", e, fileName); } } // ? columnString = FileDAOUtility.trim(columnString, fileEncoding, trimChars[i], trimTypes[i]); // ? columnString = FileDAOUtility.padding(columnString, fileEncoding, columnBytes[i], paddingChars[i], paddingTypes[i]); // ??? columnString = stringConverters[i].convert(columnString); // ??? // JavaBean??????????? ColumnParser columnParser = columnParserMap.get(fields[i].getType().getName()); try { columnParser.parse(columnString, fileLineObject, methods[i], columnFormats[i]); } catch (IllegalArgumentException e) { throw new FileLineException("Failed in coluomn data parsing.", e, fileName, currentLineCount, fields[i].getName(), columnIndex); } catch (IllegalAccessException e) { throw new FileLineException("Failed in coluomn data parsing.", e, fileName, currentLineCount, fields[i].getName(), columnIndex); } catch (InvocationTargetException e) { throw new FileLineException("Failed in coluomn data parsing.", e, fileName, currentLineCount, fields[i].getName(), columnIndex); } catch (ParseException e) { throw new FileLineException("Failed in coluomn data parsing.", e, fileName, currentLineCount, fields[i].getName(), columnIndex); } } return fileLineObject; }
From source file:com.aliyun.odps.mapred.local.LocalTaskContext.java
@Override public Iterator<Record> readResourceTable(String tbl) throws IOException { if (StringUtils.isEmpty(tbl)) { throw new IOException("Table resouce name is empty or null"); }/*from w w w. ja v a2 s .c om*/ if (!jobDirecotry.hasResource(tbl)) { String project = SessionState.get().getOdps().getDefaultProject(); try { WareHouse.getInstance().copyResource(project, tbl, jobDirecotry.getResourceDir(), WareHouse.getInstance().getLimitDownloadRecordCount(), WareHouse.getInstance().getInputColumnSeperator()); } catch (OdpsException e) { } } File dir = new File(jobDirecotry.getResourceDir(), tbl); LOG.info("Reading resource table from " + dir); final List<File> datafiles = new ArrayList<File>(); LocalRunUtils.listAllDataFiles(dir, datafiles); final TableMeta tableMeta = SchemaUtils.readSchema(dir); return new Iterator<Record>() { RecordReader reader; Record current; boolean fetched; @Override public boolean hasNext() { if (fetched) { return current != null; } // Fetch new one try { fetch(); } catch (IOException e) { throw new RuntimeException(e); } return current != null; } private void fetch() throws IOException { // first time if (reader == null) { if (datafiles.isEmpty()) { current = null; fetched = true; return; } File f = datafiles.remove(0); reader = new CSVRecordReader(new FileSplit(f, tableMeta.getCols(), 0, f.getTotalSpace()), tableMeta, LocalJobRunner.EMPTY_COUNTER, LocalJobRunner.EMPTY_COUNTER, counters, WareHouse.getInstance().getInputColumnSeperator()); current = reader.read(); fetched = true; return; } current = reader.read(); if (current == null && !datafiles.isEmpty()) { File f = datafiles.remove(0); reader = new CSVRecordReader(new FileSplit(f, tableMeta.getCols(), 0, f.getTotalSpace()), tableMeta, LocalJobRunner.EMPTY_COUNTER, LocalJobRunner.EMPTY_COUNTER, counters, WareHouse.getInstance().getInputColumnSeperator()); current = reader.read(); fetched = true; return; } fetched = true; } @Override public Record next() { if (!hasNext()) { throw new NoSuchElementException(); } fetched = false; return current; } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
From source file:org.deegree.feature.persistence.geocouch.GeoCouchFeatureStore.java
@Override public FeatureInputStream query(final Query[] queries) throws FeatureStoreException, FilterEvaluationException { // check for most common case: multiple featuretypes, same bbox (WMS), no filter boolean wmsStyleQuery = false; Envelope env = queries[0].getPrefilterBBoxEnvelope(); if (queries[0].getFilter() == null && queries[0].getSortProperties().length == 0) { wmsStyleQuery = true;//from w w w . jav a 2s.co m for (int i = 1; i < queries.length; i++) { Envelope queryBBox = queries[i].getPrefilterBBoxEnvelope(); if (queryBBox != env && queries[i].getFilter() != null && queries[i].getSortProperties() != null) { wmsStyleQuery = false; break; } } } if (wmsStyleQuery) { // return queryMultipleFts( queries, env ); } Iterator<FeatureInputStream> rsIter = new Iterator<FeatureInputStream>() { int i = 0; @Override public boolean hasNext() { return i < queries.length; } @Override public FeatureInputStream next() { if (!hasNext()) { throw new NoSuchElementException(); } FeatureInputStream rs; try { rs = query(queries[i++]); } catch (Throwable e) { LOG.debug(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e); } return rs; } @Override public void remove() { throw new UnsupportedOperationException(); } }; return new CombinedFeatureInputStream(rsIter); }