List of usage examples for java.util NoSuchElementException NoSuchElementException
public NoSuchElementException()
From source file:marmot.tokenize.preprocess.WikiReader.java
@Override public Pair next() { readNext();//from ww w. j a v a 2 s.co m if (pair_ == null) { throw new NoSuchElementException(); } Pair pair = pair_; pair_ = null; return pair; }
From source file:com.textocat.textokit.commons.cpe.FileDirectoryCollectionReader.java
/** * {@inheritDoc}/*from w w w .j a va 2 s. c o m*/ */ @Override public void getNext(CAS aCAS) throws IOException, CollectionException { if (!hasNext()) { throw new CollectionException(new NoSuchElementException()); } final int curFileIdx = lastReadFileIdx + 1; File file = files.get(curFileIdx); lastReadFileIdx = curFileIdx; // String fileContent = FileUtils.readFileToString(file, encoding); aCAS.setDocumentText(fileContent); try { DocumentMetadata docMeta = new DocumentMetadata(aCAS.getJCas()); docMeta.setSourceUri(getURIForMetadata(file).toString()); docMeta.addToIndexes(); } catch (CASException e) { throw new IllegalStateException(e); } }
From source file:edu.cornell.med.icb.goby.counts.PeakAggregator.java
/** * Return the next detected peak. The same instance of Peak is reused to provide information * about the peak. Make a copy if you need to save the peak for some purpose. * @return the next detected peak/*from ww w . j av a2 s . c om*/ */ public Peak next() { if (hasNext()) { nextLoaded = false; return currentPeak; } else { throw new NoSuchElementException(); } }
From source file:PSOResultFileReader.java
@Override public ResultEntry next() { if (!hasNext()) { throw new NoSuchElementException(); }/*from w w w. j av a 2 s .c o m*/ ResultEntry result = nextEntry; nextEntry = null; return result; }
From source file:com.android.messaging.datamodel.data.ConversationParticipantsData.java
@Override public Iterator<ParticipantData> iterator() { return new Iterator<ParticipantData>() { private int mCurrentIndex = -1; @Override// www.ja va 2 s .co m public boolean hasNext() { return mCurrentIndex < mConversationParticipantsMap.size() - 1; } @Override public ParticipantData next() { mCurrentIndex++; if (mCurrentIndex >= mConversationParticipantsMap.size()) { throw new NoSuchElementException(); } return mConversationParticipantsMap.valueAt(mCurrentIndex); } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
From source file:com.ignorelist.kassandra.steam.scraper.SharedConfig.java
public VdfNode getGameNode(Long gameId) { final VdfNode gameNode = getGameNodeMap().get(gameId); if (null == gameNode) { throw new NoSuchElementException(); }// w w w.j ava 2 s .co m return gameNode; }
From source file:ComplexKeyHashMap.java
public EntryIterator getEntrySetIterator() { return new EntryIterator() { Entry next; // next entry to return int index; // current slot Entry current; // current entry {/*from w ww. j a va 2s . c o m*/ Entry[] t = table; int i = t.length; Entry n = null; if (size != 0) { // advance to first entry while (i > 0 && (n = t[--i]) == null) { } } next = n; index = i; } public boolean hasNext() { return next != null; } public Entry next() { return nextEntry(); } Entry nextEntry() { Entry e = next; if (e == null) throw new NoSuchElementException(); Entry n = e.next; Entry[] t = table; int i = index; while (n == null && i > 0) n = t[--i]; index = i; next = n; return current = e; } }; }
From source file:com.datasayer.meerkat.MeerJobRunner.java
@SuppressWarnings("unchecked") @Override/* w ww . ja v a 2 s .c o m*/ public void bsp(final BSPPeer<Writable, Writable, Writable, Writable, Writable> peer) throws IOException, SyncException, InterruptedException { while (true) { try { long currentTime = System.currentTimeMillis(); FileSystem fs = FileSystem.get(conf); if (!fs.isFile(logPath)) { System.out.println("can not read input file"); return; } RandomAccessFile file = new RandomAccessFile(logPath.toString(), "r"); long fileLength = file.length(); if (fileLength > filePointer) { file.seek(filePointer); String line = null; while (file.length() > file.getFilePointer()) { line = file.readLine(); line = new String(line.getBytes("8859_1"), "utf-8"); guardMeer.observe(line); } filePointer = file.getFilePointer(); } else { // nothing to do } file.close(); long timeDiff = currentTime - this.lastAggregatedTime; if (timeDiff >= this.aggregationInterval) { peer.sync(); if (peer.getPeerName().equals(masterName)) { bossMeer.masterCompute(new Iterator<Writable>() { private final int producedMessages = peer.getNumCurrentMessages(); private int consumedMessages = 0; @Override public boolean hasNext() { return producedMessages > consumedMessages; } @Override public Writable next() throws NoSuchElementException { if (consumedMessages >= producedMessages) { throw new NoSuchElementException(); } try { consumedMessages++; return peer.getCurrentMessage(); } catch (IOException e) { throw new NoSuchElementException(); } } @Override public void remove() { // BSPPeer.getCurrentMessage originally deletes a message. // Thus, it doesn't need to throw exception. // throw new UnsupportedOperationException(); } }, signalMeer); this.lastAggregatedTime = currentTime; } } } catch (IOException e) { e.printStackTrace(); } } }
From source file:com.opengamma.util.timeseries.fast.longint.object.FastMapLongObjectTimeSeries.java
@Override public long getTimeFast(final int index) { if (index >= _map.size()) { throw new NoSuchElementException(); }// w w w .j a va 2s. c o m final LongBidirectionalIterator iterator = _map.keySet().iterator(); iterator.skip(index); return iterator.nextLong(); }
From source file:de.codesourcery.eve.skills.ui.utils.CalendarWidget.java
private Iterator<MyButton> buttonIterator() { return new Iterator<MyButton>() { private int x = 0; private int y = 0; @Override//from w ww.j a va 2 s .c o m public boolean hasNext() { return y < 4; } @Override public MyButton next() { if (!hasNext()) { throw new NoSuchElementException(); } final MyButton result = buttons[y][x]; x++; if (x == 7) { x = 0; y++; } return result; } @Override public void remove() { throw new UnsupportedOperationException("remove()"); } }; }